docker-node: yarn not executable
using :9 image.
recent changes made yarn not executable.
/usr/local/bin/yarn: Permission denied
chmod a+rwx /usr/local/lib/node_modules/yarn/bin/yarn*
chmod a+rwx /usr/local/bin/yarn*
as a workaround fixes it
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 30 (7 by maintainers)
Commits related to this issue
- fix yarn permission denied https://github.com/nodejs/docker-node/issues/661 — committed to springjk/web-dev-docker by springjk 6 years ago
- Update node version for development env * Update node image from 4.8.2 to 8.11.1 After upgrading to node:8.11.1 yarn is not executable See: https://github.com/nodejs/docker-node/issues/661 For now,... — committed to skroutz/analytics.js by kosdiamantis 6 years ago
- Update node version for development env * Update node image from 4.8.2 to 8.11.1 After upgrading to node:8.11.1 yarn is not executable See: https://github.com/nodejs/docker-node/issues/661 For now,... — committed to skroutz/analytics.js by kosdiamantis 6 years ago
- Workaround yarn/node image issue https://github.com/nodejs/docker-node/issues/661 — committed to lincolnloop/saltdash by ipmb 6 years ago
For now, a simple workaround is to make sure yarn.js is executable after the install:
I was hitting this when using
node:8.11-alpine
and installing yarn with NPM.I didn’t realise yarn was included with the base image, so I removed
npm install -g yarn
and it solved the issue.Installing yarn via npm is not recommended because they think it’s not secure enough, not because it shouldn’t work.
Also, installing it via npm makes sure we always get the latest version of yarn, instead of depending on the image’s version or the distro’s repo.
Anyway, what we have so far:
node:9.7
: worksnode:9.8
: unstablenode:9.9.0
: unstablenode:6
: worksnode:8
: unstableI understand this is no simple bug and there are simple workarounds available already, so I guess we might have to be happy with those even though yarn is getting more and more popular.
This is working for me as a work around using Docker and
node:8
image:@hjanuschka @SimenB Hey, I just ran into this problem too and I found out why. On the previous node images, the pre-installed yarn was so old (version 0.x) we had to do a
npm i -g yarn
to get the latest version.Now we already get the latest version of yarn pre-installed, so there’s no need for it anymore.
However, if we still do
npm i -g yarn
, we get thepermission denied
error. So, I guess this is still an issue, even though it’s a minor one.I can reproduce this, but not with
--no-bin-links
. Reading the bin links code it seems not ready for two links pointing to the same place (as the yarn package does): e.g. its dos2Unix function will be run two async, each stat()ing the file, then rewriting it, then rechmoding it. The “right” interleave (stat1, rewrite1, stat2 (gets bad perms), chmod1, rewrite2, rechmod2) will result in lost permissions.I’m hitting this too across projects running in CircleCI, with tags
circleci/ruby:2.5.1-node-browsers
andcircleci/node:8.11.1
. It’s intermittent. Will try the above fix for now. I’m not sure if both of these are based off the official docker-node images?@chorrell you’re right! I couldn’t always reproduce it here either.
But, if you try it on
node:9.7
, you can see it always works:docker run --rm node:9.7 sh -c 'npm i -g yarn && yarn -v'
I’ve checked the npm version on both images and they’re the same (5.6.0), so that’s not it. There’s something funky on the
node:9.8
image.@hjanuschka try removing your local image to make sure you get the latest one:
docker rmi node:latest
Then run
docker run --rm node:latest sh -c 'npm i -g yarn && node -v && yarn -v'
Edit: this is what I get:
@hjanuschka yep, just reproduced it with
node:latest
. Onnode:9.7
I don’t get the error.Alternatively, removing
npm i -g yarn
fixes it fornode:latest
.Edit: btw, just tested the
chmod +x /usr/local/bin/yarn
and that works too fornode:latest
, thanks for that 😃very strange, i could have sworn that i reproduced it on ci.
docker run --rm node:9 sh -c 'npm i -g yarn && yarn -v'
now, back home, i am unable to reproduce it, was there a faulty built in between yesterday and today?
sorry for the noise.