Monday, April 29, 2024
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 15242  / 1 Year ago, sat, february 4, 2023, 2:01:48

I am very new to Linux and WSL overall. I was able to use code . to open my current directory in VSCode, but after deleting something that I do not remember it just doesn't work anymore. I put in the command and it just hangs there.


I have deleted my Ubuntu-20.04 instance and recreated it, but still it will not work. Also checked my $PATH and it seems to be there.


Also, the add shell command in VSCode does not come up, so I can't uninstall and reinstall the shell shortcut.


Anyone have any idea?


drewbie@drewbie:/$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/dotnet/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files (x86)/QuickTime/QTSystem/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Go/bin:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Users/Andrew/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files/heroku/bin:/mnt/c/Users/Andrew/AppData/Local/GitHubDesktop/bin:/mnt/c/Users/Andrew/go/bin:/snap/bin

After inputing code . it just sits there


whereis and which


drewbie@drewbie:~$ whereis code
code: /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin/code /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin/code.cmd
drewbie@drewbie:~$ which code
/mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin/code

After doing what @NotTheDr01ds said in the thread below


drewbie@drewbie:~$ vi "$(which code)"
drewbie@drewbie:~$ code .
+ [ = true ]
+ COMMIT=899d46d82c4c95423fb7e10e68eba52050e30ba3
+ APP_NAME=code
+ QUALITY=stable
+ NAME=Code
+ DATAFOLDER=.vscode
+ realpath /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin/code
+ dirname /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin/code
+ dirname /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin
+ VSCODE_PATH=/mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code
+ ELECTRON=/mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/Code.exe
+ IN_WSL=false
+ [ -n Ubuntu-20.04 ]
+ IN_WSL=true
+ [ true = true ]
+ export WSLENV=ELECTRON_RUN_AS_NODE/w:WT_SESSION::WT_PROFILE_ID
+ wslpath -m /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/resources/app/out/cli.js
+ CLI=C:/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/resources/app/out/cli.js
+ WSL_EXT_ID=ms-vscode-remote.remote-wsl
+ ELECTRON_RUN_AS_NODE=1 /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/Code.exe C:/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/resources/app/out/cli.js --ms-enable-electron-run-as-node --locate-extension ms-vscode-remote.remote-wsl

More From » command-line

 Answers
6

I think this issue was caused to me by an update of VSCode, which happened automatically.


To solve it:



  1. open VSCode in Windows



  2. open the Remote Explorer


    Remote Explorer



  3. click on a folder in a WSL target of interest: you'll see that this causes some re-installation



  4. now you can go back to using the $ code . command from a folder in WSL2, just like you used to




[#860] Sunday, February 5, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mocipe

Total Points: 161
Total Questions: 106
Total Answers: 118

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
;