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

spago installed via npm does not seem to fully install #192

Closed
bbarker opened this issue May 9, 2019 · 6 comments · Fixed by #201
Closed

spago installed via npm does not seem to fully install #192

bbarker opened this issue May 9, 2019 · 6 comments · Fixed by #201

Comments

@bbarker
Copy link
Contributor

bbarker commented May 9, 2019

brandon@c9460f72c9e4:/wd$ type -a spago
spago is /usr/local/bin/spago
brandon@c9460f72c9e4:/wd$ cat /usr/local/bin/spago
#!/usr/bin/env bash
set -e

echo "This is a stub that will be replaced on install. \
It is needed to workaround https://github.com/yarnpkg/yarn/issues/3421"

I have a container for this that reproduces the issue: 305e449d39b9a146f5bfca1f335a80cd2c2bebe0 at https://github.com/bbarker/purescript-hodgepodge, or just use master's HEAD for now.

To run the container, use psc.sh in the repo, or a modified version that has fewer mounts, though I'm not sure what the behavior will be (should be mostly fine though). To build the container, you can run build.socker.sh.

@f-f
Copy link
Member

f-f commented May 9, 2019

Thanks for the report @bbarker!

Some notes:

  1. I'd recommend downloading spago in the same way you're downloading the purs and psc-package binaries in the container, as that's much more reliable than npm
  2. I'm able to reproduce just trying to install spago on a bare node image, I'll investigate more on this:
$ docker-bash node:12
root@71c1f9e95b14:/# npm install -g spago

> spago@0.7.7 preinstall /usr/local/lib/node_modules/spago
> node ./install.js

/usr/local/bin/spago -> /usr/local/lib/node_modules/spago/spago.exe
+ spago@0.7.7
added 29 packages from 19 contributors in 4.809s
root@71c1f9e95b14:/# spago -v
This is a stub that will be replaced on install. It is needed to workaround https://github.com/yarnpkg/yarn/issues/3421
root@71c1f9e95b14:/#

@f-f
Copy link
Member

f-f commented May 9, 2019

Found it. TL;DR: you need to use --unsafe-perm as an npm option if you want to install packages as root and have them to work, or just set a user in your Dockerfile. See this medium post or this StackOverflow question for more info.

So running this command in the container works correctly: npm install -g --unsafe-perm spago

I feel this "installing npm packages as root" might be a common problem, so we should definitely add to the FAQ something along the lines of "DON'T RUN NPM AS ROOT"

@f-f f-f added document me and removed bug labels May 9, 2019
@JordanMartinez
Copy link
Contributor

JordanMartinez commented May 9, 2019 via email

@f-f
Copy link
Member

f-f commented May 9, 2019

@JordanMartinez what happens here is that Docker by default runs all commands as root (unless you specify otherwise), combined with the fact that npm installs binaries as nobody when root. See the links in my previous comment, or this issue: npm/npm#3849

The result is that installing spago with npm running as root will never work, unless --unsafe-perm is specified

@JordanMartinez
Copy link
Contributor

@f-f Gotcha. Thanks for clarifying that for me.

@f-f
Copy link
Member

f-f commented May 10, 2019

@JordanMartinez you're welcome! 🙂

@f-f f-f added this to the 0.8 milestone May 12, 2019
@f-f f-f closed this as completed in #201 May 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants