Skip to content

[BUG] Failed to install npm package from git in docker since v6.11.0  #624

@doochik

Description

@doochik

What / Why

This bug is related to #476 (comment) and #514

When

npm install packages from git in docker

Where

  • packages from public git repositories

How

Current Behavior

# npm i
npm ERR! code 128
npm ERR! Command failed: git clone --depth=1 -q -b v2.0.5 git://github.com/boblauer/MockDate.git /root/.npm/_cacache/tmp/git-clone-c9699b7f
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-c9699b7f': Permission denied
npm ERR! 

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-12-23T09_49_05_990Z-debug.log

Steps to Reproduce

  • Create simple package.json with git dependency
{
  "name": "test-npm",
  "dependencies": {
    "mockdate": "git://github.com/boblauer/MockDate.git#v2.0.5"
  }
}
  • run docker run --network=host -it -v $(pwd):/var/work/test -w /var/work/test node:12.14.0 /bin/bash
  • ls -l shows that files are owned by unknown user and unknown group (this is typical behaviour on build agents like teamcity, teamcity clones git repo and mounts it inside docker container)
# ls -l
-rw-r--r-- 1 20857 115755  114 Dec 23 09:46 package.json
  • run npm install
# Depends on environment you can get

npm ERR! code 128
npm ERR! Command failed: git clone --depth=1 -q -b v2.0.5 git://github.com/boblauer/MockDate.git /root/.npm/_cacache/tmp/git-clone-c9699b7f
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-c9699b7f': Permission denied
npm ERR! 

# or

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@<private server>/admin-template.git
npm ERR! 
npm ERR! No user exists for uid 1000
npm ERR! fatal: Could not read from remote repository.
  • run npm i -g npm@6.10 (downgrade to npm 6.10.X)
  • run npm install
# all works well!

updated 1 package and audited 1 package in 1.355s
found 0 vulnerabilities

Expected Behavior

  • npm install / npm ci works well like npm@6.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions