-
Notifications
You must be signed in to change notification settings - Fork 696
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
Add config flag to control generation of .ghc.environment files #4542
Comments
So, I've recently been working in the Python/Anaconda world, where they have scripts like |
Tbh, I have been working with Python's This ticket is primarily to help those who don't subscribe to that paradigm, and want to opt-out. |
I just spent a significant chunk of time trying to get a project to build and run tests, using stack. I build the project using both cabal master and stack, to check that it works for both. Having deleted the After re-installing everything haskell related, I eventually tracked it down to this file being silently generated, and then being picked up by other tools. At this stage I would prefer to opt in for this generation, or at least get something in the output to say that the file has been generated, so that I can know that a potential landmine has been planted. This is bound to trip up others as well, as the existence and use of this file is not well documented. |
I agree that this state of affairs is not great. @hvr, can we perhaps change this setting to be opt-in? |
Can we get stack to turn off parsing of /cc @mgsloan |
fwiw nix also breaks in some cases due to |
As per https://www.reddit.com/r/haskell/comments/8iyvoo/psa_for_cabal_22_new_users_regarding/ I think that the weight of opinion is that these files should not be auto-generated, but only by opt-in. If we add this flag as a global flag that can be in ~/.cabal/config and off by default then that would help. Then if people wanted such a config, they could run I think that would improve the situation for a whole bunch of workflows... |
@gbaz quite honestly, I'm strongly against defaulting it off, as then nobody would even use what I consider one of the biggest improvements over the old flawed user pkg-db model, since almost nobody would know about it ;-( Before changing anything, I'd rather want to know exactly what workflows we're talking about that people are having problems with, as I suspect the issues are of a different nature... Fwiw, there's already patches up at to address some of the concerns with the UI |
Either way, we should have the flag so it can be changed. Lots of people don't want it on, and at the minimum they should have the option. We can sort out where the actual weight of opinion lies regarding defaults in a broader discussion. |
To expand: my personal belief is that it is currently unexpected behavior for any new-* command to produce any changes to anything outside of dist-newstyle and the store (except for install, which obviously installs), which is what this does. So it violates least-surprise to run e.g. new-test and then suddenly find your invocation of |
Moreover, this affects more than just Ironically, despite the stated goal of having GHC commands "just work" regardless of the current working directory, in practice they have the exact opposite effect. I have to be hyper-aware of which directory I'm in before I invoke |
The opt-out flag in |
@gbaz First off, I consider the current behaviour the intuitive one; if I'm in a project, I expect all invocations to be operating in that context and not some other random pkg environment which has nothing to do with the project I'm in; so I'm definitely not confused at all that Otoh, programs which invoke ghc for you will have to stop making any assumption about the implicit package environment; same goes for programs which invoke Ryan brings up the issue of runghc; Personally I've moved to using
|
@hvr I've personally experienced many cases of users coming to me asking why their project doesn't build, only to find its because of these files that they didn't notice because they begin with Furthermore, this isn't even a particularly effective solution to the problem it's supposedly fixing, because these files can and will go stale. You have to run a cabal command anyway to update it, and who would choose to have to keep track of that in their head? It's safe to say that in my experience, this is extremely unintuitive, and that seems to be the consensus in this thread. Having this be opt-out would still leave me with virtually just as many confused newcomers asking for help. |
I honestly doubt you even understand how utterly unusable ghc would be on the shell if we did that (and also how much GHC already doesn't meet your unrealistic ideal), and how frustratingly annoying |
I don't think it's considered a high priority among most people that they be able to invoke Obviously GHC isn't only configurable on the CLI. I understand that it wouldn't be realistic to uphold this standard 100% (in fact it's quite annoying that you can't configure more of the C compiler outside the CLI). But I think it's an important principle to keep in mind, and this seems like a particularly egregious deviation. All in all, I'm willing to accept that others do consider this valuable, so you'll get no uproar from me if this goes unchanged. But it would be my preference that cabal didn't generate these files implicitly. If we don't generate them implicitly, perhaps it could be a cabal subcommand to generate them? Users very often look at help text, so having a subcommand makes them very likely to be aware of the existence of this feature. |
To be fair, there is an important semantic difference between invoking I want to make it clear that I find both features extremely useful, and I'm not advocating that either one of these be removed. On the contrary, I would like to be more explicit about which ones I'm using at a given time. Currently, the latter is quite easy to use by accident, which can have unintended consequences. Luckily, some progress is being made towards making this less likely, which is nice. As I've stated (and others have stated) before, my preference would be to go from opt-out to opt-in. But that suggestion seems to have fallen on deaf ears, so I'm not going to pursue this much further. I too would appreciate a dedicated subcommand that simply generates a |
In order for a project's generated .ghc.env file to be consistent, you need to have performed a |
OK. In that case, it would be nice if the |
How do we reach consensus from here? It seems like we've only got one testimonial in favor of opt-out, vs several in favor of opt-in. |
Indeed it is clearly possible that I too don't understand this. And I may misunderstand what either of you meant by "configurability on the commandline/of the CLI". Could we just spell things out? What input does From the top of my head I can think of
Is this list complete? Does a complete version exist (in the ghc user-guide)? I just searched for "ghc.environment" (and also just "environment") and could not find anything, yet this seems highly relevant for general reproducability. But even if the environment files are just an addition to some long list, it appears to me like most other inputs are either
and in general i'd say 1-5 are all either are explicit or change only when the user (knowingly) fiddles with stuff. An implicit, frequently changing, new input is rather different imo.
Granted both ghci behaviours are useful, this is hardly a reason to not just have two versions of ( |
This discussion is very clarifying about the different attitudes involved. I think the basic question is not about cabal per-se but rather how ghc should interact with in-path "config" files of various sorts (currently mainly environment files, but also ghci files, and in the future potentially others). Some people expect ghc to behave the same no matter what directory it is run in, and some people expect it to operate in a context-sensitive fashion. Ideally we could have a solution that satisfies everybody, and ultimately I think that solution is about ghc primarily, and only secondarily about cabal. It is really just cabal auto-generating these env files that highlights the different expectations about ghc user experience. My suggestion would be a plan and discussion regarding ghc, perhaps ultimately resulting in a ghc proposal, to clarify the principles of how the compiler interacts with various configuration files. Which is to say, if people who don't like ghc picking up env files could configure ghc to not do that, then the question of cabal generating them or not would not arise. I have a draft proposal about dot-ghc-files (https://github.com/gbaz/ghc-proposals/blob/patch-2/proposals/0000-dot-ghc-file.rst) that I did not yet submit, in part because I hadn't worked out the interactions with or relationship with env files. I can try to work up different version that takes this discussion into account, and we could proceed from there... |
I had to release I'll try to find time to write a patch and cut another release ASAP (hopefully before the end of the week). |
Since it looks like we're not getting a flag any time soon, can we get some help on the proper way to work with these files? Here's my current situation that's breaking:
What am I doing wrong, and how am I supposed to make this work with |
Sounds like Shake needs to be fixed to ignore package environments when it invokes GHC, just like the various other tools that have had to make changes for this. Personally, I see that as very frustrating. The author of every tool that invokes GHC has to be aware of the fact that they have to add the same magic lines as everyone else in order for their tool not to break with new-build. I really don't think GHC should pick these up automagically. |
OTOH tools like |
I don't want to repeat the all the lengthy stuff I and other people have already written about the reasons why forcing tons of tools to opt-out is a bad idea compared to a structured way to opt-in (the |
@phadej So my time was wasted for the benefit of liquid users? Where exactly can I send my invoice for the time invested to fix my workflow? |
@phadej That you keep repeating the "but it is useful" argument is just pissing me of. It is highly disrespectful to the users affected negatively. It is highly frustrating that the maintainership makes such a one-sided, private, authoritarian decision on whether breaking existing workflows is justified by convenience for certain users. |
There is no reason to become so hostile. I, too, think that the implicit loading of environment files is a misfeature and would prefer if I had to use some explicit Ultimately, however, the maintainers of GHC and Cabal get to make the decision (as they should), and since they seem to prefer the implicit behaviour, we should probably just accept it, and start fixing our tools. In particular, unless someone is actually motivated enough to write code to change the current behaviour, then it will eventually just become a fait accompli due to inertia. |
I dunno. I'm not a fan of the idea that GHC and Cabal should service the GHC and Cabal developers before GHC and Cabal users. |
What are you referring to? Please, if you make those kind of accusations, be explicit in what and who you address. |
I think that adding a second rule to shake that deletes the env file after the build is complete might work? I like many am waiting for the new cabal-install release including this flag, and hope it comes soon, to coincide with the pending ghc 8.6.2 bugfix release. |
@gbaz Thanks! I'd tried that earlier with main = shake shakeOptions $ do
phony "build" $ do
cmd_ "cabal new-build all"
removeFile "" [".ghc.environment*"] Posted for posterity/completeness. Hopefully it helps the next person that gets bit by this bug. |
I agree that some sort of flag is needed to control whether or not this file is used. However I would err on the For the sake of people looking for similar answers, I wrote the following function in my emacs config to help manage it: (defun remove-ghc-env-file-then (f)
(shell-command-to-string (concat "rm " (projectile-project-root) ".ghc.environment.x86_64-linux-*"))
f
) |
Not sure how helpful it is to amend to this already very long thread, but I feel that this point is not addressed here: Cabal provides the very useful flag Hence my expectation indeed is that cabal never touched files outside of |
Some people are excited about .ghc.environment files, while others are mildly annoyed. I think there's probable cause to make this configurable on cabal's end.
To this end, I suggest (modulo bikeshed) to implement a flag, e.g.
--pkg-environment-scope=LEVEL
, where LEVEL can be one ofall
(default & current behaviour, generate ghc env files with all transitive dependencies of project's (non-qualified) goals):pkg:Cabal
orlib:Cabal
orCabal:test:parser-tests
): generate ghc env files containing only the stated goal's /direct/ dependencies)-
(ornone
oroff
ordisable
?): disable generation of any ghc env filesThis flag would also be persistable via
cabal.project.(local)
.Note: Item 2. is not the short-term goal of this feature request! I've included the 2. item mostly to motivate why it makes sense to design this to be a flag that's more than merely a boolean
--{disable,enable}-package-environment-files
flag.Btw, a dual feature-request (allowing to opt-out from interpreting .ghc.environment files from GHC's side) has been filed at GHC #13753 -- however, that one will be too late for GHC 8.0.2 users.
Current status:
-
environment which inhibits the default lookup logic (see http://git.haskell.org/ghc.git/commit/8f3c149d94814e4f278b08c562f06fc257eb3c43)/cc @RyanGlScott
The text was updated successfully, but these errors were encountered: