Skip to content

Conversation

@thomasdraebing
Copy link
Contributor

Aspect_rules_js supports fetching a git repository containing an npm package. However, to follow that path, it is required that the URL of the repository is prefixed with git+. However, this URL is then also configured as the remote for the git repository. The git+ prefix is not supported by git and thus fetching fails with:

git: 'remote-git+https' ist kein Git-Befehl. Siehe 'git --help'.

To prevent this, the git+-prefix is now being removed, if it is present before setting it as remote url.formation ends up in the git log.
-->


Changes are visible to end-users: no

Test plan

  • Manual testing; please provide instructions so we can reproduce:

Install an NPM package from a git repository. The pnpm-lock.yaml may look like this:

lockfileVersion: '6.0'

settings:
  autoInstallPeers: true
  excludeLinksFromLockfile: false

dependencies:
  highlight.js:
    specifier: ^11.11.1
    version: 11.11.1
  highlightjs-ttcn3:
    specifier: https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d
    version: gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d

packages:
  /[email protected]:
    resolution: {integrity: sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==}
    engines: {node: '>=12.0.0'}
    dev: false

  gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d:
    resolution:
      type: git
      repo: git+https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git
      commit: 6daccff309fca1e7561a43984d42fa4f829ce06d
    name: highlightjs-ttcn3
    version: 0.0.1
    dependencies:
      highlight.js: 11.11.1
    dev: false

@CLAassistant
Copy link

CLAassistant commented Oct 22, 2025

CLA assistant check
All committers have signed the CLA.

@aspect-workflows
Copy link

aspect-workflows bot commented Oct 22, 2025

Bazel 7 (Test)

All tests were cache hits

294 tests (100.0%) were fully cached saving 39s.


Bazel 8 (Test)

All tests were cache hits

257 tests (100.0%) were fully cached saving 36s.


Bazel 7 (Test)

e2e/bzlmod

All tests were cache hits

5 tests (100.0%) were fully cached saving 559ms.


Bazel 7 (Test)

e2e/git_dep_metadata

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Bazel 7 (Test)

e2e/git_dep_no_tar

1 test target passed

Targets
//:no_git_tar_test24ms

Bazel 7 (Test)

e2e/gyp_no_install_script

All tests were cache hits

2 tests (100.0%) were fully cached saving 153ms.


Bazel 7 (Test)

e2e/js_image_oci

All tests were cache hits

1 test (100.0%) was fully cached saving 6s.


Bazel 7 (Test)

e2e/npm_link_package

All tests were cache hits

2 tests (100.0%) were fully cached saving 206ms.


Bazel 7 (Test)

e2e/npm_link_package-esm

All tests were cache hits

2 tests (100.0%) were fully cached saving 224ms.


Bazel 7 (Test)

e2e/npm_link_package-rerooted

All tests were cache hits

2 tests (100.0%) were fully cached saving 199ms.


Bazel 7 (Test)

e2e/npm_translate_lock

All tests were cache hits

3 tests (100.0%) were fully cached saving 681ms.


Bazel 7 (Test)

e2e/npm_translate_lock_disable_hooks

All tests were cache hits

3 tests (100.0%) were fully cached saving 257ms.


Bazel 7 (Test)

e2e/npm_translate_lock_empty

All tests were cache hits

2 tests (100.0%) were fully cached saving 180ms.


Bazel 7 (Test)

e2e/npm_translate_lock_exclude_package_contents

All tests were cache hits

1 test (100.0%) was fully cached saving 34ms.


Bazel 7 (Test)

e2e/npm_translate_lock_link_workspace

All tests were cache hits

2 tests (100.0%) were fully cached saving 225ms.


Bazel 7 (Test)

e2e/npm_translate_lock_multi

All tests were cache hits

2 tests (100.0%) were fully cached saving 164ms.


Bazel 7 (Test)

e2e/npm_translate_lock_partial_clone

All tests were cache hits

1 test (100.0%) was fully cached saving 61ms.


Bazel 7 (Test)

e2e/npm_translate_lock_replace_packages

All tests were cache hits

4 tests (100.0%) were fully cached saving 487ms.


Bazel 7 (Test)

e2e/npm_translate_lock_subdir_patch

All tests were cache hits

1 test (100.0%) was fully cached saving 95ms.


Bazel 7 (Test)

e2e/npm_translate_package_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Bazel 7 (Test)

e2e/npm_translate_yarn_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Bazel 7 (Test)

e2e/package_json_module

All tests were cache hits

1 test (100.0%) was fully cached saving 324ms.


Bazel 7 (Test)

e2e/patch_from_repo

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Bazel 7 (Test)

e2e/pnpm_lockfiles

All tests were cache hits

82 tests (100.0%) were fully cached saving 8s.


Bazel 7 (Test)

e2e/pnpm_repo_install

All tests were cache hits

1 test (100.0%) was fully cached saving 963ms.


Bazel 7 (Test)

e2e/pnpm_version

All tests were cache hits

1 test (100.0%) was fully cached saving 75ms.


Bazel 7 (Test)

e2e/pnpm_workspace

All tests were cache hits

15 tests (100.0%) were fully cached saving 3s.


Bazel 7 (Test)

e2e/pnpm_workspace_deps

All tests were cache hits

3 tests (100.0%) were fully cached saving 428ms.


Bazel 7 (Test)

e2e/pnpm_workspace_rerooted

All tests were cache hits

15 tests (100.0%) were fully cached saving 3s.


Bazel 7 (Test)

e2e/repo_mapping

All tests were cache hits

3 tests (100.0%) were fully cached saving 394ms.


Bazel 7 (Test)

e2e/runfiles

All tests were cache hits

1 test (100.0%) was fully cached saving 110ms.


Bazel 7 (Test)

e2e/stamped_package_json

All tests were cache hits

1 test (100.0%) was fully cached saving 44ms.


Bazel 7 (Test)

e2e/vendored_node

All tests were cache hits

1 test (100.0%) was fully cached saving 70ms.


Bazel 7 (Test)

e2e/vendored_tarfile

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Bazel 7 (Test)

e2e/verify_patches

All tests were cache hits

2 tests (100.0%) were fully cached saving 109ms.


Bazel 7 (Test)

e2e/worker

All tests were cache hits

1 test (100.0%) was fully cached saving 35ms.


Bazel 7 (Test)

e2e/workspace

All tests were cache hits

1 test (100.0%) was fully cached saving 35ms.


Buildifier      Format

@jbedard
Copy link
Member

jbedard commented Oct 22, 2025

Can you add a test which fails without your fix?

@thomasdraebing
Copy link
Contributor Author

Can you add a test which fails without your fix?

I will do that. Currently I am waiting for my company to approve the CLA. As soon as this has been done, I will continue on this PR.

@thomasdraebing
Copy link
Contributor Author

@jbedard I finally got the approval to sign the CLA and added an E2E test. If you just check out the first commit that contains only the test, it fails, and it succeeds with the second commit containing the fix.

@jbedard
Copy link
Member

jbedard commented Dec 16, 2025

Would it be possible to test it by adding a package to e2e/pnpm_lockfiles/base/package.json? Or are you only able to reproduce when manually invoking npm_import()?

@jbedard
Copy link
Member

jbedard commented Dec 16, 2025

Otherwise I think you need to add the e2e test to the list in .github/workflows/ci.yaml and .aspect/workflows/config.yaml

Aspect_rules_js supports fetching a git repository containing an npm
package. However, to follow that path, it is required that the URL
of the repository is prefixed with `git+`. However, this URL is then
also configured as the remote for the git repository. The `git+`
prefix is not supported by git and thus fetching fails with:

git: 'remote-git+https' ist kein Git-Befehl. Siehe 'git --help'.

To prevent this, the `git+`-prefix is now being removed, if it
is present before setting it as remote url.
@thomasdraebing
Copy link
Contributor Author

Otherwise I think you need to add the e2e test to the list in .github/workflows/ci.yaml and .aspect/workflows/config.yaml

Done

Would it be possible to test it by adding a package to e2e/pnpm_lockfiles/base/package.json? Or are you only able to reproduce when manually invoking npm_import()?

I have updated the test.

@jbedard jbedard merged commit cf7583d into aspect-build:main Dec 19, 2025
113 checks passed
@jbedard
Copy link
Member

jbedard commented Dec 19, 2025

@thomasdraebing I'm just looking to port this to the 3.x branch and also add more testing and I keep getting errors when trying to install this https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d dep. But if I run pnpm (even a newer version that changes the lockfile format) in your new e2e test it seems to work, maybe because it maintains the metadata it already has and doesn't try to refetch it.

Is there something special with this https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d URL that may require auth or restrict it in some other way?

@jbedard
Copy link
Member

jbedard commented Dec 19, 2025

Even if I just rm pnpm-lock.yaml from e2e/git_dep_no_tar it then fails to install.

@thomasdraebing you must have some local config making this work work?

jbedard pushed a commit to jbedard/rules_js that referenced this pull request Dec 19, 2025
Aspect_rules_js supports fetching a git repository containing an npm
package. However, to follow that path, it is required that the URL of
the repository is prefixed with `git+`. However, this URL is then also
configured as the remote for the git repository. The `git+` prefix is
not supported by git and thus fetching fails with:

git: 'remote-git+https' ist kein Git-Befehl. Siehe 'git --help'.

To prevent this, the `git+`-prefix is now being removed, if it is
present before setting it as remote url.formation ends up in the git
log.

---

### Changes are visible to end-users: no

### Test plan

- Manual testing; please provide instructions so we can reproduce:

Install an NPM package from a git repository. The pnpm-lock.yaml may
look like this:

```
lockfileVersion: '6.0'

settings:
  autoInstallPeers: true
  excludeLinksFromLockfile: false

dependencies:
  highlight.js:
    specifier: ^11.11.1
    version: 11.11.1
  highlightjs-ttcn3:
    specifier: https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d
    version: gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d

packages:
  /[email protected]:
    resolution: {integrity: sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==}
    engines: {node: '>=12.0.0'}
    dev: false

  gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d:
    resolution:
      type: git
      repo: git+https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git
      commit: 6daccff309fca1e7561a43984d42fa4f829ce06d
    name: highlightjs-ttcn3
    version: 0.0.1
    dependencies:
      highlight.js: 11.11.1
    dev: false
```
@thomasdraebing
Copy link
Contributor Author

@jbedard just using pnpm or npm also fails for me for that repository. Actually for the same reason, it tries to download a tar-archive, which isn't available on that git server.

❯ pnpm add https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git\#6daccff309fca1e7561a43984d42fa4f829ce06d
 WARN  GET https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d error (ERR_PNPM_TARBALL_EXTRACT). Will retry in 10 seconds. 2 retries left.

It works however using yarn from which we are in the progress of migrating from due to the removal of support of yarn_install in rules_nodejs.

❯ yarn add https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git\#6daccff309fca1e7561a43984d42fa4f829ce06d
yarn add v1.22.22
info No lockfile found.
(node:13400) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
(Use `node --trace-deprecation ...` to show where the warning was created)
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...

success Saved lockfile.
success Saved 2 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ [email protected]
└─ [email protected]
✨  Done in 4.84s.

@jbedard
Copy link
Member

jbedard commented Dec 22, 2025

How did you generate the pnpm-lock in your new e2e test then?

jbedard added a commit that referenced this pull request Dec 22, 2025
Found while adding more tests for
#2403

### Changes are visible to end-users: no

### Test plan

