-
Notifications
You must be signed in to change notification settings - Fork 711
docs: cabal.project search path is not documented #7930
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
Comments
Related: #7695 Yes, we need better and consistent docs for that: in code, readthedocs, commandline help, if appropriate. |
This sounds like a misfeature to me. Can we get rid of it? What motivated it in the first place? |
I guess, cabal needs context to build a package and that context is provided by a project. If that package is not part of any project, some default context is assumed. Project can be determined by files in parent directories as well as by commandline overrides. An example of the contest info is the location of some package dependencies (that, e.g., are not on Hackage at all). I guess one may ask why in such cases packages are not built by staying in the directory where the project file is. I don't know --- perhaps cabal |
It's probably clear from my original message that I also find this feature confusing. The argument for it I got from someone is that many build tools work this way today (I think |
I think the feature can be useful, though I don't use it often. Like with git, it's nice to not have to cd back to the root of the project when invoking a command in a subdirectory. What kind of confusing behaviour did you experience? |
I had a completely unrelated |
I guess, ideally I'd expect |
Ah I see... this can indeed happen if the inner project does not have a cabal.project file. |
Me too. I only have one project with subpackages (https://github.com/BNFC/bnfc/blob/master/cabal.project), but in my working directory I mostly have the
Exactly, and I think the context should be determined by the directory where cabal has been invoked. @fgaz wrote:
I can see that such behavior can be useful in situations where you work with both projects and individual files.
The "looking above" (mis?)feature has these harms:
|
A recent example: just-released Nix 2.6 has this in release notes:
|
The quoted release notes do not link to an issue or a more detailed documentation. Anyway, this would not help if I want to |
#7057 would help with that |
Yeah this could be useful. Maybe it could only do that when the project file is not in the current directory (and be clear about that, eg. "Notice: loaded a project file from an upper directory: /blah/blah") |
I think searching upward for a |
I there are really no compelling reason for this behaviour, we can certainly drop it, with some backward compatibility scheme. Simpler is better. We'd need an RFC and some time to collect feedback. |
I have been experimenting a bit more just now, and found something I had overlooked. It works well if one does everything right like:
Then I can invoke Yet I tripped quite often in the past.
|
Big plus for cabal reporting which project files are loaded. Ambivalent (slightly leaning no: it may be handy perhaps) for removing the feature. |
Let's report the project file in use and, independenly, continue discussing a possible enhancement of the functionality. Discussion should not paralyse improvements. |
I just got burned by this. It took me ~5 mins to figure out some spooky action at a distance was happening, ~20 mins to work out cabal was being affected by a parent directory, and then another hour to find a workaround. I'm using an automarker I wrote in Haskell to mark student's Haskell coursework. The student cabal projects go in a subdirectory of the automarker cabal project. In previous years, this wasn't a problem, but this time when I tried to run the student projects I was getting
I almost never write |
Does |
Also, I will note that this semantic is common for tools such as |
I saw I agree it's not entirely unprecedented behaviour and I originally suspected it was a I'm not opposed to cabal checking the parent directories, but the behaviour I expected was for it to prioritise the most local project (like git does and like cabal does if there's a |
@ratherforky thanks a lot for carefully documenting your experience. Short of changing the default behavior (which will probably be too disruptive), what would have saved you is #8519 (display within which project file we build). What do you think? Unfortunately, that feature turned out to be tricky to integrate into our humongous and over-complicated testing infrastructure (what?? yes!!) Unfortunately, --ignore-project currently doesn't work with build: #7057 |
Yeah I think that would've saved me a lot of time figuring out what the problem was. Thankfully adding a basic |
Uh oh!
There was an error while loading. Please reload this page.
My understanding is that cabal.project affects a build even if the file lives in a parent directory, not only the current directory. Maybe this is well-known, but not for me, and I've been experiencing spooky actions at a distance for a little while. The closest the docs get to is (if I'm not mistaken):
Which, if anything, suggests that the global config file and the two from the current directory affect the build. At least, having an absolute path in the first bullet point indicates to me that the rest are probably relative paths.
If you agree that it's an omission, I could supply some kind of amendment to the above text.
The text was updated successfully, but these errors were encountered: