Skip to content

On first getting started, cannot find dotnet without a relaunch #3461

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

Closed
JacksonKearl opened this issue Dec 17, 2019 · 6 comments
Closed

On first getting started, cannot find dotnet without a relaunch #3461

JacksonKearl opened this issue Dec 17, 2019 · 6 comments

Comments

@JacksonKearl
Copy link

image

When I'm first getting started with the extension and dotnet/C# in general, following https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio-code, I get these errors even after installing dotnet and ensuring it is in my path. Upon relaunching (not reloading) VSCode, I was able to proceed. It seems the extension is not able to find dotnet on my path if it was added during the session.

Environment data

dotnet --info output:
.NET Core SDK (reflecting any global.json):
Version: 3.1.100
Commit: cd82f021f4

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/3.1.100/

Host (useful for support):
Version: 3.1.0
Commit: 65f04fb6db

.NET Core SDKs installed:
3.1.100 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

VS Code version: 1.41
C# Extension version: 1.21.9

@JacksonKearl JacksonKearl changed the title Cannot find dotnet without a relaunch On first getting started, cannot find dotnet without a relaunch Dec 17, 2019
@gregg-miskelly
Copy link
Contributor

@JacksonKearl Correct. You will need to restart VS Code, this isn't really something this extension can do anything about - VS Code doesn't re-query the environment after the .NET Core installer adds it to the path.

Is there anything that we could in either docs or this extension to better let you know that you need to restart Code? I have wondered before if maybe that error message should link to a troubleshooting page that talked about this scenario.

@JacksonKearl
Copy link
Author

I am on the VS Code team, can you explain where you'd expect the environment to be re-queried that isn't happening? I would expect you'd be able to trigger a re-query of the environment on opening a C# file or attempting to run/debug.

@gregg-miskelly
Copy link
Contributor

gregg-miskelly commented Dec 17, 2019

First some background: there are lots of different tools that need to launch dotnet. They all search for it using the PATH environment variable. This extension doesn't try to do anything fancy to try and find it because that might fix it for this extension, but it wouldn't fix all the other stuff.

Now, if we wanted to support scenarios where the user installs a new SDK and it lights up in VS Code without a restart, we would need a new feature in VS Code to update the environment when it is modified by another installer (or the user). VS Code would need to monitor the various files that are used to modify the environment (if you are interested, we can find a .NET Core setup person to comment on how they do this to at least cover the ones they use) and re-query the environment when one of these files are modified and update all of the various VS Code processes. I think this is the code that VS Code uses to fetch the environment: getUnixShellEnvironment

@incredibleweirdo
Copy link

I see this each time the extension updates, with the Output for C# showing Failed to spawn 'dotnet --info, despite dotnet being in my path, and dotnet --info running successfully in the VS Code terminal.

Restarting VS Code resolves.
Below details where captured when the extension updated today, 12/19/2019.

C# log

Installing C# dependencies... Platform: darwin, x86_64

Downloading package 'OmniSharp for OSX' (44721 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'OmniSharp for OSX'

Downloading package '.NET Core Debugger (macOS / x64)' (51272 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package '.NET Core Debugger (macOS / x64)'

Downloading package 'Razor Language Server (macOS / x64)' (50263 KB).................... Done!
Installing package 'Razor Language Server (macOS / x64)'

Finished

Failed to spawn 'dotnet --info'

Environment information

VSCode version: 1.41.1
C# Extension: 1.21.9

Mono Information OmniSharp using global mono :6.4.0
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.13
OS Platform: Darwin
RID: osx.10.13-x64
Base Path: /usr/local/share/dotnet/sdk/3.0.100/

Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33

.NET Core SDKs installed:
2.1.4 [/usr/local/share/dotnet/sdk]
2.1.505 [/usr/local/share/dotnet/sdk]
2.1.802 [/usr/local/share/dotnet/sdk]
2.2.401 [/usr/local/share/dotnet/sdk]
2.2.402 [/usr/local/share/dotnet/sdk]
3.0.100 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
Angular2 johnpapa 8.3.0
autoimport steoates 1.5.3
aws-toolkit-vscode amazonwebservices 1.4.0
bootstrap-3-snippets wcwhitehead 0.1.0
bower donjayamanne 0.0.3
bracket-pair-colorizer CoenraadS 1.0.61
chat karigari 0.29.0
code-gnu-global austin 0.2.2
code-runner formulahendry 0.9.15
code-settings-sync Shan 3.4.3
cpptools ms-vscode 0.26.2
csharp ms-vscode 1.21.9
debugger-for-chrome msjsdiag 4.12.3
EditorConfig EditorConfig 0.14.4
fairyfloss nopjmp 0.0.6
git-project-manager felipecaputo 1.7.1
githistory donjayamanne 0.4.11
gitlens eamodio 10.2.0
Go ms-vscode 0.11.9
highlight-matching-tag vincaslt 0.9.6
hot-dog-stand somekittens 6.6.9
html-css-class-completion Zignd 1.19.0
indent-rainbow oderwat 7.4.0
LiveServer ritwickdey 5.6.1
markdown-preview-enhanced shd101wyy 0.5.0
material-icon-theme PKief 3.9.2
material-theme zhuangtongfa 3.2.1
minify HookyQR 0.4.3
mssql ms-mssql 1.8.0
night-owl sdras 1.1.3
npm-intellisense christian-kohler 1.3.0
path-intellisense christian-kohler 1.4.2
powershell ms-vscode 2019.12.0
prettier-vscode esbenp 3.17.0
quokka-vscode WallabyJs 1.0.267
remote-containers ms-vscode-remote 0.94.0
remote-ssh ms-vscode-remote 0.48.0
remote-ssh-edit ms-vscode-remote 0.48.0
remote-ssh-explorer ms-vscode-remote 0.48.0
remote-wsl ms-vscode-remote 0.41.6
rest-client humao 0.23.0
sqltools mtxr 0.21.5
trailing-spaces shardulm94 0.3.1
vim vscodevim 1.12.2
vsc-material-theme Equinusocio 30.0.0
vscode-arduino vsciot-vscode 0.2.28
vscode-color anseki 0.4.5
vscode-css-peek pranaygp 3.0.2
vscode-fileutils sleistner 3.0.0
vscode-import-cost wix 2.12.0
vscode-jasmine-test-adapter hbenl 1.6.2
vscode-markdownlint DavidAnson 0.33.0
vscode-npm-script eg2 0.3.10
vscode-peacock johnpapa 3.2.0
vscode-remote-extensionpack ms-vscode-remote 0.19.0
vscode-svgviewer cssho 2.0.0
vscode-test-explorer hbenl 2.15.0
vsliveshare ms-vsliveshare 1.0.1404
vsliveshare-audio ms-vsliveshare 0.1.80
vsliveshare-pack ms-vsliveshare 0.3.4
winteriscoming johnpapa 1.3.0
xml DotJoshJohnson 2.5.0

@JacksonKearl
Copy link
Author

@incredibleweirdo That sounds like a separate issue, consider filing a new one.

@gregg-miskelly
Copy link
Contributor

I am going to close this issue since it isn't really about this extension. Note that I am adding a help link to the error message that does mention this problem with #3507.

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