Skip to content
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

Strange `stack setup` behaviour when `DESTDIR` is set #1460

Closed
ehamberg opened this issue Dec 2, 2015 · 6 comments
Closed

Strange `stack setup` behaviour when `DESTDIR` is set #1460

ehamberg opened this issue Dec 2, 2015 · 6 comments

Comments

@ehamberg
Copy link

@ehamberg ehamberg commented Dec 2, 2015

Calling stack setup, with DESTDIR set fails since it will end up being installed in $DESTDIR$HOME/.stack/programs/x86_64-linux/ghc-7.10.2/. This happened on a CI server that called make DESTDIR=$BUILD_DIR install and relied on the fact that the install target was calling other targets that eventually called stack setup.

Here's what happens on Debian 8.2 for a user with HOME=/var/lib/buildkite-agent:

$ rm -rf ~/.stack/
$ DESTDIR=/tmp/test stack setup
Downloaded lts-3.16 build plan.
Caching build plan
Fetched package index.
Populated index cache.
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-7.10.2.
Installed GHC.
Executable named ghc not found on path: ["/var/lib/buildkite-agent/.stack/programs/x86_64-linux/ghc-7.10.2/bin","/usr/local/bin","/usr/bin","/bin","/usr/local/games","/usr/games"]
$ ls var/lib/buildkite-agent/.stack/programs/x86_64-linux/ghc-7.10.2/
bin  lib  share

Note that the install ends up in $DESTDIR$HOME which here is /tmp/test/var/lib/buildkite-agent.

(This was solved by changing the build to be make && make DESTDIR=$BUILD_DIR install so that DESTDIR is only set for the install target.)

@ehamberg
Copy link
Author

@ehamberg ehamberg commented Dec 2, 2015

To clarify: Even if stack setup is meant to honour DESTDIR (is it?), it looks like the files end up being installed into $DESTDIR$HOME, which to me looks like it's definitely a bug.

@mgsloan
Copy link
Contributor

@mgsloan mgsloan commented Dec 3, 2015

I don't think stack setup is meant to honour DESTDIR, that's part of the ghc makefile. I think we should filter this from the environment when installing GHC, and possibly other env vars.

So in your particular case, during build, other makefiles get invoked which use DESTDIR? Or does cabal-install use DESTDIR (doesn't afaict).

@mgsloan mgsloan added this to the P3: Optional milestone Dec 3, 2015
@ehamberg
Copy link
Author

@ehamberg ehamberg commented Jan 19, 2016

So in your particular case, during build, other makefiles get invoked which use DESTDIR? Or does cabal-install use DESTDIR (doesn't afaict).

We specified DESTDIR ourselves when calling make from our build server. On a fresh server, where stack setup was called, this would lead to it being set for that invocation, making stack setup fail.

@borsboom borsboom modified the milestones: P2: Should, P3: Optional Jan 19, 2016
@borsboom
Copy link
Contributor

@borsboom borsboom commented Jan 19, 2016

Sounds like we should just remove DESTDIR from the environment when installing GHC.

@mgsloan
Copy link
Contributor

@mgsloan mgsloan commented Jan 19, 2016

That sounds like a good resolution to me! It should warn about unsetting the env var, incase the user is doing it intentionally.

@mgsloan
Copy link
Contributor

@mgsloan mgsloan commented May 15, 2016

Fixed! Feel free to re-open if not.

@mgsloan mgsloan closed this May 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants