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

[BUG] Extension don't add package to PATH variable, when some active tabs need any package from shell.nix #66

Open
Wittano opened this issue Dec 28, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Wittano
Copy link

Wittano commented Dec 28, 2021

Weird situation. First time run extension, I selected my configured shell.nix file, extension loaded packages, everything works. Second time, extension didn't load my packages and LSP throws exception, because package didn't add to PATH. But when I close every tabs, that use any package from shell.nix, extension will load packages, add to PATH and everything back to normal.

I found this bug for GoLang project. You can generate simple golang project and add to your shell.nix LSP for golang.

@Wittano Wittano added the bug Something isn't working label Dec 28, 2021
@AleksanderGondek
Copy link

Thank you for taking time to report this, I thought I had been going crazy.

@Wittano Wittano changed the title Extension don't add package to PATH, when some active tabs need any package [BUG] Extension don't add package to PATH, when some active tabs need any package May 23, 2022
@Wittano Wittano changed the title [BUG] Extension don't add package to PATH, when some active tabs need any package [BUG] Extension don't add package to PATH variable, when some active tabs need any package from shell.nix May 23, 2022
@rectcircle
Copy link

I also encountered the same problem.

I read the source code of this extension. I think this is an underlying flaw of this extension, related to the VSCode extension activation order.

In order to start fast enough, VSCode does not provide an API to define the order of extension activation.

Therefore, in some cases, other extensions will start before this extension completes env/set-current-env.

(env/set-current-env))

Taking the Go extension as an example, if I don't open the go source file, it will work fine, the extension host output is:

2023-03-04 17:50:41.355 [info] ExtensionService#_doActivateExtension arrterian.nix-env-selector, startup: false, activationEvent: '*'
2023-03-04 17:50:41.355 [info] ExtensionService#_doActivateExtension mutantdino.resourcemonitor, startup: false, activationEvent: '*'
2023-03-04 17:50:41.356 [info] ExtensionService#_doActivateExtension vscode.extension-editing, startup: false, activationEvent: 'onLanguage:markdown'
2023-03-04 17:50:41.356 [info] ExtensionService#_doActivateExtension vscode.markdown-language-features, startup: false, activationEvent: 'onLanguage:markdown'
2023-03-04 17:50:41.356 [info] ExtensionService#_doActivateExtension DavidAnson.vscode-markdownlint, startup: false, activationEvent: 'onLanguage:markdown'
2023-03-04 17:50:42.638 [info] ExtensionService#_doActivateExtension vscode.git, startup: false, activationEvent: '*'
2023-03-04 17:50:42.638 [info] ExtensionService#_doActivateExtension vscode.github, startup: false, activationEvent: '*'
2023-03-04 17:50:42.816 [info] ExtensionService#_doActivateExtension vscode.markdown-math, startup: false, activationEvent: 'api', root cause: vscode.markdown-language-features
2023-03-04 17:50:42.972 [info] ExtensionService#_doActivateExtension golang.go, startup: true, activationEvent: 'workspaceContains:*.go,*/*.go,*/*/*.go'

If I open the Go source file, the Go extension will report an error, and the extension host output is:

2023-03-04 17:49:58.989 [info] ExtensionService#_doActivateExtension arrterian.nix-env-selector, startup: false, activationEvent: '*'
2023-03-04 17:49:58.989 [info] ExtensionService#_doActivateExtension mutantdino.resourcemonitor, startup: false, activationEvent: '*'
2023-03-04 17:49:58.989 [info] ExtensionService#_doActivateExtension golang.go, startup: false, activationEvent: 'onLanguage:go'

Therefore, I think the implementation of this extension can only completely solve this problem by modifying the user's shell profile to inject environment variables such as PATH. For example ~/.bashrc

if [ $VSCODE_RESOLVING_ENVIRONMENT ]; then
  # source ....
fi

@rectcircle
Copy link

microsoft/vscode#152806

@opeik
Copy link

opeik commented Mar 8, 2023

I don't think anything can be done without modifying VSCode. Trying to fix it on the extension side ends up being hacky and buggy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants