Permission denied when running as root
Closed this issue · 2 comments
peacememories commented
We are running elm-watch in a docker container which, at least for now, is running as root.
When running elm-watch make
for the first time, it fails with the following message:
Log
🚨 Dependencies
-- UNEXPECTED ELM OUTPUT -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/srv/service/elm.json
I tried to make sure all packages are installed by running the following commands:
cd /srv/service
elm make --output=/dev/null /tmp/ElmWatchDummy.elm
I expected it to either exit 0 with no output (success),
or exit 1 with an error I can recognize (using regex) on stderr.
But it exited like this:
exit 1
elm: /root/.elm/0.19.1/packages: createDirectory: permission denied (Permission denied)
-- ERROR -----------------------------------------------------------------------
I ran into something that bypassed the normal error reporting process! I
extracted whatever information I could from the internal error:
> thread blocked indefinitely in an MVar operation
These errors are usually pretty confusing, so start by asking around on one of
forums listed at https://elm-lang.org/community to see if anyone can get you
unstuck quickly.
-- REQUEST ---------------------------------------------------------------------
If you are feeling up to it, please try to get your code down to the smallest
version that still triggers this message. Ideally in a single Main.elm and
elm.json file.
From there open a NEW issue at https://github.com/elm/compiler/issues with your
reduced example pasted in directly. (Not a link to a repo or gist!) Do not worry
about if someone else saw something similar. More examples is better!
This kind of error is usually tied up in larger architectural choices that are
hard to change, so even when we have a couple good examples, it can take some
time to resolve in a solid way.elm: thread blocked indefinitely in an MVar operation
The same happens when we set ELM_HOME
to a temporary directory in /tmp
Details
elm make <file>
works fine and createselm-stuff
, after which elm-watch also works- The working directory is not owned by root, but by a user mapped to the host user (this is necessary since we mount our source directory into the container)
chown
ing the temporary elm-home to the same user causes elm-watch to work
It seems to me that elm-watch has logic that depends on the owner of the working directory, or that triggers when it is run as root, and then tries to run elm with the same user?
peacememories commented
Hmm nevermind, this seems to also happen with elm make <file>
, so I'm guessing this is a problem with elm itself
peacememories commented
Ohhh... this is an npm thing. Running a script with npx
(or npm run
) sets the user to the owner of the working directory. Welp, today I learned