Skip to content

Last alpine image breaks npm install with git+ssh #1378

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

Closed
damiankoper opened this issue Oct 23, 2020 · 6 comments
Closed

Last alpine image breaks npm install with git+ssh #1378

damiankoper opened this issue Oct 23, 2020 · 6 comments
Labels

Comments

@damiankoper
Copy link

It looks like NPMv7 npm install wants to use bash, which is not present in alpine image. NPMv6 works fine on lts-alpine.
DIGEST: sha256:97204ef250fa90f8177084ef6d7641ede6d48c4c8acfb30faf3580bee5c59c0b

Is it NPM problem or with some settings connected with latest image?

Log:

npm WARN tarball tarball data for XXX@git+ssh://[email protected]/XXX/XXX.git#hash (null) seems to be corrupted. Trying again.
npm WARN tarball tarball data for XXX@git+ssh://[email protected]/XXX/XXX.git#hash (null) seems to be corrupted. Trying again.
npm notice 
npm notice New patch version of npm available! 7.0.2 -> 7.0.3
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.3>
npm notice Run `npm install -g [email protected]` to update!
npm notice 
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path bash
npm ERR! errno -2
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 
@SimenB
Copy link
Member

SimenB commented Oct 23, 2020

I don't know what package you're trying to install - I'm assuming it is due to some pre-built binary not being available, so it attempts to build from source, which requires bash. Hard to tell without more details, however.

I don't think it's a bug in this image or in npm. I might be wrong though. You should take a look at the logfile after the failure.

@damiankoper
Copy link
Author

It looks like NPMv7 issue:
npm/cli#2008
npm/cli#2022
So this issue can be closed.

@damiankoper
Copy link
Author

It turns out that NPMv7 respects shell config option and NPMv6 does not (in this case).

NPMv6:

damian_koper@X:~/Desktop/npm-test $ docker run -it node:lts-alpine sh
/ # npm -v
6.14.8
/ # npm config ls -l | grep shell
script-shell = null
shell = "bash"
/ # apk add git
OK: 23 MiB in 22 packages
/ # npm i github:damiankoper/piw.git # random repo
# WORKS

NPMv7:

damian_koper@X:~/Desktop/npm-test $ docker run -it node:alpine sh
/ # npm -v
7.0.3
/ # npm config ls -l | grep shell
script-shell = null 
shell = "bash" 
/ # apk add git
OK: 23 MiB in 22 packages
/ # npm i github:damiankoper/piw.git # random repo
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path bash
npm ERR! errno -2
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Solution for NPMv7:

/app # npm config set shell sh # Should this be added to alpine Dockerfile with NPMv7?
validBefore? true
/ # npm i github:damiankoper/piw.git # random repo
WORKS

@SimenB
Copy link
Member

SimenB commented Oct 25, 2020

so npm defaults to bash? They should probably default to. sh as that's more portable. We can probably set that config option, tho.

@Tchoupinax
Copy link

Tchoupinax commented Nov 9, 2020

I had the same issue (installing package from git) and adding the following line in my Dockerfile fixes the issue. Thanks @damiankoper

npm config set shell sh

Edit: answer to the next comment, yes v15.1.0 solve the issue ^^

@nschonni
Copy link
Member

nschonni commented Nov 9, 2020

Default shell was fixed in NPM and included in the 15.1.0 images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants