Open dibarbet opened 3 weeks ago
Thank you @dibarbet
The solution I have tried from https://stackoverflow.com/a/79131320/2402577:
Confirm that the path to your .NET SDK is included in your PATH. Or on your VSCode settings.json you can setup it:
"terminal.integrated.env.osx": { "PATH": "/usr/local/share/dotnet:/usr/bin:/bin:/usr/sbin:/sbin" }
An altdernative is change for bash to zsh or your default shell,
"terminal.integrated.defaultProfile.osx": "zsh" // Or "bash" if you use Bash
But I am still having the same error. Looks like settings.json
is not considered or something is overwriting onto it.
@nagilson would you first scout? Also, is this something we will have covered in the PATH api switch?
The PATH API considers both bin/sh and bin/bash. Although it's not supporting SDK lookup initially, if we added it based on our current plans post our recent conversation on Friday, I would expect it to work here.
Sometimes vscode does not load the environment properly, but that may be based on the users settings. If the user sets the PATH in both bin/bash and bin/sh, then launching vscode through the terminal, Im curious to see if it works? Im also curious if it works if they set DOTNET_ROOT.
@nagilson I confirm that PATH in /bin/bash is set. /bin/sh reads from .profile I assume, that is set as well. Like /bin/sh in terminal see my PATH where /bin/sh in vscode does not.
Maybe dumb question - have you fully restarted VSCode? Not just closing the window but in the top left bar quit the entire application? IIRC there was an issue on Mac where changes to PATH or other environment variables wouldn't be seen until VSCode was quite entirely.
@dibarbet Yes sir I have restarted the VSCode, restarted to computer as well. /bin/sh in vscode only sees /usr/bin:/bin:/usr/sbin:/sbin
and does not see /usr/local/share/dotnet//dotnet
:-(
I was not able to figure out how can I update its PATH (seems like its the only solution) or somehow force vscode to use /bin/bash.
@avatar-lavventura Thank you for responding to us. Can you try this please? Within the vscode terminal:
node
(You may need node.js to be installed, if its not installed I'd recommend node 20, to enter the node terminal)
require('child_process').spawnSync('env', [''], { env : process.env, shell : '/bin/sh/' }).stdout.toString()
require('child_process').spawnSync('env', [''], { env : process.env, shell : '/bin/bash/' }).stdout.toString()
And share the result of the PATH from that output (denote privacy)
I am getting following error:
❯ node
Welcome to Node.js v20.9.0.
Type ".help" for more information.
> require('child_process').spawnSync('env', [''], { env : process.env, shell : '/bin/sh/' }).stdout.toString()
Uncaught TypeError: Cannot read properties of null (reading 'toString')
> require('child_process').spawnSync('env', [''], { env : process.env, shell : '/bin/bash/' }).stdout.toString()
Uncaught TypeError: Cannot read properties of null (reading 'toString')
Thank you. I am sorry but there wasn't supposed to be a / at the end 🤦
require('child_process').spawnSync('env', [''], { env : process.env, shell : '/bin/sh' }).stdout.toString()
require('child_process').spawnSync('env', [''], { env : process.env, shell : '/bin/bash/' }).stdout.toString()
This seems to work for me.
For both command I get following for PATH
and terimal in vscode is able to see dotnot process:
'PATH=/usr/local/share/dotnet/:/Users/alper/.pyenv/shims:/usr/local/Cellar/pyenv-virtualenv/1.2.4/shims:/usr/local/opt/make/libexec/gnubin:/usr/local/opt/imagemagick@6/bin:/usr/local/opt/curl/bin:/Users/alper/.npm-packages/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.0/bin:/Users/alper/venv/bin:/usr/local/sbin:/usr/local/lib/node_modules/bin:/usr/local/bin:/Users/alper/.cargo/bin:/Users/alper/venv/bin:/Users/alper/.local/bin/:/Users/alper/Downloads/camino/bin:/usr/local/opt/grep/libexec/gnubin:/Users/alper/bin/:/Users/alper/personalize/bin:/Users/alper/ebloc-broker/broker/eblocbroker:/Users/alper/ebloc-broker/broker/bash_scripts:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/Applications/VMware Fusion.app/Contents/Public:/Library/TeX/texbin:/Applications/Little Snitch.app/Contents/Components:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Users/alper/.cargo/bin:/snap/go/current/bin:/Users/alper/go/bin:/Users/alper/.gem/bin:/opt/ss:/usr/local/Cellar/ruby/3.2.2/bin:/Users/alper/.local/bin:/Users/alper/.local:/usr/local/opt/fzf/bin:/Users/alper/.local\n'
Thank you. That's the code that our new API does use to scan the PATH, so this increases my confidence that the change we are working on would fix this scenario. And interesting to see that node is working fine here. If it doesn't get fixed by our change then honestly I (us at MSFT) would take this to vscode and talk to them to see why is invoking this code in their context not getting the same result
Thank you sir. When would be the change will take the place? How can I update it?
Some parts still need to be implemented. Youd get the update automatically as long as you havent disabled automatic extension updates. But I imagine it will still be a few weeks out. In the meantime, I would try setting DOTNET_ROOT in your terminal and launching vscode from there to see if it helps. Otherwise, the OP would be the one who could provide a workaround.
Describe the Issue
Originally filed by @avatar-lavventura at https://github.com/dotnet/vscode-csharp/issues/7701
I have installed dotnet sdk inside MacBook and in my terminal
dotnet --info
returns valid information.But inside
Visual Studio Code
, I am getting following error message, when I try to run the project:How can I fix this error? Note that vscode tries to read
PATH
from/bin/sh
rather than/bin/bash
.Steps To Reproduce
No response
Expected Behavior
No response
Environment Information
No response