Sdk: can use dotnet in command but cannot be located in vscode on mac os

Created on 14 Jul 2016  Â·  22Comments  Â·  Source: dotnet/sdk

image

sorry my english is not good.so i upload a pic to show my probleam.
the point is .i update to the new .net core sdk.
i add to the PATH .and i can use
dotnet new
dotnet restore
dotnet run
in the command.
but when i open the project in vscode.
the cli tools cannot be located error happen.

Environment data

dotnet --info output:
bash-3.2$ dotnet --info
.NET Command Line Tools (1.0.0-preview3-003180)

Product Information:
Version: 1.0.0-preview3-003180
Commit SHA-1 hash: d4193cd5c1

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.11
OS Platform: Darwin
RID: osx.10.11-x64
bash-3.2$ dotnet run
Project hello (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
Hello World!

Console

//Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:88 The .NET CLI tools cannot be located. .NET Core debugging will not be enabled. Make sure .NET CLI tools are installed and are on the path.e.doShow @ //Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:88

I tried above .but not solved.
use command+P.and enter >Download .Net core Debugger
likes nothing hanppen . the console also have no error message.

Append

image
i can use dotnet restore in command.
but when i use Command+p and enter >dotnet restore
then "/bin/sh"

image

image

Most helpful comment

Try closing vscode completely and then restarting it. If you updated the CLI tools while vscode was open, vscode likely _did not_ load the updated $PATH environment variable.

All 22 comments

Try closing vscode completely and then restarting it. If you updated the CLI tools while vscode was open, vscode likely _did not_ load the updated $PATH environment variable.

@tonyferreira i restart my pc. but /bin/sh:dotnet command not found error not solved.
and i upload another pic to show that.

@yuzd I just tried it but I exited VS Code with Cmd-Q (or Code -> Quit VS Code from the menu bar). After restarting VS Code it actually worked. Can you try that?

@blackdwarf
thanks for comment。
I tried that.but failed.
my vs code can not use dotnet command.so i tried this:

➜ ~ which dotnet
/usr/local/bin/dotnet

i copy the dotnet file from [/usr/local/bin/dotnet] to the project folder.
then debugger working.

image

but when start debugger.
then show me to enter pc password.does vs code have no permissions for dotnet cli command?
image

image

but this was not expected.
how to let vs code read dotnet cli command Automatic ?

What is the version of the SDK you have installed? You can find this out by running dotnet --version from the terminal.

Thanks,
Z

Sent from my tricorder

On Mon, Jul 18, 2016 at 5:40 PM -0700, "鱼东东" <[email protected]notifications@github.com> wrote:

@blackdwarfhttps://github.com/blackdwarf
thanks for comment。
I tried that.but failed.
my vs code can not use dotnet command.so i tried this:

? ~ which dotnet
/usr/local/bin/dotnet

i copy the dotnet file from [/usr/local/bin/dotnet] to the project folder.
then debugger working.

[image]https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fcloud.githubusercontent.com%2fassets%2f16083659%2f16934723%2fb01ff0c4-4d8b-11e6-9662-c143d77e9222.png&data=01%7c01%7cZlatko.Knezevic%40microsoft.com%7c2f28adb66a7b4d71ced708d3af6d36f1%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=a7MZfVayhoJv0KS3pnfVIc%2fUqS2ZmGjFLJSPI5X%2fIqU%3d

but this was not expected.
i need help.

―
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/dotnet/cli/issues/3858#issuecomment-233499994, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AC-H_Acu4gBkycZ4weLXo8MmEbk5Tfexks5qXBzcgaJpZM4JL8SB.

@blackdwarf
➜ ~ which dotnet
/usr/local/bin/dotnet
➜ ~ dotnet --version
1.0.0-preview3-003180

Thanks for helping!

The same issue for me with 1.0.0-preview2-003121 on Mac OSX

I've installed nvm much earlier than dotnet

I read this issue from the OmniSharp repository, so I tried by removing the nvm related scripts from my profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc), this workaround is working in my case

The same issue for me on Win7

dotnet --version

Product Information:            
 Version:     1.0.0-beta-001598 
 Commit Sha:  7582649f88        

Runtime Environment:            
 OS Name:     Windows           
 OS Version:  6.1.7601          
 OS Platform: Windows           
 Runtime Id:  win7-x64          

vscode version

1.3.1

@DustinCampbell

cc @gregg-miskelly as well

@Tobyee you have a very old version of the dotnet tools. Can you please install the latest and see if it repros again?

@leonplata
thank you very mush.
I removed the nvm from the ~/.zshrc .
then solved!

But i can not use node command .do you have any idea for that?

@blackdwarf
The problem solved, see

https://github.com/OmniSharp/omnisharp-vscode/issues/627#issuecomment-235816230

This issue is still happening with the latest version of Visual Studio Code on macOS.

@bandrei If you are only seeing this problem in VS Code (not a terminal window), the problem is likely to be that you have something configured with your shell that break's VS Code's ability to scrape environment variables. There are troubleshooting steps in https://github.com/Microsoft/vscode/issues/21655 that you may find useful.

I would've thought that might be the case, however whenever I run env I do see the path to dotnet being set correctly to /usr/local/share/dotnet. I opened another issue with the Azure Functions Extension because I think that's where the problem is (i.e. it doesn't know where on the path to look for the SDK)

ok, so the omnisharp server is starting correctly after running dotnet restore from VSCode. I guess that's needed to install the project depdencies locally. However the missing .NET cli error is still there.

further tracked it down to

> Executing task: dotnet clean <

/bin/bash: dotnet: command not found
The terminal process terminated with exit code: 127

Terminal will be reused by tasks, press any key to close it.

It does look like the task execution is not picking up the environemnt variables

Ok, I have absolutely no idea what happened (it might have been my empty dev.env) file that messed up the path after omnisharp started working, however I restarted and updated VSCode and things are working now.

@bandrei check your ~/.bash_profile and comment out items one by one. In my case, the problem was caused after I added export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"

I'm still having this issue on osx...

I had to symlink for the task to work... ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/

I had the same problem (/bin/bash -c 'dotnet build ... -c DebugMacOS' works in command line shell, but VS Code gets 'failed to launch (exit code: 127).'

and I fixed it by launching VS Code from a Terminal shell where dotnet is visible.

$ open /Applications/Visual\ Studio\ Code.app

I wonder if wherever VS Code is updating $PATH, is not used in the context when VS Code is launched from the Mac GUI shell.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

noelitoa picture noelitoa  Â·  3Comments

moozzyk picture moozzyk  Â·  3Comments

aguacongas picture aguacongas  Â·  3Comments

davkean picture davkean  Â·  3Comments

gkhanna79 picture gkhanna79  Â·  3Comments