Stream: t-compiler/wg-rls-2.0

Topic: VSCode installation error


mre (Jan 06 2020 at 10:30, on Zulip):

Hi,
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. code and cargo are in my path, but I don't think that's relevant.

Inside /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 npm@6.13.4
npm info using node@v12.14.0
npm verb run-script [ 'prepackage', 'package', 'postpackage' ]
npm info lifecycle ra-lsp@0.0.1~prepackage: ra-lsp@0.0.1
npm info lifecycle ra-lsp@0.0.1~package: ra-lsp@0.0.1
npm info lifecycle ra-lsp@0.0.1~package: ignored because ignore-scripts is set to true ra-lsp@0.0.1
npm info lifecycle ra-lsp@0.0.1~postpackage: ra-lsp@0.0.1
npm verb exit [ 0, true ]
npm timing npm Completed in 108ms
npm info ok

but it doesn't create the .vsix file.
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.
E.g. running 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.

matklad (Jan 06 2020 at 10:34, on Zulip):

Hm..... My guess is that:

mre (Jan 06 2020 at 10:44, on Zulip):

Same result:

./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)
mre (Jan 06 2020 at 10:46, on Zulip):

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 ra-lsp@0.0.1: 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)
matklad (Jan 06 2020 at 10:47, on Zulip):

Second hypothesis: vsce picks the wrong rollup (see vsce:preblushin in package.json)

mre (Jan 06 2020 at 10:48, on Zulip):

Shouldn't then the yarn build also fail?

matklad (Jan 06 2020 at 10:49, on Zulip):

I can see how yarn and npm might pick different binaries

matklad (Jan 06 2020 at 10:50, on Zulip):

To clarify, we do install rollup as a dev-dependency, and it's version is pinned, so tools should pick up that

matklad (Jan 06 2020 at 10:50, on Zulip):

But we already had a bug where npm picked a global binary withotu a special flag

matklad (Jan 06 2020 at 10:51, on Zulip):

Actually, it might be the same exact bug in vsce? It doesn't set --scripts-prepend-node-path which leaks global env?

mre (Jan 06 2020 at 10:56, on Zulip):

Hum...
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
└── npm@6.13.4
yarn global list
yarn global v1.21.1
✨  Done in 0.06s.
matklad (Jan 06 2020 at 10:58, on Zulip):

Hm...

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 rollup -c

mre (Jan 06 2020 at 11:02, on Zulip):
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 ra-lsp@0.0.1: 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```
mre (Jan 06 2020 at 11:02, on Zulip):

Looks like npm swallows the error.

mre (Jan 06 2020 at 11:08, on Zulip):

Well, there is this is in the verbose output: npm info lifecycle ra-lsp@0.0.1~vscode:prepublish: ignored because ignore-scripts is set to true ra-lsp@0.0.1

mre (Jan 06 2020 at 11:10, on Zulip):

After running npm config set ignore-scripts false I get the same output now.

matklad (Jan 06 2020 at 11:11, on Zulip):

Hm, yeah, our installation will not work with --ignore-scripts

mre (Jan 06 2020 at 11:12, on Zulip):

No clue why it was set, to be honest. :laughing:

matklad (Jan 06 2020 at 11:12, on Zulip):

Is there a way to make npm fail with --ignore-scripts? Quietly ignoring it and producing a pacakge without javascript is not a very helpful behavior :-)

mre (Jan 06 2020 at 11:17, on Zulip):

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 true.

mre (Jan 06 2020 at 15:42, on Zulip):

Could create an issue to follow up that discussion if you like. Anyway, thanks for helping me out here. :)

Last update: Jun 04 2020 at 17:50UTC