-
Notifications
You must be signed in to change notification settings - Fork 701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cabal repl doesn't respect flag constraints for dependencies #7017
Comments
I've tried to reproduce this with cabal 3.2 but from my POV,
cabal v2-repl --constraint="gloss +GLFW -GLUT"
appears to be honored (you notice this if you change the flag settings
and cabal hasn't cached yet the different flag configuration it'll
rebuild a different instance of `gloss` and its rev-deps); in fact, if I
invoke
cabal v2-repl --constraint="gloss -GLFW -GLUT"
`gloss` would fail to build because it include a CPP conditional that
will trigger a compile error if neither the GLFW nor the GLUT backend
have been compile-time enabled:
,----
| $ cabal v2-repl --constraint="gloss -GLFW -GLUT"
| Resolving dependencies...
| Build profile: -w ghc-8.10.2 -O1
| In order, the following will be built (use -v for more details):
| - gloss-1.13.1.2 (lib) (requires build)
| - essence-of-live-coding-tutorial-0.2.2 (exe:essence-of-live-coding-tutorial) (first run)
| Starting gloss-1.13.1.2 (lib)
| Building gloss-1.13.1.2 (lib)
|
| Failed to build gloss-1.13.1.2.
| Build log (
| /home/hvr/.cabal/logs/ghc-8.10.2/gloss-1.13.1.2-2d63cd816ebde03d84ef0dbc18eee2e68e2f3e34a8344cb19fd6ff5dc5cdfbcb.log
| ):
| Configuring library for gloss-1.13.1.2..
| Preprocessing library for gloss-1.13.1.2..
| Building library for gloss-1.13.1.2..
|
| Graphics/Gloss/Internals/Interface/Backend.hs:31:2: error:
| error: #error No default backend defined
| #error No default backend defined
| ^~~~~
| |
| 31 | #error No default backend defined
| | ^
|
| Graphics/Gloss/Internals/Interface/Backend.hs:1:1: error:
| `cc' failed in phase `C pre-processor'. (Exit code: 1)
| |
| 1 | {-# LANGUAGE CPP #-}
| | ^
| cabal: Failed to build gloss-1.13.1.2 (which is required by
| exe:essence-of-live-coding-tutorial from
| essence-of-live-coding-tutorial-0.2.2). See the build log above for details.
`----
PS: I don't have nix-shell (as I don't use Nix myself), so I couldn't
properly reproduce your instructions, however from the looks of it I
don't think it would have made any significant difference
|
Thank you for trying to reproduce! This is the behaviour I would expect. Then it must be an interaction with Nix. The nix-shell supplies a particular version of |
Then it must be an interaction with Nix. The nix-shell supplies a
particular version of `gloss` to GHC, namely one built with default
flags (`-GLFW +GLUT`), and it seems like `cabal repl` (or in fact all
of cabal? not sure) doesn't try to do anything about that.
Aha! That's actually a good point! If your dependency is already
contained in the global or user package-db (which is what you'd end up
e.g. when you install Debian-packaged Haskell packages via `apt-get` --
or like nix-shell seems to do), then those packages will be preferred.
And the problem with flags in "(pre)installed" (this is the technical
term for those and a keyword for constraints) packages is that the flag
settings aren't recorded in in ghc-pkg's metadata, so cabal has no way
to know that a preinstalled package doesn't have the requested flag.
so what you *can* do, is to explicitly tell cabal via the constraint
specification to force using a non-preinstalled from-"source" package:
long story short, try adding a
…--constraint "gloss source"
flag, in addition to your
--constraint "gloss +GLWF -GLUT"
flag, and see if that makes any difference.
For the record, these special constraint-types are mentioned e.g. in
https://cabal.readthedocs.io/en/3.4/setup-commands.html?highlight=source#cmdoption-runhaskell-Setup.hs-configure-constraint
|
Yes, that resolves the cabal issue! Thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The bug was originally discovered in a special case here: turion/essence-of-live-coding-tutorial#3
In that case, the application has a dependency to
gloss
, which has the flagsGLUT
andGLFW
. We tried setting these flags withcabal repl --constraint="gloss +GLFW -GLUT"
and by writing them down incabal.project.local
. Nevertheless, always the GLUT backend is selected.A clear and concise description of what the bug is.
To Reproduce
You will see an error message saying something with
GLUT
.The text was updated successfully, but these errors were encountered: