Closed jezen closed 4 years ago
Reasons to do this:
Reasons not to do this:
Changes behavior, could break scripts
It may be surprising to people that inside stack exec bash
, PWD is no longer used for figuring out the current stack project.
I'm leaning towards wontfix because STACK_YAML=
is sufficient. Maybe we can have yesod-bin recommend that approach?
@mgsloan I would have thought this change would be quite self-contained. Why would changing STACK_YAML
affect PWD?
Using the environment variable is indeed sufficient, but I'd also say it's surprising and inconsistent.
@jezen Usually if you run stack build
or any such command, it figures out from the current directory (aka pwd) what stack.yaml to use. But here, if someone were inside stack exec
, it wouldn't anymore. You'd be forced to always use the one from the exec call (unless you overrode it)
So the question I think becomes, in what cases are stack runs being nested like this? I'm not sure. I think it could end up being very surprising for STACK_YAML to be set in some cases though.
I suggest that if there are ever any cases that STACK_YAML gets set by stack exec, it should always get set by stack exec. Otherwise things aren't predictable enough. I ran into an ugly scenario like this with git's hook scripts - https://public-inbox.org/git/CAEDDsWdXQ1+UukvbfRoTPzY3Y9sOaxQ7nh+qL_Mcuy3=XKKh7w@mail.gmail.com/
I can imagine nested stack being used with stack query commands. I dunno, maybe noone's scripts would break, but it would be a behavior change.
I expect the following to use the specified
stack.yaml
, but it doesn't work:What does work is specifying the file in the environment variable, like this:
I'm guessing it should be enough to have Stack set that environment variable if the flag is used, but I don't know. Would that work?
More info: https://github.com/yesodweb/yesod/issues/1472