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

[BUG] git+ssh errors in npm8 #5289

Closed
2 tasks done
grahamrhay opened this issue Aug 10, 2022 · 3 comments
Closed
2 tasks done

[BUG] git+ssh errors in npm8 #5289

grahamrhay opened this issue Aug 10, 2022 · 3 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@grahamrhay
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

We have a number of node14 projects that we are in the process of upgrading to 16 (and if we aren't careful, the LTS train will have moved on before we get there!).

Can anyone explain what has changed in npm 8(?), that could cause git+ssh dependencies to fail? I have a (fairly) minimal repro here, but almost no theory as to what could cause it. I don't know if it is related to docker, or npm, or some combination of the two.

The main branch builds fine:

$ make build
Building the image...
DOCKER_BUILDKIT=1 docker build --ssh default -t npm-chown .
[+] Building 2.2s (14/14) FINISHED                                                                                                                                                            
 => [internal] load build definition from Dockerfile                                                                                                                                     0.0s
 => => transferring dockerfile: 450B                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                          0.0s
 => resolve image config for docker.io/docker/dockerfile:experimental                                                                                                                    1.0s
 => CACHED docker-image://docker.io/docker/dockerfile:experimental@sha256:600e5c62eedff338b3f7a0850beb7c05866e0ef27b2d2e8c02aa468e78496ff5                                               0.0s
 => [internal] load metadata for docker.io/library/node:14-alpine                                                                                                                        1.0s
 => [internal] load build context                                                                                                                                                        0.0s
 => => transferring context: 69B                                                                                                                                                         0.0s
 => [1/7] FROM docker.io/library/node:14-alpine@sha256:e22ee6a906e823dc592d6022a3f520676575b50320fe2c3916c88acb16f471ce                                                                  0.0s
 => CACHED [2/7] RUN apk --no-cache --virtual build-dependencies add     make     g++     git     openssh                                                                                0.0s
 => CACHED [3/7] RUN mkdir -p /root/.ssh &&     chmod 0700 /root/.ssh &&     ssh-keyscan github.com >> /root/.ssh/known_hosts                                                            0.0s
 => CACHED [4/7] WORKDIR /app/                                                                                                                                                           0.0s
 => CACHED [5/7] RUN chown -R node $PWD                                                                                                                                                  0.0s
 => CACHED [6/7] ADD ./service/package.json .                                                                                                                                            0.0s
 => CACHED [7/7] RUN --mount=type=ssh npm i                                                                                                                                              0.0s
 => exporting to image                                                                                                                                                                   0.0s
 => => exporting layers                                                                                                                                                                  0.0s
 => => writing image sha256:fa984c52481af4a483017351da9902eb627eccdfc2f837ead12a73812b1bf14d                                                                                             0.0s
 => => naming to docker.io/library/npm-chown   

but the other two branches fail like this:

$ make build
Building the image...
DOCKER_BUILDKIT=1 docker build --ssh default -t npm-chown .
[+] Building 11.3s (14/14) FINISHED                                                                                                                                                           
 => [internal] load build definition from Dockerfile                                                                                                                                     0.0s
 => => transferring dockerfile: 467B                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                          0.0s
 => resolve image config for docker.io/docker/dockerfile:experimental                                                                                                                    0.8s
 => CACHED docker-image://docker.io/docker/dockerfile:experimental@sha256:600e5c62eedff338b3f7a0850beb7c05866e0ef27b2d2e8c02aa468e78496ff5                                               0.0s
 => [internal] load metadata for docker.io/library/node:14-alpine                                                                                                                        0.7s
 => [1/8] FROM docker.io/library/node:14-alpine@sha256:e22ee6a906e823dc592d6022a3f520676575b50320fe2c3916c88acb16f471ce                                                                  0.0s
 => [internal] load build context                                                                                                                                                        0.0s
 => => transferring context: 69B                                                                                                                                                         0.0s
 => CACHED [2/8] RUN apk --no-cache --virtual build-dependencies add     make     g++     git     openssh                                                                                0.0s
 => CACHED [3/8] RUN mkdir -p /root/.ssh &&     chmod 0700 /root/.ssh &&     ssh-keyscan github.com >> /root/.ssh/known_hosts                                                            0.0s
 => CACHED [4/8] WORKDIR /app/                                                                                                                                                           0.0s
 => CACHED [5/8] RUN chown -R node $PWD                                                                                                                                                  0.0s
 => CACHED [6/8] ADD ./service/package.json .                                                                                                                                            0.0s
 => [7/8] RUN npm i -g npm                                                                                                                                                               7.2s
 => ERROR [8/8] RUN --mount=type=ssh npm i                                                                                                                                               2.3s
------                                                                                                                                                                                        
 > [8/8] RUN --mount=type=ssh npm i:                                                                                                                                                          
#14 2.263 npm ERR! code 128                                                                                                                                                                   
#14 2.266 npm ERR! An unknown git error occurred
#14 2.267 npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/jashkenas/underscore.git
#14 2.267 npm ERR! Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
#14 2.267 npm ERR! git@github.com: Permission denied (publickey).
#14 2.267 npm ERR! fatal: Could not read from remote repository.
#14 2.267 npm ERR! 
#14 2.267 npm ERR! Please make sure you have the correct access rights
#14 2.267 npm ERR! and the repository exists.
#14 2.269 
#14 2.270 npm ERR! A complete log of this run can be found in:
#14 2.270 npm ERR!     /root/.npm/_logs/2022-08-09T11_50_52_370Z-debug-0.log
------
executor failed running [/bin/sh -c npm i]: exit code: 128
make: *** [Makefile:7: build] Error 1

I have a workaround, to move the chown after npm i, but that takes my build time from ~1 min to ~12 mins. which isn't ideal.

Expected Behavior

I would expect it to work the same as npm6

Steps To Reproduce

see above

Environment

see above

@grahamrhay grahamrhay added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Aug 10, 2022
@grahamrhay
Copy link
Author

could it be related to this?

@wraithgar
Copy link
Member

Duplicate of #5278

@wraithgar wraithgar marked this as a duplicate of #5278 Aug 10, 2022
@grahamrhay
Copy link
Author

that's not the same error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

2 participants