I wanted to install the latest version of rust analyzer for VSCode on macOS.
Did a fresh clone of the repo and ran
cargo xtask install.
Then something weird happened. The server compiles without a hitch, but the extension doesn't:
will run: npm --version 6.13.4 will run: npm install added 116 packages from 109 contributors and audited 201 packages in 2.732s 2 packages are looking for funding run `npm fund` for details found 0 vulnerabilities will run: npm run package --scripts-prepend-node-path will run: code --version 1.41.1 26076a4de974ead31f97692a0d32f90d735645c0 x64 will run: code --install-extension ./ra-lsp-0.0.1.vsix --force Installing extensions... ENOENT: no such file or directory, open '/private/tmp/rust-analyzer/editors/code/ra-lsp-0.0.1.vsix' Failed Installing Extensions: ./ra-lsp-0.0.1.vsix Error: install client Caused by: `code --install-extension ./ra-lsp-0.0.1.vsix --force` exited with exit code: 1
The file is indeed not there.
cargo are in my path, but I don't think that's relevant.
/editors/code, I tried the following:
npm run package --verbose npm info it worked if it ends with ok npm verb cli [ npm verb cli '/Users/mendler/.volta/tools/image/node/12.14.0/6.13.4/bin/node', npm verb cli '/Users/mendler/.volta/tools/image/node/12.14.0/6.13.4/bin/npm', npm verb cli 'run', npm verb cli 'package', npm verb cli '--verbose' npm verb cli ] npm info using email@example.com npm info using firstname.lastname@example.org npm verb run-script [ 'prepackage', 'package', 'postpackage' ] npm info lifecycle email@example.com~prepackage: firstname.lastname@example.org npm info lifecycle email@example.com~package: firstname.lastname@example.org npm info lifecycle email@example.com~package: ignored because ignore-scripts is set to true firstname.lastname@example.org npm info lifecycle email@example.com~postpackage: firstname.lastname@example.org npm verb exit [ 0, true ] npm timing npm Completed in 108ms npm info ok
but it doesn't create the
Then I tried vsce:
vsce package Executing prepublish script 'npm run vscode:prepublish'... DONE Packaged: /private/tmp/rust-analyzer/editors/code/ra-lsp-0.0.1.vsix (4 files, 13.69KB)
This creates the
.vsix, but it's suspiciously small and only contains 4 files:
unzip -l ra-lsp-0.0.1.vsix Archive: ra-lsp-0.0.1.vsix Length Date Time Name --------- ---------- ----- ---- 1751 01-06-2020 11:26 extension.vsixmanifest 245 01-06-2020 11:26 [Content_Types].xml 41101 01-06-2020 11:07 extension/package-lock.json 11740 01-06-2020 11:07 extension/package.json --------- ------- 54837 4 files
Installing this extension works, but the commands don't exist.
Rust Analyzer: Status gives me
command 'rust-analyzer.analyzerStatus' not found
The only thing I can think of is, that I'm using volta as a node version manager.
The node version gets correctly detected, however.
Maybe anyone has an idea what I'm doing wrong.
Hm..... My guess is that:
./node_modules/vsce/out/vsce package Executing prepublish script 'npm run vscode:prepublish'... DONE Packaged: /private/tmp/rust-analyzer/editors/code/ra-lsp-0.0.1.vsix (4 files, 13.69KB)
Huh, it works with yarn...
./node_modules/vsce/out/vsce package --yarn Executing prepublish script 'yarn run vscode:prepublish'... yarn run v1.21.1 $ rollup -c Done in 4.14s. warning email@example.com: The engine "vscode" appears to be invalid. src/main.ts → ./out/main.js... created ./out/main.js in 2.6s DONE Packaged: /private/tmp/rust-analyzer/editors/code/ra-lsp-0.0.1.vsix (5 files, 108.09KB)
vsce picks the wrong
vsce:preblushin in package.json)
Shouldn't then the yarn build also fail?
I can see how
npm might pick different binaries
To clarify, we do install
rollup as a dev-dependency, and it's version is pinned, so tools should pick up that
But we already had a bug where npm picked a global binary withotu a special flag
Actually, it might be the same exact bug in
vsce? It doesn't set
--scripts-prepend-node-path which leaks global env?
Don't have rollup installed globally, I guess.
npm list -g --depth=0 /Users/mendler/.volta/tools/image/node/12.14.0/6.13.4/lib └── firstname.lastname@example.org
yarn global list yarn global v1.21.1 ✨ Done in 0.06s.
But it seems like we still can narrow the problem down to just rollup, right? Ie, do
npm run vscode:prepublish and
yarn run vscode:prepublish differ? prepublish is just
rust-analyzer/editors/code on master is v0.0.1 via ⬢ v12.14.0 ❯❯❯ npm run vscode:prepublish rust-analyzer/editors/code on master is v0.0.1 via ⬢ v12.14.0 ❯❯❯ yarn run vscode:prepublish yarn run v1.21.1 warning email@example.com: The engine "vscode" appears to be invalid. $ rollup -c src/main.ts → ./out/main.js... created ./out/main.js in 2.4s ✨ Done in 3.00s. rust-analyzer/editors/code on master is v0.0.1 via ⬢ v12.14.0 took 3s ❯❯❯ rollup -c zsh: command not found: rollup```
Looks like npm swallows the error.
Well, there is this is in the verbose output:
npm info lifecycle firstname.lastname@example.org~vscode:prepublish: ignored because ignore-scripts is set to true email@example.com
npm config set ignore-scripts false I get the same output now.
Hm, yeah, our installation will not work with
No clue why it was set, to be honest. :laughing:
Is there a way to make
npm fail with
One thing that comes to mind is that we could check the return value of
npm config get ignore-scripts ourselves and print an error message if it's
Could create an issue to follow up that discussion if you like. Anyway, thanks for helping me out here. :)