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

Comments

Projects
None yet
3 participants
@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

This comment has been minimized.

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

This comment has been minimized.

Collaborator

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

This comment has been minimized.

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

This comment has been minimized.

Contributor

borsboom commented Jan 19, 2016

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

@mgsloan

This comment has been minimized.

Collaborator

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

This comment has been minimized.

Collaborator

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