npm / npm/cli

[BUG] npm treat every path from gitlab as git url even it is a dist path to .tgz

Open
#2,405 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug cmd:install Priority 2 Release 7.x Release 8.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Current Behavior:

Every path in gitlab generic package was treated as git repo url
For example https://gitlab.com/api/v4/projects/0000000/packages/generic/xxxxxxxx/0.0.1/dist.tar.gz

results in

npm ERR! code 128
npm ERR! command failed
npm ERR! command git ls-remote ssh://git@gitlab.com/api/v4/projects/0000000/packages/generic/xxxxxxxx/0.0.1/dist.tar.gz.git
npm ERR! remote: 
npm ERR! remote: ========================================================================
npm ERR! remote: 
npm ERR! remote: The namespace you were looking for could not be found.
npm ERR! remote: 
npm ERR! remote: ========================================================================
npm ERR! remote: 
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mmis1000/.npm/_logs/2020-12-23T05_24_20_136Z-debug.log
Expected Behavior:

It should be treated as a tarball url as the path suggests.
At least for path under the /api/ should just respect the path.
Instead of https://gitlab.com/api/v4/projects/0000000/packages/generic/xxxxxxxx/0.0.1/dist.tar.gz.git/

Steps To Reproduce:
  1. npm init
  2. npm i https://gitlab.com/api/v4/projects/0000000/packages/generic/xxxxxxxx/0.0.1/dist.tar.gz
  3. See the error
Environment:
  • OS: Mac 11.1
  • Node: v10.21.0
  • npm: 7.3.0
Note

The same bug exists in npm@6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with npm i https://gitlab.com/api/v4/projects/0000000/packages/generic/xxxxxxxx/0.0.1/dist.tar.gz, then trace npm's URL handling and git-versus-tarball resolution. Done means the .tar.gz URL is fetched as a tarball without appending .git or invoking git ls-remote.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, javascript, nodejs
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.