Vscode: Snap: Failed to read user shell environment

Created on 10 Apr 2019  路  17Comments  路  Source: microsoft/vscode


  • VSCode Version: 1.34.0-insider 56f1b4795fed05677eb82a21dac4fc1ab62d747b x64
  • OS Version: Ubuntu 18.04.2 LTS x86_64

Steps to Reproduce:

  1. Install VSCode as a snap
  2. Install JSHint
  3. Install dbaeumer.jshint


Does this issue occur when all extensions are disabled?: N/A

I also reported it in https://github.com/Microsoft/vscode-jshint/issues/71, but it's probably unrelated to the extension itself.

bug linux snap upstream verified workbench-os-integration

Most helpful comment

Fixed by #80585

cc @alexr00

All 17 comments

@dbaeumer What can the user do to figure out what's wrong?

@RMacfarlane took that over. We might want to consider changing the publisher

If there anything in the JSHint output panel?

Even after selecting F1 JSHint : Show Output, the Output tab is empty. All I got is the error message.

Failed to load jshint library. Please install jshint in your workspace folder using npm install jshint or globally using npm install -g jshint and then press Retry.

image

@NatoBoram do you have jshint itself installed? Your workspace doesn't have a node_modules folder.

Also, can you reproduce with VS Code without Snap? https://update.code.visualstudio.com/latest/linux-x64/insider

@dbaeumer JSHint was installed globally. The workspace isn't a NodeJS project.

jshint --version
jshint v2.10.2

@joaomoreno
No. The .deb works fine.

@NatoBoram does it work if you install jshint locally?

Yes, it works when installed locally.

@NatoBoram Do you use NVM? If you open the Developer Tools and run getLazyEnv().then(console.log), do you get the expected environment?

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

Reopening.

@joaomoreno and I looked into this and the problem seems to be that the environment is not correctly sourced when running out of a snap which makes the server fail looking up global node moddules.

Also faced this issue. the problem is with gnome launcher .desktop file. it does not run ~/.bashrc or any other shell environment file. running code from terminal inherits the environment and works just fine.
Fixed it temporarily by editing /var/lib/snapd/desktop/applications/code_code.desktop and changing the Exec line from:
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/code_code.desktop /snap/bin/code %U
to:
Exec=bash -c "source $HOME/.bashrc && env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/code_code.desktop /snap/bin/code %U"

I have a similar issue but the above does not fix it.
If I add VSCode as a favorite from the UBUNTU dash and then click VSCode icon on the sidebar none of my scripts work in VSCode script explorer. I get npm not found.
If I start VSCode within a terminal everything works.

I should have said "none of my npm scripts work

Fixed by #80585

cc @alexr00

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trstringer picture trstringer  路  3Comments

lukehoban picture lukehoban  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments

curtw picture curtw  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments