nvm icon indicating copy to clipboard operation
nvm copied to clipboard

Checksums do not match; tar: Error opening archive: Unrecognized archive format

Open gvlax opened this issue 2 years ago • 1 comments

Operating system and version:

nvm debug output:

nvm --version: v0.39.3
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'maciejgulak'
${HOME}: /Users/maciejgulak
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8.1 (x86_64-apple-darwin22.0)'
uname -a: 'Darwin 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:06:26 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8112 arm64'
checksum binary: 'shasum'
OS version: macOS 13.1 22C65
awk: /usr/bin/awk, awk version 20200816
curl: /usr/bin/curl, curl 7.85.0 (x86_64-apple-darwin22.0) libcurl/7.85.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.47.0
wget: /opt/homebrew/bin/wget, GNU Wget 1.21.3 built on darwin22.1.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/bin/git, git version 2.37.1 (Apple Git-137.1)
ls: grep:: No such file or directory
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}), grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:271: command not found: npm
npm root -g: nvm:271: command not found: npm

nvm ls output:

       v16.19.0
        v19.3.0
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v19.3.0) (default)
stable -> 19.3 (-> v19.3.0) (default)
lts/* -> lts/lts (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.2 (-> N/A)
lts/gallium -> v16.19.0 (-> N/A)
lts/hydrogen -> v18.12.1 (-> N/A)
lts/lts -> version (-> N/A)

How did you install nvm?

curl command from https://github.com/nvm-sh/nvm#install--update-script

What steps did you perform?

nvm install <node_version>

What happened?

Regardless of the specified node version (14, or 19), the installation fails showing each time the same errors regarding checksums and unrecognised archive format. For instance:

➜  ~ nvm install v15
Downloading and installing node v15.14.0...
Downloading https://nodejs.org/dist/v15.14.0/node-v15.14.0-darwin-x64.tar.xz...
############################################################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums do not match: '38bbfc689514b23284510ab918794d17a0520b3ef7b222ae8c7babb4e40cb4b2' found, 'f355aeda5049fdbac4acca23a7bb6f66e145a179a52bd2489e3f76fbe0feb161' expected.
tar: Error opening archive: Unrecognized archive format
mv: rename /Users/maciejgulak/.nvm/.cache/bin/node-v15.14.0-darwin-x64/files/* to /Users/maciejgulak/.nvm/versions/node/v15.14.0/*: No such file or directory
Binary download failed, trying source.
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Downloading https://nodejs.org/dist/v15.14.0/node-v15.14.0.tar.xz...
############################################################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums do not match: 'fae701b16eda78963c59a2f5ebd36da9ba98a4032e30d3092800f8c534aaedef' found, '8122dc4eea4f00af32a1d14ca85a1d4d6ca7b2dcffd9a731bda149fc5593a66e' expected.
tar: Error opening archive: Unrecognized archive format
nvm: install v15.14.0 failed!

What did you expect to happen?

No checksums and archive errors.

Is there anything in any of your profile files that modifies the PATH?

Yes, I am using zshrc and OMZ, but after switching back to a regular bash the same issue appears.

gvlax avatar Jan 04 '23 17:01 gvlax

Are you on an M1 or M2 Mac? node 15 requires Rosetta on these.

ljharb avatar Jan 04 '23 17:01 ljharb

M2, but even checking "Open using Rosetta" of iTerm.app the result is the same:

➜  ~ nvm install v15
Downloading and installing node v15.14.0...
Local cache found: ${NVM_DIR}/.cache/bin/node-v15.14.0-darwin-x64/node-v15.14.0-darwin-x64.tar.xz
Computing checksum with shasum -a 256
Checksums do not match: '38bbfc689514b23284510ab918794d17a0520b3ef7b222ae8c7babb4e40cb4b2' found, 'f355aeda5049fdbac4acca23a7bb6f66e145a179a52bd2489e3f76fbe0feb161' expected.
Checksum check failed!
Removing the broken local cache...
Downloading https://nodejs.org/dist/v15.14.0/node-v15.14.0-darwin-x64.tar.xz...
################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums do not match: 'ea4cbac18d8d411ad362bbca2f9aecab06a6ec10d7b63b691434a48f693783ad' found, 'f355aeda5049fdbac4acca23a7bb6f66e145a179a52bd2489e3f76fbe0feb161' expected.
tar: Error opening archive: Unrecognized archive format
nvm_install_binary_extract:40: no matches found: /Users/maciejgulak/.nvm/.cache/bin/node-v15.14.0-darwin-x64/files/*
Binary download failed, trying source.
Detected that you have 8 CPU core(s)
Running with 7 threads to speed up the build
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Local cache found: ${NVM_DIR}/.cache/src/node-v15.14.0/node-v15.14.0.tar.xz
Computing checksum with shasum -a 256
Checksums do not match: 'fae701b16eda78963c59a2f5ebd36da9ba98a4032e30d3092800f8c534aaedef' found, '8122dc4eea4f00af32a1d14ca85a1d4d6ca7b2dcffd9a731bda149fc5593a66e' expected.
Checksum check failed!
Removing the broken local cache...
Downloading https://nodejs.org/dist/v15.14.0/node-v15.14.0.tar.xz...
################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums do not match: '05ff2e463316c8bfa36b34f891bc7af4bee90861ae3675893d0cfc80d66eef0d' found, '8122dc4eea4f00af32a1d14ca85a1d4d6ca7b2dcffd9a731bda149fc5593a66e' expected.
tar: Error opening archive: Unrecognized archive format
nvm: install v15.14.0 failed!

or for v14

➜  ~ nvm install v14
Downloading and installing node v14.21.2...
Downloading https://nodejs.org/dist/v14.21.2/node-v14.21.2-darwin-x64.tar.xz...
################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums do not match: 'b52791ad7a2887d5f0bc887c6f2358f0695bda884008d119c572b1277b4e29bc' found, 'f32dc21f9bde31563d9c8fd28e07a7bc1189d1a094cc842125ae3067128f9492' expected.
tar: Error opening archive: Unrecognized archive format
nvm_install_binary_extract:40: no matches found: /Users/maciejgulak/.nvm/.cache/bin/node-v14.21.2-darwin-x64/files/*
Binary download failed, trying source.
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Downloading https://nodejs.org/dist/v14.21.2/node-v14.21.2.tar.xz...
################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums do not match: '02e552332fcc6fea0e5e1b52864ad38b619f3c424d4188f66ab9a26430a52fb3' found, 'd8f09a0f16773a77613c3817606f6d455624992d9c43443aca15e91807a1ff03' expected.
tar: Error opening archive: Unrecognized archive format
nvm: install v14.21.2 failed!

Of course in each of the cases, I am able to download the file https://nodejs.org/dist/.../node_v.....tar.xz and tar -xvf manually. The archives are always correct.

I have tried also: $ arch -x86_64 bash The result also ends with lines:

[...]
Checksums do not match: 'a604ee6022773e72905170b30a625ca021a3c130381eb0ba12cc9f014598be54' found, 'd3189574ef9849c713822e7f31de7a1b9dd8a2c6b5fc78ddb811aaa259a22b1e' expected.
tar: Error opening archive: Unrecognized archive format
nvm: install v19.3.0 failed!

gvlax avatar Jan 04 '23 18:01 gvlax

hm, interesting, thanks for confirming. I see you've aliased grep and perhaps also ls - can you try unaliasing those, just to see if that's the problem? What do which tar and which shasum report?

ljharb avatar Jan 04 '23 19:01 ljharb

bash-3.2$ which tar
/usr/bin/tar
bash-3.2$ ls -l /usr/bin/tar
lrwxr-xr-x  1 root  wheel  6 Dec  2 12:37 /usr/bin/tar -> bsdtar
bash-3.2$ which shasum
/usr/bin/shasum

nvm debug output (after unaliasing grep and ls):

nvm --version: v0.39.3
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'maciejgulak'
${HOME}: /Users/maciejgulak
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8.1 (x86_64-apple-darwin22.0)'
uname -a: 'Darwin 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:06:26 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8112 x86_64'
checksum binary: 'shasum'
OS version: macOS 13.1 22C65
awk: /usr/bin/awk, awk version 20200816
curl: /usr/bin/curl, curl 7.85.0 (x86_64-apple-darwin22.0) libcurl/7.85.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.47.0
wget: /opt/homebrew/bin/wget, GNU Wget 1.21.3 built on darwin22.1.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/bin/git, git version 2.37.1 (Apple Git-137.1)
grep: /usr/bin/grep, grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:271: command not found: npm
npm root -g: nvm:271: command not found: npm

Still the same checksums and archive errors, here using node v19 version:

➜  ~ nvm install v19
Downloading and installing node v19.3.0...
Local cache found: ${NVM_DIR}/.cache/bin/node-v19.3.0-darwin-x64/node-v19.3.0-darwin-x64.tar.xz
Computing checksum with shasum -a 256
Checksums do not match: '87c573fcdc3657a192d10bfbe96de6e9d4a13995421e9c95e9f9fc8d8a5b67ee' found, '3bc9a06f53b48a5bb2f4b3d370d5ad6b53e3c36fada85f6850120130fde2a444' expected.
Checksum check failed!
Removing the broken local cache...
Downloading https://nodejs.org/dist/v19.3.0/node-v19.3.0-darwin-x64.tar.xz...
################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums do not match: '8db49b70ddb8864bd53de65e05ec20b4a808acf3944051161684c25edbd3ed05' found, '3bc9a06f53b48a5bb2f4b3d370d5ad6b53e3c36fada85f6850120130fde2a444' expected.
tar: Error opening archive: Unrecognized archive format
nvm_install_binary_extract:40: no matches found: /Users/maciejgulak/.nvm/.cache/bin/node-v19.3.0-darwin-x64/files/*
Binary download failed, trying source.
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Local cache found: ${NVM_DIR}/.cache/src/node-v19.3.0/node-v19.3.0.tar.xz
Computing checksum with shasum -a 256
Checksums do not match: 'fbedbc7e50dece51236256d36c3b6a10f16a655f10b46b6506ae08ced6ef5d39' found, 'd3189574ef9849c713822e7f31de7a1b9dd8a2c6b5fc78ddb811aaa259a22b1e' expected.
Checksum check failed!
Removing the broken local cache...
Downloading https://nodejs.org/dist/v19.3.0/node-v19.3.0.tar.xz...
################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums do not match: '6075bc5655d93f67853bf985411cb6e6a8c2fee7ffc8f07d17930408582e33b0' found, 'd3189574ef9849c713822e7f31de7a1b9dd8a2c6b5fc78ddb811aaa259a22b1e' expected.
tar: Error opening archive: Unrecognized archive format
nvm: install v19.3.0 failed!

gvlax avatar Jan 04 '23 20:01 gvlax

I wonder if bsdtar is the issue. Can you try unaliasing tar instead and see what happens?

ljharb avatar Jan 04 '23 20:01 ljharb

In order to replace bsdtar I did:

brew install gnu-tar
brew install xz

and added

export PATH="$(brew --prefix)/opt/gnu-tar/libexec/gnubin:$PATH"

to .zshrc

Now:

➜  ~ which tar
/opt/homebrew/opt/gnu-tar/libexec/gnubin/tar

The result is that for example

➜  ~ tar -xf node-v14.21.2.tar.xz

works,

but the following fails as previously:

Error nvm install v15:

➜  ~ nvm install v15
Downloading and installing node v15.14.0...
Local cache found: ${NVM_DIR}/.cache/bin/node-v15.14.0-darwin-x64/node-v15.14.0-darwin-x64.tar.xz
Computing checksum with shasum -a 256
Checksums do not match: 'd9578a91631e0c945e703eb77f3caabe83a6388f1ea6ed4d612a2d99b5b1bcc8' found, 'f355aeda5049fdbac4acca23a7bb6f66e145a179a52bd2489e3f76fbe0feb161' expected.
Checksum check failed!
Removing the broken local cache...
Downloading https://nodejs.org/dist/v15.14.0/node-v15.14.0-darwin-x64.tar.xz...
################################################################################################################################################################ 100.0%
Computing checksum with shasum -a 256
Checksums do not match: 'f198848d8b84a18b1abc1fe550b6b48546255e7dc67f40a7ff152a6c5da7190a' found, 'f355aeda5049fdbac4acca23a7bb6f66e145a179a52bd2489e3f76fbe0feb161' expected.
xz: (stdin): File format not recognized
tar: Child returned status 1
tar: Error is not recoverable: exiting now
nvm_install_binary_extract:40: no matches found: /Users/maciejgulak/.nvm/.cache/bin/node-v15.14.0-darwin-x64/files/*
Binary download failed, trying source.
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Local cache found: ${NVM_DIR}/.cache/src/node-v15.14.0/node-v15.14.0.tar.xz
Computing checksum with shasum -a 256
Checksums do not match: 'e839d4df3d18c721ac7775ca5e3e3eae3a629656793f83755a481c7c3bbb4795' found, '8122dc4eea4f00af32a1d14ca85a1d4d6ca7b2dcffd9a731bda149fc5593a66e' expected.
Checksum check failed!
Removing the broken local cache...
Downloading https://nodejs.org/dist/v15.14.0/node-v15.14.0.tar.xz...
################################################################################################################################################################ 100.0%
Computing checksum with shasum -a 256
Checksums do not match: '2afd3bde50659a6f37371b73233377712fb8b5dfac93f0b1071b29e4278f38a5' found, '8122dc4eea4f00af32a1d14ca85a1d4d6ca7b2dcffd9a731bda149fc5593a66e' expected.
xz: (stdin): File format not recognized
tar: Child returned status 1
tar: Error is not recoverable: exiting now
nvm: install v15.14.0 failed!

gvlax avatar Jan 04 '23 21:01 gvlax

I am pretty sure I have found the cause of the problem. The dotfiles-0.2.462 library that I installed, tried and removed a couple days ago probably has left behind a ~/.curlrc configuration that says among others:

# Automatically add newline at end of curl response body.
-w "\n"

when I removed this setting, obviously the Checksums do not match errors disappeared...

gvlax avatar Jan 05 '23 13:01 gvlax

The issue was caused by an incorrect curlrc configuration.

gvlax avatar Jan 05 '23 13:01 gvlax

oh wow, ok thanks - i'll see if there's something nvm can do to protect against it. it should already be using -q tho, which ignores the curlrc.

ljharb avatar Jan 05 '23 19:01 ljharb

@gvlax i can't reproduce this - nvm seems to completely ignore curlrc via the -q option. Do you have curl aliased?

ljharb avatar Jan 05 '23 23:01 ljharb

No, no aliased. Sorry, probably I was wrong regarding the guilty setting in the ~/.curlrc config file, it must have been caused by another one.

Anyway, I have just restored the ~/.curlrc file using the content of

https://github.com/sebastienrousseau/dotfiles/blob/master/lib/configurations/curl/curlrc

and the error has occurred again!

Here is an example console output w/ and w/o the ~/.curlrc file:

 ~ $ ls .curlrc
.curlrc
 ~ $ rm -rf ${NVM_DIR}/.cache
 ~ $ nvm i 18
Downloading and installing node v18.13.0...
Downloading https://nodejs.org/dist/v18.13.0/node-v18.13.0-darwin-arm64.tar.xz...
############################################################################################################################################################ 100.0%
Computing checksum with sha256sum
Checksums do not match: '5a96ae3e1586845dad4483e541bf4a112fd187be52f92473a7f44da10de57945' found, '15210e2672040f375f7804ed1e665d67e2026e5160125358e4187d32f71bac62' expected.
tar: Error opening archive: Unrecognized archive format
nvm_install_binary_extract:40: no matches found: /Users/maciejgulak/.nvm/.cache/bin/node-v18.13.0-darwin-arm64/files/*
Binary download failed, trying source.
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Downloading https://nodejs.org/dist/v18.13.0/node-v18.13.0.tar.xz...
############################################################################################################################################################ 100.0%
Computing checksum with sha256sum
Checksums do not match: 'ff5d981cd5435beefd96ee323ffc2f92313f1c1e239c54f9cac8860e245e67c5' found, 'fd4ac562e01d172896e3a959bd59552dbf647331c90d726f8d3471683dd3da68' expected.
tar: Error opening archive: Unrecognized archive format
nvm: install v18.13.0 failed!
 ~ $
 ~ $ rm .curlrc
 ~ $ rm -rf ${NVM_DIR}/.cache
 ~ $
 ~ $ nvm i 18
Downloading and installing node v18.13.0...
Downloading https://nodejs.org/dist/v18.13.0/node-v18.13.0-darwin-arm64.tar.xz...
############################################################################################################################################################ 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v18.13.0 (npm v8.19.3)
 ~ $

gvlax avatar Jan 07 '23 14:01 gvlax

Wait, I don't have a ~/.curlrc config file and I'm stillseeing an install issue

$ nvm i 14                                                                                                                                                                                                                                                                                          [14:30:06]
Downloading https://nodejs.org/dist/v14.21.2/node-v14.21.2-darwin-arm64.tar.xz...

Checksums empty
tar: Error opening archive: Unrecognized archive format
Binary download failed, trying source.

Checksums empty
tar: Error opening archive: Unrecognized archive format
Binary download failed, trying source.
Installing node v1.0 and greater from source is not currently supported
FAIL

How was this solved?

Huckleberry-Carignan avatar Feb 10 '23 19:02 Huckleberry-Carignan

@Huckleberry-Carignan you may want to file a new issue, after ensuring you're on the latest version of nvm.

ljharb avatar Feb 10 '23 20:02 ljharb