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

Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped? #5536

Closed
Amiryy opened this issue Mar 18, 2018 · 14 comments
Closed
Assignees
Labels

Comments

@Amiryy
Copy link

Amiryy commented Mar 18, 2018

Do you want to request a feature or report a bug?

I'd like to report a bug.

What is the current behavior?
After cloning a repository and uploading it to a private repository I try to run yarn add ...repo url
I get:
error An unexpected error occurred: "https://...": Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?".

If the current behavior is a bug, please provide the steps to reproduce.

  1. clone https://github.com/adazzle/react-data-grid.
  2. create a new repo and publish your clone.
  3. run yarn add ...repo url in a project directory.

What is the expected behavior?
Adding the forked package to my dependencies.

Please mention your node.js, yarn and operating system version.
OS: MacOS High Sierra 10.13.3 (17D102)
yarn v1.5.1
node.js v8.9.4

yarn-error.log:

  Error: https://...repo url: Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?
      at Object.module.exports.exports.decode (/usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:76469:43)
      at Extract.onheader [as _onparse] (/usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:145039:39)
      at Extract.module.exports.Extract._write (/usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:145162:8)
      at doWrite (/usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:72818:64)
      at writeOrBuffer (/usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:72807:5)
      at Extract.module.exports.Writable.write (/usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:72744:11)
      at Duplexify.ondata (/usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:71892:20)
      at emitOne (events.js:116:13)
      at Duplexify.emit (events.js:211:7)
      at readableAddChunk (/usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:71563:18)
@ghost ghost assigned rally25rs Mar 18, 2018
@ghost ghost added the triaged label Mar 18, 2018
@rally25rs
Copy link
Contributor

what is the URL that you are using? my guess it that it is malformed in some way.

@Amiryy
Copy link
Author

Amiryy commented Mar 18, 2018

The URL is a private git lab repository, it is private to the company I work in.
it looks like that: https://gitlab.eng.company.com/team/react-data-grid

I have noticed that forking the repo and yarn adding it straight from the fork url (instead of cloning and republishing) doesn't work either - I get an error:
An unexpected error occurred: "Can't add \"react-data-grid\": invalid package version undefined."
The same happens when I try to add the repo straight from https://github.com/adazzle/react-data-grid.

@rally25rs
Copy link
Contributor

I can fork that repo on GitHub and it seems to at least try to install. I had to edit package.json because the package was marked private and didn't have a version. I don't have lerna installed so it failed at that point

~/Projects/yarn-test/packages/package-one 🐒   yarn add https://github.com/rally25rs/react-data-grid.git
yarn add v1.5.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "https://github.com/rally25rs/react-data-grid.git > react-dnd@2.5.4" has unmet peer dependency "react@*".
warning "https://github.com/rally25rs/react-data-grid.git > react-contextmenu@1.6.2" has unmet peer dependency "react@^0.14.0 || ^15.0.0".
warning "https://github.com/rally25rs/react-data-grid.git > react-contextmenu@1.6.2" has unmet peer dependency "react-dom@^0.14.0 || ^15.0.0".
warning "https://github.com/rally25rs/react-data-grid.git > react-select@1.2.1" has unmet peer dependency "react@^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0".
warning "https://github.com/rally25rs/react-data-grid.git > react-select@1.2.1" has unmet peer dependency "react-dom@^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0".
warning "https://github.com/rally25rs/react-data-grid.git > react-select > react-input-autosize@2.2.1" has unmet peer dependency "react@^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0".
warning "https://github.com/rally25rs/react-data-grid.git > react-input-autosize@1.1.0" has unmet peer dependency "react@^0.14 || ^15.0.0-rc || ^15.0".
warning "https://github.com/rally25rs/react-data-grid.git > react-contextmenu > react-overlays@0.6.12" has unmet peer dependency "react@>=0.14.0".
warning "https://github.com/rally25rs/react-data-grid.git > react-contextmenu > react-overlays@0.6.12" has unmet peer dependency "react-dom@>=0.14.0".
warning "https://github.com/rally25rs/react-data-grid.git > react-contextmenu > react-overlays > react-prop-types@0.4.0" has unmet peer dependency "react@>=0.14.0".
warning " > react-data-grid@2.0.2" has unmet peer dependency "react@^15.6.2".
warning " > react-data-grid@2.0.2" has unmet peer dependency "react-dom@^15.6.2".
[4/4] Building fresh packages...
[-/3] ⡀ waiting...
[2/3] ⡀ uws
[-/3] ⡀ waiting...
[-/3] ⡀ waiting...
error An unexpected error occurred: "/Users/jvalore/Projects/yarn-test/node_modules/react-data-grid: Command failed.
Exit code: 127
Command: sh
Arguments: -c lerna bootstrap
Directory: /Users/jvalore/Projects/yarn-test/node_modules/react-data-grid
Output:

@rally25rs
Copy link
Contributor

Judging from the output message, it would seem like maybe your registry isn't returning a proper .tgz file, which yarn requests using the git archive command. 🤔

@Amiryy
Copy link
Author

Amiryy commented Mar 18, 2018

I just edited my comment to refer to this ^

In that case, what is your suggestion?

@rally25rs
Copy link
Contributor

rally25rs commented Mar 18, 2018

Could you try adding .git to the end of your url? I think yarn might think you are trying to give it the path directly to a tarball... trying to quickly dig through the code looking for how it decides...

I noticed these that it uses to decide that the URL is to a git repo:

const GIT_HOSTS = ['github.com', 'gitlab.com', 'bitbucket.com', 'bitbucket.org'];

const GIT_PATTERN_MATCHERS = [/^git:/, /^git\+.+:/, /^ssh:/, /^https?:.+\.git$/, /^https?:.+\.git#.+/];

so I think since you are using a private repo, it doesnt match the hard coded domain names, then falls back to the regex matches

Adding a .git to the end should make it match. Otherwise I think it falls back to the tarball resolver and just downloades whatever is at that URL and tries to untar it, hence the error.

@Amiryy
Copy link
Author

Amiryy commented Mar 18, 2018

looks like adding .git at the end of the url solved it. The package is now being installed.
Thanks a lot, @rally25rs!

@gunzip
Copy link

gunzip commented Jun 5, 2018

same issue trying to "yarn add node-fetch && yarn install" (yarn 1.7.0):

Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?

(npm works). adding .git to the URL does not help

@madrus
Copy link

madrus commented Aug 24, 2018

Same issue trying to install Vue CLI 3.0 with yarn while installing with npm works fine.
Actually, I get exactly the same error message (about yeoman-generator) with ANY package whether I try to install, remove, or upgrade. So, currently I can only work via npm. Yarn has become virtually unusable.
I have tried reinstalling yarn, deleting all yeoman-generator packages from yarn cache but no change in behavior.

$ yarn global add @vue/cli
yarn global v1.9.4
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
warning Pattern ["yeoman-generator@https://github.com/ev1stensberg/generator.git#Feature-getArgument"] is trying to unpack in the same destination "/Users/madrus/Library/Caches/Yarn/v2/npm-yeoman-generator-1.1.1-9e24fa31c85302ca1145ae34fc68b4f133251ca0" as pattern ["yeoman-generator@^1.1.0"]. This could result in non-deterministic behavior, skipping.
error https://github.com/ev1stensberg/generator.git: Extracting tar content of undefined failed, the file appears to be corrupt: "Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?"
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.

@corysimmons
Copy link

corysimmons commented Jan 14, 2019

This throws on trying to add a pkg from a GitHub URL + commit (press y while viewing a GitHub project).

Example: yarn add https://github.com/rehooks/window-scroll-position/tree/0d935b8cbc8c215c6d832d31bc3150896e4e50d9 throws.

It'd be really nice to be able to do this as it'd kinda version lock to that commit (i.e. prevent maintainers from screwing over users by force pushing a breaking change).

https://yarnpkg.com/lang/en/docs/cli/add/#toc-adding-dependencies docs kinda lead me to believe the commit URL thing would work.

yarn add #<branch/commit/tag> installs a package from a remote git repository at specific git branch, git commit or git tag.

@cristianmercado19
Copy link

looks like adding .git at the end of the url solved it. The package is now being installed.
Thanks a lot, @rally25rs!

Dealing with similar issue when I have tried to add a tgz dependency in the package.json
"my-package": "https://gitlab+deploy-token-88433:xxxxx@gitlab.com/MyUser/my-package.git/raw/Packages/my-package-1.0.6.tgz",

Even when I have added .git`` as you recommended in the url, it does not work.

Error message:
Extracting tar content of undefined failed, the file appears to be corrupt: "Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?"

Forcing consumer to install my package throw tgz file I am "preventing" use the source code instead the transpired / compiled.

Any suggestion?

@nathanhannig
Copy link

I started getting this error for a package yesterday, anyone else?

@anchalarora
Copy link

Getting the same error while I mentioned "@stevenmasini/react-native-fast-image": "https://test-uat2.gymboree.com/rwd/third-party/react-native-fast-image-v7.0.3.tgz", in package.json file.

Any solution?

@rbrooks
Copy link

rbrooks commented Oct 24, 2022

Sorry to crack this open and Spam everyone. I didn't see this workaround mentioned.

I had to fully qualify the URL, ie, change this line (which already had .git in it):

"react-d3-tree": "https://github.com/trainual/react-d3-tree.git#release/3.3.6",

...to:

"react-d3-tree": "https://github.com/trainual/react-d3-tree/archive/refs/tags/release/3.3.6.tar.gz",

That's one of our privately hosted React packages. Just drill into it in your GitHub GUI, and do "Copy URL".

Then pnpm install succeeded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants