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] npm install <git remote url> when git group/namespace starts with a number #7255

Open
2 tasks done
albek446 opened this issue Feb 27, 2024 · 2 comments
Open
2 tasks done
Labels
Bug thing that needs fixing Documentation documentation related issue Priority 2 secondary priority issue

Comments

@albek446
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

Running the following command does not work:

npm install git+ssh://git@github.com:1example/common-code.git

Note that 1example/common-code.git is not a real repository. It is just used to demonstrate the issue.

The problem is that the group/namespace/org part that is named 1example in this example begins with a number. The full format for the npm install command for this is as follows:
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]

Here we can clearly see that the : can be used for both the port and the path parts. So I guess that because 1example begins with a number it is treated as the port and therefore this fails. Note that I am not sure this is the case, just a guess based on the behaviors I have seen.

Expected Behavior

I would expect that 1example is treated as a group/namespace/org and not as a port since 1exampleis not a valid port.
I would expect that the npm install git+ssh://git@github.com:1example/common-code.git command works and the package is installed (assuming the command actually points to a real repository which it is not in this example)

Steps To Reproduce

  1. Create a git repository inside a group/namespace/org that begins with a number
  2. run npm install git+ssh://git@github.com:<group/namespace/org>/<repo.name>.git against the repository that was created in step 1

Environment

  • npm: 9.8.1
  • Node.js: v18.18.1
  • OS Name: Ubuntu 20.04.06 and in Rocky Linux 9.3
  • System Model Name: Not Relevant
  • npm config: empty
@albek446 albek446 added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Feb 27, 2024
@kashav
Copy link

kashav commented Feb 29, 2024

Mind if I work on this?

@kashav
Copy link

kashav commented Mar 6, 2024

nvm, I think this is just a consequence of how shell treats colons in URIs.

eg, the following two also fail:

$ npm install git+ssh://git@github.com:6/stopwords-json.git
$ git --no-replace-objects ls-remote ssh://git@github.com:6/stopwords-json.git

@milaninfy milaninfy added Documentation documentation related issue Priority 2 secondary priority issue and removed Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Documentation documentation related issue Priority 2 secondary priority issue
Projects
None yet
Development

No branches or pull requests

3 participants