-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 pack <git-dependency>#<commit-hash>
fails in npm >= 9.6.5
#6723
Comments
npm>=9.6.5 has a bug which causes `npm pack` to fail for git dependencies: npm/cli#6723 The latest `nodejs-npm` available in the Fedora 38 repos is 9.6.7. Downgrade to the only older version still available, which is 9.5.0. Signed-off-by: Adam Cmiel <[email protected]>
npm>=9.6.5 has a bug which causes `npm pack` to fail for git dependencies: npm/cli#6723 The latest `nodejs-npm` available in the Fedora 38 repos is 9.6.7. Downgrade to the only older version still available, which is 9.5.0. Signed-off-by: Adam Cmiel <[email protected]>
npm>=9.6.5 has a bug which causes `npm pack` to fail for git dependencies: npm/cli#6723 The latest `nodejs-npm` available in the Fedora 38 repos is 9.6.7. Downgrade to the only older version still available, which is 9.5.0. Signed-off-by: Adam Cmiel <[email protected]>
So, I think I've found the problem. npm pack calls pacote.manifest() without passing in an Arborist (why would it, it's just getting a package.json) Line 37 in 6ec6ff0
For a git dependency which is "hosted" and resolved, GitFetcher.manifest uses FileFetcher.manifest instead cli/node_modules/pacote/lib/git.js Lines 312 to 313 in 6ec6ff0
FileFetcher.manifest calls extract() cli/node_modules/pacote/lib/file.js Lines 27 to 28 in 6ec6ff0
extract calls _tarballFromResolved cli/node_modules/pacote/lib/fetcher.js Line 331 in 6ec6ff0
And finally, GitFetcher's _tarballFromResolved does a full clone, prepare and would go on to do pretty much an entire pack operation if not for the missing Arborist error cli/node_modules/pacote/lib/git.js Lines 209 to 213 in 6ec6ff0
|
I think the fix is to remove the FileFetcher.manifest usage and always just clone return Promise.resolve(this.package)
}
- return this.spec.hosted && this.resolved
- ? FileFetcher.prototype.manifest.apply(this)
- : this[_clone](dir =>
+ return this[_clone](dir =>
this[_readPackageJson](dir + '/package.json')
.then(mani => this.package = {
...mani,
Would anyone happen to know why FileFetcher.manifest was used in the first place? |
To get the manifest for a hosted, resolved git package, pacote uses FileFetcher.manifest. FileFetcher.manifest calls extract(), which calls _tarballFromResolved. This means getting the manifest involves nearly a complete pack operation, including 'npm install', the 'prepare' script etc. It also means getting the manifest requires an Arborist constructor (causes npm/cli#6723). Remove the special handling of hosted, resolved git packages, handle all git packages the same way: clone the repo (or get the tarball from a hosted git server) and read the package.json. The effects for hosted, resolved git packages: - getting the manifest no longer involves packing the tarball - getting the manifest no longer requires an Arborist constructor - the manifest no longer includes an _integrity (same as un-hosted or un-resolved git packages) Signed-off-by: Adam Cmiel <[email protected]>
To get the manifest for a hosted, resolved git package, pacote uses FileFetcher.manifest. FileFetcher.manifest calls extract(), which calls _tarballFromResolved. This means getting the manifest involves nearly a complete pack operation, including 'npm install', the 'prepare' script etc. It also means getting the manifest requires an Arborist constructor (causes npm/cli#6723). Remove the special handling of hosted, resolved git packages, handle all git packages the same way: clone the repo (or get the tarball from a hosted git server) and read the package.json. The effects for hosted, resolved git packages: - getting the manifest no longer involves packing the tarball - getting the manifest no longer requires an Arborist constructor - the manifest no longer includes an _integrity (same as un-hosted or un-resolved git packages) Signed-off-by: Adam Cmiel <[email protected]>
I'm getting the same error when trying to use |
evidently it works for short commit hash format and fails for long one.
|
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npm pack
with a specific commit of a git dependency fails as follows:Expected Behavior
Expected
npm pack
to succeed (like it does in version <= 9.6.4).Note that it still works for things that are not commit hashes:
Steps To Reproduce
npm
version 9.6.5 or highernpm pack vercel/ms#1304f150b38027e0818cc122106b5c7322d68d0c
or any other git dependency + commit hashnpm ERR! GitFetcher requires an Arborist constructor to pack a tarball
Environment
The text was updated successfully, but these errors were encountered: