docker-node icon indicating copy to clipboard operation
docker-node copied to clipboard

`yarn` not found in `node:alpine`

Open beldur opened this issue 8 years ago • 71 comments

I'm using the node:alpine image in a gitlab-ci build. Since a few minutes ago I get the following error in gitlab-ci:

$ yarn config set cache-folder .yarn
/bin/sh: eval: line 50: yarn: not found
ERROR: Job failed: exit code 127

My .gitlab-ci.yaml:

build:
  image: node:alpine
  stage: build
  script:
    - yarn config set cache-folder .yarn
    - yarn
    - yarn build

beldur avatar Mar 16 '18 11:03 beldur

I'm seeing the same in circleci

Step 6/9 : RUN yarn
 ---> Running in a8731d6619d5
/bin/sh: yarn: not found
The command '/bin/sh -c yarn' returned a non-zero code: 127

mmcgarr avatar Mar 16 '18 11:03 mmcgarr

I'm experiencing the same issue.

rtorino avatar Mar 16 '18 11:03 rtorino

Same here. Need to revert ae26d217bca933e72ac5f8de946681c1b5f8b37e.

Scukerman avatar Mar 16 '18 11:03 Scukerman

Same for the normal node:9.8.0

~ » docker run -it --rm node:9.8.0 sh  
# yarn
sh: 1: yarn: not found

thrawny avatar Mar 16 '18 11:03 thrawny

Same here with node:carbon

fabriciocolombo avatar Mar 16 '18 11:03 fabriciocolombo

This was caused by this commit: https://github.com/nodejs/docker-node/commit/ae26d217bca933e72ac5f8de946681c1b5f8b37e

Given the way the symlink is done mkdir -p /opt/yarn should have been deleted

nicolas-duvauchel avatar Mar 16 '18 11:03 nicolas-duvauchel

node:9.7-alpine image seems unaffected

mmcgarr avatar Mar 16 '18 11:03 mmcgarr

@PeterDaveHello @chorrell

SimenB avatar Mar 16 '18 11:03 SimenB

Seems to affect all supported tags except chakracore.

tredston avatar Mar 16 '18 11:03 tredston

The problem is with mkdir -p /opt/yarn (related to missing /opt directory see #648). The correct command should be mkdir -p /opt.

michalpiekarski avatar Mar 16 '18 11:03 michalpiekarski

latest is affected I think:

The link /usr/local/bin/yarn is broken, it targets /opt/yarn/bin/yarn which doesn't exist. But /opt/yarn/yarn-v1.5.1 exists.

root@5706d42db0c6:/# ls /usr/local/
CHANGELOG.md  LICENSE  README.md  bin  etc  games  include  lib  man  sbin  share  src
root@5706d42db0c6:/# ls /usr/local/bin
node  nodejs  npm  npx  yarn  yarnpkg
root@5706d42db0c6:/# /usr/local/bin/yarn
bash: /usr/local/bin/yarn: No such file or directory
root@5706d42db0c6:/# ls /usr/local/bin
node  nodejs  npm  npx  yarn  yarnpkg
root@5706d42db0c6:/# stat /usr/local/bin/yarn
  File: '/usr/local/bin/yarn' -> '/opt/yarn/bin/yarn'
  Size: 18              Blocks: 0          IO Block: 4096   symbolic link
Device: 31h/49d Inode: 62          Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-03-16 10:19:06.000000000 +0000
Modify: 2018-03-16 10:19:06.000000000 +0000
Change: 2018-03-16 11:13:53.243600600 +0000
 Birth: -
root@5706d42db0c6:/# /usr/local/bin/yarn
bash: /usr/local/bin/yarn: No such file or directory
root@5706d42db0c6:/# /usr/local/bin/n
node    nodejs  npm     npx
root@5706d42db0c6:/# /usr/local/bin/yarn
bash: /usr/local/bin/yarn: No such file or directory
root@5706d42db0c6:/# /opt/yarn/bin/yarn
bash: /opt/yarn/bin/yarn: No such file or directory
root@5706d42db0c6:/# ls /opt/yarn
yarn-v1.5.1
root@5706d42db0c6:/# ls /opt/yarn/yarn-v1.5.1
LICENSE  README.md  bin  lib  package.json
root@5706d42db0c6:/# ls /opt/yarn/yarn-v1.5.1

cecton avatar Mar 16 '18 11:03 cecton

Broke our CI as well this morning!

lingz avatar Mar 16 '18 11:03 lingz

Should #639, #647 and #648 all be reverted, or can someone send a new PR fixing it?

SimenB avatar Mar 16 '18 11:03 SimenB

Same here, with every version of node. We've already tried carbon and latest. Both fail with the yarn command.

elboletaire avatar Mar 16 '18 11:03 elboletaire

This affects 9.8.0, 9.8, 9, latest, 8.10.0, 8.10, 8, carbon, 6.13.1, 6.13, 6, boron, 4.8.7, 4.8, 4, argon and all variants (alpine, slim, onbuild, wheezy, stretch)

SimenB avatar Mar 16 '18 11:03 SimenB

@SimenB I volunteer to make a PR. I will remove the mkdir -p and replace by a symlink where the yarn has been decompressed.

cecton avatar Mar 16 '18 11:03 cecton

@cecton thanks!

SimenB avatar Mar 16 '18 11:03 SimenB

I will be able to fix that in several hours. If anyone can take care of it earlier, please do.

pesho avatar Mar 16 '18 11:03 pesho

I asked for a revert in https://github.com/docker-library/official-images/pull/4131, but I think they are all on the west coast of the US, so probably asleep.

SimenB avatar Mar 16 '18 11:03 SimenB

Adding the following to my Dockerfile as a temporary fix helped. Remember YMMV! RUN mkdir -p /opt/yarn/bin && ln -s /opt/yarn/yarn-v1.5.1/bin/yarn /opt/yarn/bin/yarn

ghindle avatar Mar 16 '18 11:03 ghindle