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

Dotnet is not found under default PATH #1259

Closed
NinoFloris opened this issue Feb 22, 2017 · 14 comments
Closed

Dotnet is not found under default PATH #1259

NinoFloris opened this issue Feb 22, 2017 · 14 comments

Comments

@NinoFloris
Copy link

NinoFloris commented Feb 22, 2017

Environment data

dotnet --info output:
.NET Command Line Tools (1.0.0-rc4-004849)

Product Information:
Version: 1.0.0-rc4-004849
Commit SHA-1 hash: 7dcefb5076

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/1.0.0-rc4-004849
VS Code version: 1.10.0-insider
C# Extension version: 1.7.0

Steps to reproduce

Dotnet is not found under default path folders.

This results in .net cli errors from the c# extension and a failure to debug/restore and build, omnisharp works fine though.

Tested with cli from dot.net, rc3 and latest bits on a clean Sierra installation.

Installer correctly installs path into /etc/paths.d but this is not picked up by the extension (failed to run path_helper?).

The PATH in the integrated terminal is completely fine but looking at dev tools in vscode and running process.env gives the default PATH of: PATH: "/usr/bin:/bin:/usr/sbin:/sbin" where dotnet of course cannot be found.

Running code from the terminal where it gets populated with a bigger path does have the desired effect but is cumbersome and a roundabout way to solving this.

@NinoFloris NinoFloris changed the title Dotnet is not found under default path folders Dotnet is not found under default PATH Feb 22, 2017
@gregg-miskelly
Copy link
Contributor

@NinoFloris this isn't really an issue with the extension -- for things to work somehow dotnet needs to be on the PATH that the extension runs under. We have had a few folks report similar problems before. Look at #555 (skip the first few entries as that was back when we tried to interpret the PATH ourselves) for some of the things that have worked for others.

@NinoFloris
Copy link
Author

NinoFloris commented Feb 23, 2017 via email

@gregg-miskelly
Copy link
Contributor

@NinoFloris for all the clean install MacOS boxes we have, whatever the .NET CLI is doing to add itself to PATH, it shows up in the PATH for VS Code. So I think you must have some sort of configuration nob set that causes this. Though what that is I have no idea.

If you have a tasks.json entry that spawns dotnet to build. Do you run into the same problem?

If VS Code is already somehow using path_helper but it isn't getting used by the extension, then we can certainly fix it. But otherwise we will at least need a VS Code side fix. I am afraid I don't know all that much about this area.

@NinoFloris
Copy link
Author

Sadly the same is true for tasks yes. I have no clue why vscode only has the default path entries loaded and the terminal has all of the PATHS (which I know requires some gymnastics for vscode to populate with a full PATH, as I had an older issue for an issue about that)

@gregg-miskelly
Copy link
Contributor

@dbaeumer @chrisdias @blackdwarf do any of you know enough about PATH handling on MacOS to comment on if VS Code should somehow be using path_helper to ensure that paths added in /etc/paths.d (I am assuming this is where the .NET CLI adds itself at least) are in the PATH environment variable for tasks.json tasks?

If this isn't a bug, any guess as to why this isn't happening for @NinoFloris automatically?

@blackdwarf
Copy link

blackdwarf commented Feb 28, 2017

@gregg-miskelly the path_helper gets called for new login shells, I believe, by default. In general, the path_helper is not supposed to be run by GUI apps. This is guidance, I don't know if anything untoward would happen if you do since it reads the etc/paths.d/ entries and constructs the default $PATH and $MANPATH from it.

@NinoFloris
Copy link
Author

NinoFloris commented Feb 28, 2017

How do you discover dotnet then?
Let me rephrase, what techniques are currently used by this extension's dotnet restore command to find the dotnet binary?

If it's just start a vscode child process dotnet args: restore then it's obvious that it can't work with the default PATH that osx gives to apps launched through launchd. (as that's just PATH: "/usr/bin:/bin:/usr/sbin:/sbin")

EDIT:
Yes path_helper is really not much more than something that reads etc/paths.d/* and etc/path so you can source its output.

And yes as seen in commands.ts there is just a spawn with env: process.env which cannot work if the vscode PATH is the default launchd PATH, dotnet is only found under /usr/local/share which is not a default PATH entry

@NinoFloris
Copy link
Author

But it starts to look like this is a vscode wide issue as tasks for instance exhibit the same problems.
Something must have changed related to PATH handling on OSX in recent releases.

@blackdwarf
Copy link

@NinoFloris are you using Sierra?

I don't understand the question about restore, though. Do you mean to say that VS Code can run dotnet restore and that is the only command that works?

@NinoFloris
Copy link
Author

Yes

About dotnet restore, you are relying on the shell to expand this dotnet command via env (PATH) to an existing path right? Well if you take the vscode process env which is set to launchd defaults, as launchd spawned it you will never be able to execute dotnet as it is not found in those paths

@NinoFloris
Copy link
Author

NinoFloris commented Feb 28, 2017

which is what I get on all commands involving dotnet

install

Finished
Failed to spawn 'dotnet --info'

restore

ERROR: Error: spawn dotnet ENOENT
Done: -2.

@gregg-miskelly
Copy link
Contributor

RE: How do you discover dotnet then?
As I said, for most folks, PATH automatically gets passed so this 'just works'.

@NinoFloris
Copy link
Author

NinoFloris commented Mar 1, 2017

Okay found it, it was again exactly the same problem

microsoft/vscode#8434

Seems like something broke the fix as fish with powerline breaks the hacky PATH importer again

@gregg-miskelly
Copy link
Contributor

Closing this issue since the root problem is a VS Code issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants