Open W4RH4WK opened 8 years ago
I have a similar problem under Docker. But creating the folder doesn't help to solve it:
Dockerfile:
FROM heroku/cedar
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 575159689BEFB442 \
&& echo 'deb http://download.fpcomplete.com/debian jessie main'| tee /etc/apt/sources.list.d/fpco.list \
&& apt-get update && apt-get install stack -y
RUN stack setup --allow-different-user --compiler ghc-7.10.3
RUN apt-get install nodejs -y \
&& ln -s /usr/bin/nodejs /usr/bin/node
USER root
RUN echo "allow-different-user: true" > stack.yaml \
&& echo "compiler: ghcjs-0.2.0.20160414_ghc-7.10.3" >> stack.yaml \
&& echo "resolver: lts-6.0 " >> stack.yaml \
&& echo "compiler-check: match-exact" >> stack.yaml \
&& echo "setup-info:" >> stack.yaml \
&& echo " ghcjs:" >> stack.yaml \
&& echo " source:" >> stack.yaml \
&& echo " ghcjs-0.2.0.20160414_ghc-7.10.3:" >> stack.yaml \
&& echo " url: https://s3.amazonaws.com/ghcjs/ghcjs-0.2.0.20160414_ghc-7.10.3.tar.gz" >> stack.yaml \
&& echo " sha1: 6d6f307503be9e94e0c96ef1308c7cf224d06be3" >> stack.yaml \
&& cat stack.yaml \
&& mkdir -p /root/.stack/programs/x86_64-linux/ghcjs-0.2.0.20160414_ghc-7.10.3/src \
&& stack setup --allow-different-user --compiler ghcjs-0.2.0.20160414_ghc-7.10.3
error:
.....
ghcjs-0.2.0.20160414_ghc-7.10.3: 10.82 MiB downloaded...
ghcjs-0.2.0.20160414_ghc-7.10.3: 10.91 MiB downloaded...
ghcjs-0.2.0.20160414_ghc-7.10.3: 11.02 MiB downloaded...
ghcjs-0.2.0.20160414_ghc-7.10.3: 11.09 MiB downloaded...
ghcjs-0.2.0.20160414_ghc-7.10.3: 11.13 MiB downloaded...
Downloaded ghcjs-0.2.0.20160414_ghc-7.10.3.
Unpacking GHCJS into /root/.stack/programs/x86_64-linux/ghcjs-0.2.0.20160414_ghc-7.10.3/src/ ...
Setting up GHCJS build environment
You are not the owner of '/root/.stack/programs/x86_64-linux/ghcjs-0.2.0.20160414_ghc-7.10.3/src/'. Aborting to protect file permissions.
Retry with '--allow-different-user' to disable this precaution.
....
I've just run into this issue too, though it seems to be worse now. stack setup
seemingly changes the permissions on the fly and then fails because of it. --allow-different-user
has no effect:
root@e39d656bbcbe:/pact# stack setup
Downloaded lts-6.19 build plan.
Fetched package index.
Populated index cache.
Preparing to install GHCJS to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghcjs-0.2.0.9006019_ghc-7.10.3.
Setting up GHCJS build environmentYou are not the owner of '/root/.stack/programs/x86_64-linux/ghcjs-0.2.0.9006019_ghc-7.10.3/src/'. Aborting to protect file permissions.
Retry with '--allow-different-user' to disable this precaution.
root@e39d656bbcbe:/pact# ls -lart /root/.stack/programs/x86_64-linux/ghcjs-0.2.0.9006019_ghc-7.10.3/src/
total 84
drwxr-xr-x 2 1000 1000 4096 Sep 28 08:56 utils
drwxr-xr-x 2 1000 1000 4096 Sep 28 08:56 test
drwxr-xr-x 2 1000 1000 4096 Sep 28 08:56 src-bin
drwxr-xr-x 4 1000 1000 4096 Sep 28 08:56 src
drwxr-xr-x 7 1000 1000 4096 Sep 28 08:56 lib
drwxr-xr-x 3 1000 1000 4096 Sep 28 08:56 include
drwxr-xr-x 2 1000 1000 4096 Sep 28 08:56 doc
drwxr-xr-x 2 1000 1000 4096 Sep 28 08:56 cbits
-rw-r--r-- 1 1000 1000 10047 Sep 28 08:56 Setup.hs
-rw-r--r-- 1 1000 1000 6309 Sep 28 08:56 README.markdown
-rw-r--r-- 1 1000 1000 1098 Sep 28 08:56 LICENSE
drwxr-xr-x 10 1000 1000 4096 Sep 28 08:56 .
-rw-r--r-- 1 1000 1000 37 Sep 28 10:21 stack.yaml
-rw-r--r-- 1 1000 1000 13744 Sep 28 10:21 ghcjs.cabal
drwxr-xr-x 4 root root 4096 Oct 20 19:13 ..
root@e39d656bbcbe:/pact# chown -R root:root /root/.stack/programs/x86_64-linux/ghcjs-0.2.0.9006019_ghc-7.10.3/src/
root@e39d656bbcbe:/pact# ls -lart /root/.stack/programs/x86_64-linux/ghcjs-0.2.0.9006019_ghc-7.10.3/src/
total 84
drwxr-xr-x 2 root root 4096 Sep 28 08:56 utils
drwxr-xr-x 2 root root 4096 Sep 28 08:56 test
drwxr-xr-x 2 root root 4096 Sep 28 08:56 src-bin
drwxr-xr-x 4 root root 4096 Sep 28 08:56 src
drwxr-xr-x 7 root root 4096 Sep 28 08:56 lib
drwxr-xr-x 3 root root 4096 Sep 28 08:56 include
drwxr-xr-x 2 root root 4096 Sep 28 08:56 doc
drwxr-xr-x 2 root root 4096 Sep 28 08:56 cbits
-rw-r--r-- 1 root root 10047 Sep 28 08:56 Setup.hs
-rw-r--r-- 1 root root 6309 Sep 28 08:56 README.markdown
-rw-r--r-- 1 root root 1098 Sep 28 08:56 LICENSE
drwxr-xr-x 10 root root 4096 Sep 28 08:56 .
-rw-r--r-- 1 root root 37 Sep 28 10:21 stack.yaml
-rw-r--r-- 1 root root 13744 Sep 28 10:21 ghcjs.cabal
drwxr-xr-x 4 root root 4096 Oct 20 19:13 ..
root@e39d656bbcbe:/pact# stack setup
Preparing to install GHCJS to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.
Setting up GHCJS build environmentYou are not the owner of '/root/.stack/programs/x86_64-linux/ghcjs-0.2.0.9006019_ghc-7.10.3/src/'. Aborting to protect file permissions.
Retry with '--allow-different-user' to disable this precaution.
root@e39d656bbcbe:/pact# ls -lart /root/.stack/programs/x86_64-linux/ghcjs-0.2.0.9006019_ghc-7.10.3/src/
total 84
drwxr-xr-x 2 1000 1000 4096 Sep 28 08:56 utils
drwxr-xr-x 2 1000 1000 4096 Sep 28 08:56 test
drwxr-xr-x 2 1000 1000 4096 Sep 28 08:56 src-bin
drwxr-xr-x 4 1000 1000 4096 Sep 28 08:56 src
drwxr-xr-x 7 1000 1000 4096 Sep 28 08:56 lib
drwxr-xr-x 3 1000 1000 4096 Sep 28 08:56 include
drwxr-xr-x 2 1000 1000 4096 Sep 28 08:56 doc
drwxr-xr-x 2 1000 1000 4096 Sep 28 08:56 cbits
-rw-r--r-- 1 1000 1000 10047 Sep 28 08:56 Setup.hs
-rw-r--r-- 1 1000 1000 6309 Sep 28 08:56 README.markdown
-rw-r--r-- 1 1000 1000 1098 Sep 28 08:56 LICENSE
drwxr-xr-x 10 1000 1000 4096 Sep 28 08:56 .
-rw-r--r-- 1 1000 1000 37 Sep 28 10:21 stack.yaml
-rw-r--r-- 1 1000 1000 13744 Sep 28 10:21 ghcjs.cabal
drwxr-xr-x 4 root root 4096 Oct 20 19:14 ..
root@e39d656bbcbe:/pact#
Here's the dockerfile and relevant stack.yaml
:
FROM ubuntu:16.04
MAINTAINER Will <will@kadena.io>
RUN apt-get -y update && apt-get -y upgrade
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 575159689BEFB442 && \
echo 'deb http://download.fpcomplete.com/ubuntu xenial main' >> /etc/apt/sources.list.d/fpco.list && \
apt-get -y update && \
apt-get install -y libtool pkg-config build-essential autoconf automake rlwrap htop tmux libevent-dev libncurses-dev stack wget curl npm
RUN cd && mkdir .stack
COPY ./stack.yaml /pact/stack.yaml
COPY ./pact.cabal /pact/pact.cabal
CMD ["/bin/bash"]
resolver: lts-6.19
# GHCJS build
compiler: ghcjs-0.2.0.9006019_ghc-7.10.3
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.0.9006019_ghc-7.10.3:
url: http://ghcjs.tolysz.org/lts-6.19-9006019.tar.gz
sha1: ef4264d5a93b269ee4ec8f9d5139da030331d65a
Workaround: TAR_OPTIONS=--no-same-owner stack setup
@dplusic That's good to know, thanks! Makes sense to me to have stack just always pass in that flag.
Still exists in 2020 and I don't understand why stack would care about the permissions.
If anyone is experiencing this issue when trying to run stack in a GitHub Action, you can work around it by manually setting the file ownership to the running user. Just add this step before running stack:
- name: Permissions bug workaround
run: "chown -R $(id -un):$(id -gn) ~"
@
If anyone is experiencing this issue when trying to run stack in a GitHub Action, you can work around it by manually setting the file ownership to the running user. Just add this step before running stack:
- name: Permissions bug workaround run: "chown -R $(id -un):$(id -gn) ~"
I don't get that same problem using docker-compose builds :( This has to do on how the docker container is run by github actions... that really sucks ... I'm back to using docker-compose
Workaround:
TAR_OPTIONS=--no-same-owner stack setup
This doesn't work (anymore?).
@hasufell, can you provide any more information about what you are experiencing? There is this code in Stack.Config.loadConfig
(extract):
unless config.allowDifferentUser $ do
unless userOwnsStackRoot $
throwM (UserDoesn'tOwnDirectory stackRoot)
but that is behind the unless config.allowDifferentUser
test.
EDIT: There is also a distinct error Won'tCreateStackRootInDirectoryOwnedByDifferentUser
, but that has a different text to the error reported by the original poster in 2016.
Looking at its code, Stack can be configured (the default is otherwise) to use a Stack root 'owned' by another user, but it cannot currently create a Stack root on a absolute path where the user does not 'own' any directory on that path.
None of this applies on Windows, and I don't know enough about Unix-like operating systems to know if that is a prudent approach.
Some history: https://github.com/commercialhaskell/stack/issues/471
Here's a recent example of this, in a Github linux workflow. https://github.com/simonmichael/hledger/actions/runs/8730436402/job/23954254751
I should clarify: stack is doing the right thing in my example ("Preventing creation of Stack root '/github/home/.stack/"), but it's another way to trigger this error message in a Github workflow (when using a container, there is confusion about the HOME path. For more info, see https://github.com/actions/runner/issues/1146, https://github.com/actions/runner/issues/863. Worked around with https://github.com/actions/runner/issues/863#issuecomment-1027721398 and stack's --allow-different-user
flag).
I just encountered an issue where stack complains (and exists with !=0) when it wants to create a stack-root in a location owned by another user. This would be fine in general but even happens when the
--allow-different-user
flag is provided. Of course the user executing stack has write permissions inside that other directory.If I manually create the folder beforehand (
mkdir
) stack doesn't complain at all.