- Covered by existing test cases
- New test cases added
jbedard added a commit that referenced this pull request Dec 22, 2025
Found while adding more tests for
#2403

- Covered by existing test cases
- New test cases added
jbedard pushed a commit to jbedard/rules_js that referenced this pull request Dec 22, 2025
Aspect_rules_js supports fetching a git repository containing an npm
package. However, to follow that path, it is required that the URL of
the repository is prefixed with `git+`. However, this URL is then also
configured as the remote for the git repository. The `git+` prefix is
not supported by git and thus fetching fails with:

git: 'remote-git+https' ist kein Git-Befehl. Siehe 'git --help'.

To prevent this, the `git+`-prefix is now being removed, if it is
present before setting it as remote url.formation ends up in the git
log.

---

- Manual testing; please provide instructions so we can reproduce:

Install an NPM package from a git repository. The pnpm-lock.yaml may
look like this:

```
lockfileVersion: '6.0'

settings:
  autoInstallPeers: true
  excludeLinksFromLockfile: false

dependencies:
  highlight.js:
    specifier: ^11.11.1
    version: 11.11.1
  highlightjs-ttcn3:
    specifier: https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d
    version: gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d

packages:
  /[email protected]:
    resolution: {integrity: sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==}
    engines: {node: '>=12.0.0'}
    dev: false

  gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git#6daccff309fca1e7561a43984d42fa4f829ce06d:
    resolution:
      type: git
      repo: git+https://gitea.osmocom.org/ttcn3/highlightjs-ttcn3.git
      commit: 6daccff309fca1e7561a43984d42fa4f829ce06d
    name: highlightjs-ttcn3
    version: 0.0.1
    dependencies:
      highlight.js: 11.11.1
    dev: false
```
@thomasdraebing
Copy link
Contributor Author

The case used in the e2e test is actually the case, I wanted to solve for the Gerrit project. There I added the dependency manually to the lock-file based on the previously existing yarn.lock file. I guess, the same bug should be fixed in pnpm as well.

@jbedard
Copy link
Member

jbedard commented Dec 23, 2025

You manually created the lockfile? Does that mean it might be invalid and your fix is for a scenario that pnpm would never reproduce?

@thomasdraebing
Copy link
Contributor Author

I don't believe that it is invalid. The resolution format is implemented here: https://github.com/pnpm/pnpm/blob/v8.15.9/resolving/git-resolver/src/index.ts#L36.

This works:

lockfileVersion: '6.0'

settings:
  autoInstallPeers: true
  excludeLinksFromLockfile: false

dependencies:
  highlightjs-vue:
    specifier: github:paladox/highlightjs-vue#44eed074ea0110d1ad03d2cbd77d27027cf7bb04
    version: github.com/paladox/highlightjs-vue/44eed074ea0110d1ad03d2cbd77d27027cf7bb04

packages:

  github.com/paladox/highlightjs-vue/44eed074ea0110d1ad03d2cbd77d27027cf7bb04:
    resolution:
      type: git
      repo: git+https://codeload.github.com/paladox/highlightjs-vue.git
      commit: 44eed074ea0110d1ad03d2cbd77d27027cf7bb04
    name: highlightjs-vue
    version: 1.1.0
    dev: false

However, pnpm again uses this data to compute the tar-ball download URL.

This is not the case for rules_js. It will actually try to clone. Just see the diff of my fix and that is clearly broken.
I would be open to have a look at pnpm itself and to add the support of git clone to fetching dependencies as well, because I believe that this is a valid usecase.

@jbedard
Copy link
Member

jbedard commented Dec 23, 2025

If it is impossible to generate that lockfile via pnpm then I would not consider that to be a valid lockfile.

See e758431 where I was trying to add tests for this. Anywhere I use git+https specifiers it results in resolution: {... repo: https://} without any git+ in the resolution.

How did you end up with git+https in the resolution.repo?

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 this pull request may close these issues.

3 participants