How can I fix the "segmentation fault" error in Visual Studio Code's terminal? - visual-studio-code

On Windows 10, I have Visual Studio Code installed.
When I open the terminal (Git Bash) and type less-watch-compiler, I get the error:
Segmentation fault
But if I go to the Git Bash terminal itself (outside Visual Studio Code) and type less-watch-compiler, the command works.
How can I fix this problem?
I reinstalled Git for Windows, but it didn't help.
I have the latest version of Visual Studio Code (1.36.1)
When I use the "cmd" editor within Visual Studio Code, it works fine as well.

Not sure if it's the same problem but I was also getting segmentation fault errors running VSCode with WSL.
What fixed it for me was:
rm -rf ~/.vscode-server
The next time I tried the command, VScode downloaded the necessary files and everything worked again.

Related

Terminal doesn't work in Visual Studio Code

When I open my visual studio code my terminal is blank, neither ubuntu, nor command prompt, nor powershell, nor JavaScript debugger work.
I tried to change the path by which vs code calls my ubuntu but it didn't work.

Visual studio code command doesn't work on WSL 2

For some reason, when I type the command code . from a WSL terminal I have the message:
Command is only available in WSL or inside a Visual Studio Code terminal.
After some research, I tried to fix it with the following commands:
rm -r ~/.vscode-server
code .
It redownloads VS Code Server and it works correctly but just for one terminal instance. When I open a new terminal, I still have the message :
Command is only available in WSL or inside a Visual Studio Code terminal.
I don't have the issue when I use the command code in a VS code terminal.

VS Code opened via VS Developer Command Prompt not recognizing 'cl'

As the title says, VS Code is not recognizing cl compiler although opened via Visual Studio 2022 Developer Command Prompt:
VS Code terminal:
I have tried using VS Code external terminal with %comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
which did not work.
Setting the comspec manualy in the terminal did solve the issue for the terminal instance:
But the C++ extension is still complaining about cl.exe:
cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt for VS.
I have never used VS Code for C++ before and I don't use windows for development at all so go easy on me.
What could be the reason for the issue and how it can be solved?
Visual Studio Developer Command Prompt must be elevated(run as Administrator) in order to correctly open VS Code with the needed permissions.
Running Visual Studio Developer Command Prompt as Admin solves the issue.
One solution that worked for me is to go directly in the setting for C++ extension and find compiler path setting, and manually set it to cl.exe path on your computer.

Visual Studio Code not running/working on WSL 2

Somehow when I run code . inside the WSL, it simply doesn't do anything. If I which code it does return the VS Code path on windows, but still nothing happens.
Well, after some research, what really fixed the issue for me was the following:
Within the WSL terminal, type rm -r ~/.vscode-server to delete the VS Code WSL server.
Exit the terminal and from your PowerShell/Cmd, run wsl --shutdown.
Then you can log in back to your WSL and run code . and it should work normally.
I solved it following this post with slight modifications.
exit all instaces of wsl
From the power shell run wsl --shutdown
Start VS Code on Windows
Open a previously saved project which uses wsl (this is the difference)
Open wsl and run code . starts VS Code for me
Note: the issue appeared for me after upgrading to wsl2

VS Code doesn't add command line on path permanently on Mac

I am using VS code 1.8.1 on Mac 10.12.3 (16D32). After launch vscode, I run cmd shift p to open command search field. Then run Install code command in Path. I can see the code got added on PATH but it got removed after I close vs code. Is there a way to add it permanently?
So I've just had this issue during setup of a new laptop and found a simple (but slightly embarrassing) solution that worked for me. After faffing about with it for way too long I noticed I had left it in Downloads. I moved the .app file to /Applications and ran the command-line install function again and now the "code" command persists.
Add this to your ~/.bash_profile
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
source: https://code.visualstudio.com/docs/setup/mac
I am assuming you've checked this link.
VSCode application generally resides in /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code.
Follow these steps to access VSCode through code on shell.
Open bash_profile page
sudo vi /etc/paths
Add an extra line in the list of PATH folders as
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/
Exit from vi: Esc > :wq! > Enter Key
Restart shell. Then do echo $PATH to confirm VSCode has been added successfully.
Check code command is added by typing which code. You should see VSCode path printed on screen.
Try this link if it doesn't work out.
Edit: I am using version 1.9.1 and after I ran Install code command in Path it got added permanently.
Visual Studio Code
rm /usr/local/bin/code
ln -s "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code
Visual Studio Code - Insiders
rm /usr/local/bin/code-insiders
ln -s "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code" /usr/local/bin/code-insiders
For Big Sur:
From the official docs:
Note: Since zsh became the default shell in macOS Catalina, run the
following commands to add VS Code to your path:
cat << EOF >> ~/.zprofile
# Add Visual Studio Code (code) export PATH="\$PATH:/Applications/Visual Studio
Code.app/Contents/Resources/app/bin" EOF
I did this and it worked for me.
I am running Visual Studio Code - Insiders 1.23.0 on a Mac/Mac OS 10.10.5 Yosemite. I added the "Shell Command: Install 'code-insiders' command in PATH" from within VSC - Insiders. From the terminal in any directory I just add 'code-insiders .' and it launches in VSC - Insiders without issue.
Hope that helps.
For me, the problem was that Visual Studio Code.app was not in the Applications folder, but rather in the Downloads folder. Moving it there and re-running the add to path command fixed it for me.