ulauncher-vscode-projects icon indicating copy to clipboard operation
ulauncher-vscode-projects copied to clipboard

Difference launching VS Code from ulauncher as opposed to manually

Open CumpsD opened this issue 4 years ago • 10 comments

For some reason, when I launch a project using this, it seems it cannot find dotnet and I am getting errors like:

It was not possible to find any installed .NET Core SDKs
Cannot start .NET Core language services because `dotnet` was not found. Consider: 
* setting the `FSharp.dotnetRoot` settings key to a directory with a `dotnet` binary, 
* including `dotnet` in your PATH, 
* installing .NET Core into one of the default locations, or 
* using the `net` `FSharp.fsacRuntime` to use mono instead

When I manually open VS Code and select the project through the extension side bar, all is fine.

I dont know enough Python, but could it be that this is losing some PATH vars along the way: https://github.com/brpaz/ulauncher-vscode-projects/blob/master/main.py#L88

To be clear, dotnet is on my PATH in my normal shell :)

What can I provide to help debug this?

CumpsD avatar May 02 '20 23:05 CumpsD

I also experience this issue, I've found out that my $PYTHONPATH has /usr/lib/python3/dist-packages added when opening via the ulauncher in the terminal. It makes the extension unusable as it conflicts with my virtual environment paths.

ilaif avatar May 10 '20 15:05 ilaif

@CumpsD Maybe adding shell=True argument on that subprocess call.

You could try change the code directly (~/.local/share/ulauncher/extensions/com.github.brpaz.ulauncher-vscode-projects/main.py and restart Ulauncher to see if it helps.

brpaz avatar May 29 '20 17:05 brpaz

The same thing happens with Node "Can not find npm on PATH" when I open vscode using this extension, but everything works if I open vscode normally

joekaiser avatar Oct 31 '20 21:10 joekaiser

@joekaiser I cannot reproduce this in my machine. I thought it could be related to the command not being run in a shell environment and so the environment variables wouldn't be available, I tried adding "shell=True" to the command and now it opens VSCode but not the project directory, so it´s not the solution.

Can you try the following:

  1. Open a terminal and run python
  2. It will open Python console. Then run the following commands. Press enter after each one and replace it with your project path.
import subprocess
subprocess.run(['code', '<path/to/your/project'])
  1. Check if the project is opened and if you have any errors.

Also, how did you install NodeJS? Did you use NVM or something?

brpaz avatar Nov 15 '20 15:11 brpaz

Yes, I used nvm.

I'll try that later today and edit this comment with the results.


@brpaz Opening the project this way works. No errors are reported and npm is found in PATH

joekaiser avatar Nov 15 '20 16:11 joekaiser

ok, that´s exactly the same command executed by this extension to launch code.

Something related to the execution envrionment of Ulauncher extensions maybe? I really dont have any idea for now.

brpaz avatar Nov 15 '20 18:11 brpaz

I use subprocess.Popen() with shell=True but this also doesn't seem to solve the PATH problem however it allows VS Code to open the project correctly. at least that's what i experienced during testing.

Kazumasan avatar Mar 12 '21 20:03 Kazumasan

This other extension has the same issue https://github.com/Kazumasan/ulauncher-sessions/issues/2

The author and I determined it is how the Application Launcher runs ulauncher. If I kill the process and start it via the terminal then everything works great.

Just thought you might want to know. Go look at the linked issue on how to fix this. It isn't a bug with this extension.

joekaiser avatar Mar 14 '21 14:03 joekaiser

man you're fast :)

dirty/quickfix might be to prevent your Application launcher to launch Ulauncer and insted do so through your shell profile as Ulauncher should then recive the full environment.

Kazumasan avatar Mar 14 '21 14:03 Kazumasan

I was able to patch this issue by overriding the code path to a custom script which unsets the problematic envvars.

Something like:

#! /usr/bin/zsh

unset PYTHONPATH && /usr/bin/code $@

Then change the code path to that script like:

image

nolanbconaway avatar Jan 17 '24 19:01 nolanbconaway