-
Notifications
You must be signed in to change notification settings - Fork 704
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
--extra-lib-dirs and --extra-include-dirs ignored? #2997
Comments
It appears the same problem exists with global |
This is a question about what packages do top level options apply to? All packages all the way down, all packages local to the project or what? The current answer is all packages local to the project. So in this example since text-icu is not local to the project then the top level options do not apply to it. |
Btw, here's a quite common use-case I heard from an OSX user w/ homebrew:
|
What if we give a warning if these options are passed in from command line? They could be legitimate, but I think in most cases they won't be, and a user can always stick it in |
Sorry -- dumb and slightly off-topic question here -- but I just want to make sure that the options set in the ~/.cabal/configure file for these two are always respected even under new-build? |
.cabal/config is respected by new-build. See also http://ezyang.com/nix-local-build.html#configuring-builds-with-cabal.project for all the config that is used in this determination. |
So, let's assume that I want all Cabal build to find header files in |
@peti btw, one problem I recently realised is that such a global setting would force every package, including GHC boot libraries to be recompiled, as it would force a new nix-hash (as those flags enter the hash computation). And for non-reinstallable packages such as |
I see. Yes, that makes sense. I am basically happy specifying those Now, if I could add
to |
@peti Personally, I think that'd quite reasonable to have in ~/.cabal/config (or nearby). I do wonder though how to be able to locally override the global setting. Especially with openssl, I've sometimes needed temporarily to use a newer local versions rather than the system-wide installed one (e.g. On the other hand, I guess a local I think we have enough here to turn this into a specification for a feature-request ticket... :-) |
@hvr, I see what you mean.
|
If anyone is looking for a workaround: I found that setting the For example, I have a project that has a dependency on the lzma package. When running regular But this did work:
|
Note that search paths configured via environment variables like |
I was compiling GHC and it errored out because it could not find |
The command-line flags still seem to do nothing. Not sure why it exists. |
What's the status of this? I went to install
Is still not honored. |
They are not completely ignored; they currently only apply to local packages (i.e. locally unpacked ones e.g.) but not to non-local ones; you'd also notice this if you ran
and the top-level properties in if you want something to apply to non-local packages you have to declare it in a
it'd apply to all packages, local and non-local; but due to the Nix-style configuration tracking approach, this would also force every package to be recompiled, even if that include/lib-path would made no difference whatsoever to a package which doesn't even depend on hsopenssl. Hence the recommendation is to write specific
as that would require only the least amount of cache-misses & recompilation, and redundant entries in your nix-style store. However, I need to investigate what the situation is re having globally configured settings in |
@hvr This came up while installing |
The problem is that When Yet. I invite anyone to look up in how the command line interface is built. It's somewhat tricky to see what options are there, and almost impossible in how they are wired up. :) |
To clarify previous a bit: I'm afraid there is no active cabal contributors who understand how parsing of I'll get to that eventually, but I'm simply postponing that because I'm afraid I'll lose productivity for a month or two trying to understand and (as my gut feeling says) try to untangle that code. If no-one championed these issues for past 5 years, I don't think they are urgent. |
I'd be worth articulating why exactly; For one, ...but then we have So in the outside-a-project case of a
it's clearly understandable you'd want a way to inject some |
Thanks @jneira. I had not tried |
That is hard problem and ux is suffering from it. The cause imo is nobody agree about what should be the "default" behaviour when you dont specify any scope. That includes raw cli arguments and cabal.project top level fields. Some people thinks it should be applied to all packages and other ones will be surprised if they are applied to dependencies, depending of their use case at hand. Otoh nobody wants to set explicitly everywhere the scope and remove non scoped arguments will break all the ecosystem really hard. 🤷 |
I say the default for the cli arguments should be "this package and whatever packages get built as dependencies for it".
|
@mouse07410 nice, i think it matches what are we discussing here: #7297 (comment) |
Do I understand this correctly? If I try to build zlib for my project like this
The option actually has no effect, and that's intended behavior? |
well it is somewhat specified in docs: https://cabal.readthedocs.io/en/stable/cabal-project.html#package-configuration-options
afaiu cli args are equivalent to top level options and maybe it should be stressed in docs |
Well this is the error message I get:
So it's suggesting a flag that doesn't work. |
@asivitz ugh, thanks for pointing it out, the error message should be ammended too, replacing the suggestion with another one which works generically or noting flags will only work for local packages |
Yea, I'm actually not sure what I can do here. Do I pass --ghc-options="-L/some/path"? That doesn't work for me, but I could be hitting another problem. I'm all mixed up b/c this also involves Nix, and something is being very stubborn about finding this library. But it's hard to debug b/c all of Nix, Cabal, and GHC seem potentially resistant to accepting new library paths. It seems to be passed along, but then when it finally reaches the CC call, it's dropped. |
Does not the workaround mentioned in the issue first comment work for you?
|
The main reason I can't go that route is that I'm trying to get a configuration that will work across multiple environments. So I wouldn't want to embed that configuration into something I'd check into source control. And also, the actual lib is dynamically created (through Nix). So, a command line argument is really what I need here, as opposed to a config value. (I guess I could dynamically generate the project file, but, I really don't want to do that.) I'm currently trying a different approach in Nix. Although it seems like I should be able to do this, somehow, maybe I can avoid the problem entirely. |
You can add that configuration to cabal.project.local and hence not place it in what is put it in source control, fwiw. I can't think of a good way to specify this in command line options. We would need a full design to have subpackage options stanzas specifiable on the command line, which feels pretty awkward compared to creating a file. |
or maybe we could play with the explicit target, the counterintuitive thing arise when you do a |
That would certainly address my use case. It makes intuitive sense to me as well |
Trying to summarise:
While in a project, both
This all I know and can understand, please correct me if I made mistakes or missed something important. |
Currently, there are three kinds of cabal configurations considered when determining an option of an `ElaboratedConfiguredPackage`: * Global configuration, in `.cabal/config` * Local configuration, in - Options passed in the cabal invocation, e.g. `cabal build --enable-executable-dynamic` - Fields in the top level `cabal.project`, or `cabal.project.local`, e.g. `extra-include-dirs: /opt/homebrew/include` Note thus that top-level cabal.project flags and cli flags are treated all together at the same level (`local`). * Per package configuration, as in package HsOpenSSL extra-include-dirs: /opt/homebrew/Cellar/openssl@3/3.2.0_1/include extra-lib-dirs: /opt/homebrew/Cellar/openssl@3/3.2.0_1/lib Then, we have a definition for whether a package is local to the project. The local packages are the packages listed in the project which have a specific source package, rather than just being listed by name in a `source-repository-stanza`, or in a `package <package-name>` stanza that configures installed packages. In this patch, we try fix the mistmatch between the `local` flags and the packages which are deemed `local`, and define a specification for what exactly should happen..... TODO Fixes haskell#7297, haskell#8909, haskell#2997
Currently, there are three kinds of cabal configurations considered when determining an option of an `ElaboratedConfiguredPackage`: * Global configuration, in `.cabal/config` * Local configuration, in - Options passed in the cabal invocation, e.g. `cabal build --enable-executable-dynamic` - Fields in the top level `cabal.project`, or `cabal.project.local`, e.g. `extra-include-dirs: /opt/homebrew/include` Note thus that top-level cabal.project flags and cli flags are treated all together at the same level (`local`). * Per package configuration, as in package HsOpenSSL extra-include-dirs: /opt/homebrew/Cellar/openssl@3/3.2.0_1/include extra-lib-dirs: /opt/homebrew/Cellar/openssl@3/3.2.0_1/lib Then, we have a definition for whether a package is local to the project. The local packages are the packages listed in the project which have a specific source package, rather than just being listed by name in a `source-repository-stanza`, or in a `package <package-name>` stanza that configures installed packages. The reason why local packages being installed are treated as non-local is that TODO In this patch, we try fix the mistmatch between the `local` flags and the packages which are deemed `local`, and define a specification for what exactly should happen..... TODO Fixes haskell#7297, haskell#8909, haskell#2997
I investigated and discussed this issue in yesterday's Cabal dev meeting. As has been noted in this ticket's discussion, and summarised by @andreabedini and the commit message of 652a77c (this is a commit that took the wrong approach, but describes what packages do each flags apply to), flags given in the command line to However, local flags do not apply to non-local packages (such as those pulled from hackage and installed in the store). Therefore, specifying To apply flags to a package you depend on, such as package HsOpenSSL
extra-lib-dirs: ...
extra-include-dirs: ... or e.g. using an In the meeting we agreed that, ultimately, the behaviour of local flags applying to local packages only is the correct one, and that we shouldn't change that behaviour. Instead, we agree the solution to this ticket is to improve documentation and be very clear in cabal configure/build about the scope of configuration flags, add explicit examples of these use cases such as configuring the extra-lib-dirs of a specific package, and perhaps even add a small note to the documentation of |
I tried compiling
hackage-server
withnew-build
, andhackage-server
relies ontext-icu
, which in my case is installed in the brewCellar
and hence needs additional lib and include paths. However, doinghad no effect, nor had setting the
extra-include-dirs
andextra-lib-dirs
flags in the global section of thecabal.project
file. This worked though:(which arguably is the most logical way to configure this anyway, so perhaps this is merely a matter of warning the user that global lib/include flags are not taken into account for subpackages?).
The text was updated successfully, but these errors were encountered: