commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.98k stars 843 forks source link

Set $ACLOCAL_PATH in `stack exec` appropriately #3501

Open sgraf812 opened 6 years ago

sgraf812 commented 6 years ago

As I found out in this Phabricator thread, stack exec [--no-ghc-package-path] bash doesn't set $ACLOCAL_PATH. I'm not sure why this is. When starting a regular mingw64 session or Git Bash (even stack exec mintty and choosing mingw64), the paths are set correctly.

Steps to reproduce

  1. stack exec bash on a Windows machine (AFAICT any stack config will do)
  2. Realise that ehco $ACLOCAL_PATH is empty
$ stack --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e x86_64 hpack-0.17.1
mgsloan commented 6 years ago

Curious! What version of stack are you on? Perhaps try a newer one? That flag is literally only used in this one spot: https://github.com/commercialhaskell/stack/blob/master/src/Stack/Setup.hs#L304

Note that there is no mention of ACLOCAL_PATH in the entirety of stack.

As you can see, it just disables inserting into the environment map. So, no idea why that would be. Unfortunately, I do not have straightforward access to a windows environment with stack. Hopefully a windows user can dig into the code and work out what's going on, put up a fix. Maybe that person can be you! Contributions appreciated!

sgraf812 commented 6 years ago

I updated the issue with the version I used. Is the place you mentioned the only one where stack exec prepares the environment in which to execute its command?

Note that my first sentence was a bit misleading: This issue seems to be independent of passing --no-ghc-package-path or not.

After a little digging, it seems that /etc/profile doesn't seem to be sourced for stack exec. echo $MSYS2_PATH has a value in e.g. Git Bash but not in stack exec.

mgsloan commented 6 years ago

Ohh, I misread. Ok, yeah, that probably has something to do with the mingw setup or something like that. Guessing that git bash is probably using a different mingw than the one installed by stack. I'm not sure really how that part of things works.