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

can use dotnet in command but cannot be located in vscode on mac os #6631

Closed
yuzd opened this issue Jul 13, 2016 · 27 comments
Closed

can use dotnet in command but cannot be located in vscode on mac os #6631

yuzd opened this issue Jul 13, 2016 · 27 comments

Comments

@yuzd
Copy link

yuzd commented Jul 13, 2016

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: d4193cd

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

@tonyferreira
Copy link

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.

@yuzd
Copy link
Author

yuzd commented Jul 15, 2016

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

@blackdwarf
Copy link

@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?

@yuzd
Copy link
Author

yuzd commented Jul 19, 2016

@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 ?

@blackdwarf
Copy link

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]mailto:[email protected]> 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.

@yuzd
Copy link
Author

yuzd commented Jul 21, 2016

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

Thanks for helping!

@leonplata-old
Copy link

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

@tobyee
Copy link

tobyee commented Jul 27, 2016

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

@TheRealPiotrP
Copy link
Contributor

@DustinCampbell

@DustinCampbell
Copy link
Member

cc @gregg-miskelly as well

@blackdwarf
Copy link

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

@yuzd
Copy link
Author

yuzd commented Jul 28, 2016

@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?

@tobyee
Copy link

tobyee commented Jul 28, 2016

@blackdwarf
The problem solved, see

dotnet/vscode-csharp#627 (comment)

@yuzd yuzd closed this as completed Aug 1, 2016
@bandrei
Copy link

bandrei commented Jul 9, 2018

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

@gregg-miskelly
Copy link

@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 microsoft/vscode#21655 that you may find useful.

@bandrei
Copy link

bandrei commented Jul 10, 2018

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)

@bandrei
Copy link

bandrei commented Jul 10, 2018

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.

@bandrei
Copy link

bandrei commented Jul 10, 2018

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

@bandrei
Copy link

bandrei commented Jul 10, 2018

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.

@Miggleness
Copy link

Miggleness commented Jul 19, 2018

@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"

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@steveoh
Copy link

steveoh commented Apr 17, 2020

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/

@misterbeebee
Copy link

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.

@upzone
Copy link

upzone commented Jul 8, 2021

I fixed it by changing type from process to shell in the tasks.json

@MubarakSULAYMAN
Copy link

Kindly check this Grepper response, works well on Ubuntu 20.04.4 LTS also.

@gn-bcampbell
Copy link

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.

As silly as it is, this worked for me. My problem was I had other VS Code windows open so closing only the one causing the issue wasn't enough - all of them needed closed. Thank you!!

@seb9465
Copy link

seb9465 commented Mar 9, 2023

Using directly the command dotnet in my task file outputted me the zsh:1: command not found: dotnet error.
Changing dotnet to the absolute path /usr/local/share/dotnet/dotnet in my task file solved my issue.

@kaunglvlv
Copy link

@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?

This worked for me 🤷🏽‍♂️

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

No branches or pull requests