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] "could not create leading directories" when installing globally from GitHub URL #642

Closed
richRemer opened this issue Dec 29, 2019 · 1 comment · Fixed by #673
Closed

Comments

@richRemer
Copy link

richRemer commented Dec 29, 2019

What / Why

npm: v5.8.0, v6.13.4

When I attempt to install a package from GitHub globally, I am getting a permission error: "could not create leading directories".

$ sudo -H npm install -g git+https://github.com/richRemer/pool.git
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone -q https://github.com/richRemer/pool.git /root/.npm/_cacache/tmp/git-clone-e33b6b4f
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-e33b6b4f': Permission denied
npm ERR! 

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

The relevant log bits:

12 silly fetchPackageMetaData error for git+https://github.com/richRemer/pool.git Command failed: /usr/bin/git clone -q https://github.com/richRemer/pool.git /root/.npm/_cacache/tmp/git-clone-e33b6b4f
12 silly fetchPackageMetaData fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-e33b6b4f': Permission denied
13 verbose stack Error: Command failed: /usr/bin/git clone -q https://github.com/richRemer/pool.git /root/.npm/_cacache/tmp/git-clone-e33b6b4f
13 verbose stack fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-e33b6b4f': Permission denied
13 verbose stack
13 verbose stack     at ChildProcess.exithandler (child_process.js:294:12)
13 verbose stack     at ChildProcess.emit (events.js:189:13)
13 verbose stack     at maybeClose (internal/child_process.js:970:16)
13 verbose stack     at Socket.stream.socket.on (internal/child_process.js:389:11)
13 verbose stack     at Socket.emit (events.js:189:13)
13 verbose stack     at Pipe._handle.close (net.js:600:12)
14 verbose cwd /home/rremer
15 verbose Linux 5.3.0-24-generic
16 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "git+https://github.com/richRemer/pool.git"
17 verbose node v10.15.2
18 verbose npm  v5.8.0
19 error code 128
20 error Command failed: /usr/bin/git clone -q https://github.com/richRemer/pool.git /root/.npm/_cacache/tmp/git-clone-e33b6b4f
20 error fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-e33b6b4f': Permission denied
21 verbose exit [ 1, true ]

When

  • happens when using "... install -g git+https://..."
  • happens with all repos, public or private, but ultimately I'm trying to solve this for private repos
  • happens whether I use "sudo -H" or if switch to root user and run directly

Where

  • n/a

How

Current Behavior

  • fails to install global packages from GitHub

Steps to Reproduce

  • run the following command
sudo -H npm install -g git+https://github.com/richRemer/pool.git

Expected Behavior

  • it should work the same as running:
git clone https://github.com/richRemer/pool.git
sudo -H npm install -g $(npm pack pool/)

Who

  • n/a

References

@isaacs
Copy link
Contributor

isaacs commented Dec 30, 2019

Duplicate of #624.

@isaacs isaacs closed this as completed Dec 30, 2019
isaacs added a commit to npm/pacote that referenced this issue Dec 30, 2019
Fix: npm/cli#624
Fix: npm/cli#642
Fix: npm/cli#514

Infer the ownership of a git command invocation based on the cwd, if one is
specified.
rish9511 added a commit to ElucidataInc/node-s3-client that referenced this issue Jun 30, 2022
Before this commit it was required to install the package
using Github. However when using NPM version 8.5, the installation
used to fail with the following error :
"... git --no-replace-objects clone https://git@github.com/ElucidataInc/node-s3-client.git
 /root/.npm/_cacache/tmp/git-cloneNZtpAU --recurse-submodules
npm ERR! fatal: could not create leading directories of
'/root/.npm/_cacache/tmp/git-cloneNZtpAU': Permission denied"

The following Github threads were reported with similar issues
- npm/cli#624
- npm/cli#642

As the suggested methods in the above threads, like shifting to older
version of NPM, did not satisfy our needs, we are publishing the package
to NPM public registry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@isaacs @richRemer and others