-
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
Packages are resolved w.r.t to project-file path when absolute, but not when relative #7695
Comments
I haven't looked in depth, but would this change the situation: #7581 or is it unrelated? |
I looked through the pull request discussion and it looks like it's unrelated to this. |
OK, I'm puzzled why it doesn't work in the second case. I did a quick code dive, found |
Where relative paths are rooted is not clarified in the docs as far as i can see, and that should be fixed. I always assumed that
|
Okay, I have an idea why this is happening, and my experiments confirm this. From https://cabal.readthedocs.io/en/3.6/cabal-project.html#cmdoption-0 i see that
Note that This does not sound user friendly at all but at least it is consistent and predictable.
edit: here's a place where the documentation conflicts with this behaviour: https://cabal.readthedocs.io/en/3.6/cabal-project.html#cmdoption-builddir
|
@fgaz Yes, this is what I get
|
I can understand that this behaviour makes sense in case we are in a subdirectory of a project and do a I am not sure if the same behaviour makes sense when we explicitly pass a project-file though. |
@pranaysashank: well put. @fgaz and I think it's worth a simplification. Let me mark it so. [Edit: but it's yet clear how exactly to simplify.] |
@fgaz I am not sure it's so simple since the following works
Based on your comment it should have looked for foo in / and failed |
simple: make the project root coincide to the location of the project file
isn't cabal.project in |
@fgaz No the project is in
Note: I moved cabal.project here to |
I tried a few more combinations, and I think I got it all now:
the fact that they are different suggests that this (the behaviour on relative paths based on above discussion) is a bug |
I think it'd be nice to have the relative behavior in all cases. So if I have some constraints in a global project file, any package can immediately use them (of course |
@pranaysashank: do you have a convincing speculative use case or a real life use case? We not only need a consistent implementation and documentation of this feature (which I'd love if you could provide; even just to see if the codebase gets more complicated or simpler), but we'd need to maintain it, also after you stop using this particular feature and so lose interest in supporting it. This consideration is based on our hunch that we can slightly simplify the codebase making the absolute behaviour the only one and that the documentation would be simpler in this case. |
I ran into this issue accidentally and decided to report it in case it's a bug. I don't even depend on it working, my above comment was speculative. |
I was looking at implementing #6051 and noticed the difference between absolute and relative --project-file paths while reading the code. For my use case, the relative behavior is ideal, since I would like to store the Nix project files in a nix directory (rather than pollute the root directory). I think there are two separate things here: 1) specifying the project file(s) 2) specifying the project root (currently only inferred). I suspect that the main use case for using an absolute path with --project-file is to specify the project root. Perhaps there should be a separate command for both. |
I have opened a PR (#8454) that addresses this issue by:
Please feel free to discuss/bikeshed in the PR. |
Could I ask for help reviewing the PR fixing this issue (#8454)? Even a cursory look and a comment whether this might fix your use case (bonus points for checking out and confirming) would be very much appreciated. |
A new proposal dropped at #8454. Could you kindly voice your opinion? |
I'd just like to point out that the bug this issue discovered happens when we pass a relative path which I don't think is fixed by the merged PR |
Thank you for the clarification. Let me reopen. If cabal 3.10, when it's released, fixes this, please somebody note it down here. |
The merged pr claims that it has a behavior of |
@cydparser can you sched light on this? |
The expected behavior in this issue:
PR #8454 deprecates the use of |
There was no issue with using absolute paths in project-file. There is a bug in the behaviour of relative paths, here is the current behaviour when you pass a relative file path:
From one of the earlier comments in this discussion:
Please go through the example in the issue as that should clarify the what the actual bug is. |
Describe the bug
When a project-file is passed as an absolute path that is not in the current directory. cabal seems to be resolving the packages location relative to where the file is located. This doesn't happen if the file path is relative.
Is this a bug or correct behaviour?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Expect cabal to resolve the packages field relative to where I run cabal file or have a consistent behaviour with both relative and absolute file paths.
System information
cabal
,ghc
versions: 3.4, 8.10.4The text was updated successfully, but these errors were encountered: