I've installed vscode on my ubuntu and I'm trying to run it with root privileges.
I understand there is a problem with this version and root privileges.
I use this command from my terminal:
sudo code /my_fils --user-data-dir='.' --no-sandbox
but when running it vscode opens a blank and white screen with super-user definition on top but with nothing else.
I know there was a problem with this configuration and I found this issue in this link :
https://code.visualstudio.com/updates/v1_59#_progress-for-electron-sandbox-support
I've tried the following but the outcome is the same:
sudo chown root /chrome-sandbox
sudo chmod 4755 /chrome-sandbox
running vscode without the root privilege works.
I'm using ubuntu 20.04 and my vscode version is 1.70.2
is there a workaround for it?
thanks !!
Yes, this seems to be an issue try 1.65.x it might run. encountered the same when installing a fluent theme.
Checkout : https://github.com/microsoft/vscode/issues/146847
On macOS Big Sur, I installed MacPorts and installed bash using it. I set my default shell to the MacPorts version of bash /opt/local/bin/bash by using chsh.
All was well.
I decided I would rather use Homebrew. I uninstalled MacPorts, installed Homebrew, installed bash via homebrew, and set my default shell to /opt/homebrew/bin/bash via chsh.
All was well, except when I am first starting vscode (from Finder) which reports:
Unable to resolve your shell environment: A system error occurred (spawn /opt/local/bin/bash ENOENT)
This is a totally reasonable complaint, since that binary no longer exists. It makes this complaint when launched from Finder, but not when launched from the terminal. There is no reference to this prior version of bash in my user settings.json file, nor is it in my .bashrc.
Where the heck could vscode be getting this path to bash from?!
Edit (2021-10-11): there is something strange going on here. If I open an integrated terminal in vscode:
$ echo $SHELL
/opt/local/bin/bash
$ ls -lh $SHELL
ls: /opt/local/bin/bash: No such file or directory
$ ps -p $$
PID TTY TIME CMD
45388 ttys001 0:00.12 /bin/bash -l
(there are no such problems in the regular macOS Terminal app)
Edit again (2021-10-12):
I tried resetting vscode (via rm -rf ~/Library/Application\ Support/Code).
I tried resetting vscode's cache (via rm -rf ~/Library/Caches/com.microsoft.*),
I downloaded iTerm2 and ran it; it loaded the correct shell (/opt/homebrew/bin/bash) without issue (tried this in hopes of determining if there was some other setting in macOS pointing at the old macports version of bash).
Had the same issue and was able to resolve this by changing the shell for the logged in user (using chsh -s, cf. the hint at the bottom of https://github.com/microsoft/vscode/issues/139867). As this change is not being picked up by VSCode in your currently logged in session, don't forget to explicitly log out and log back in again after performing this step.
I can add the "shell command install 'code' command". Testing it works, but if i close out of the VS Code or after a couple of hours of adding the command it doesn't work. Terminal says "zsh: command not found: code" and on VS when click on the "shell command install code command" has a "EACCES: permission denied, unlink 'usr/local/bin/code' " pop up. How should i go about this? I'm using a macbook 2020 if that matters
Uninstall the code command from PATH in VS Code and reinstall it.
Open the command palette in VS Code using cmd + shift + p. Search "uninstall 'code'" and select the first option to uninstall.
Once uninstalled, "install 'code'" for installing.
That should fix it.
This happened to me on Macbook Pro M1 Chip. Basically follow this:
Simply uninstall the code command from PATH in vscode and reinstalled. i.e open the command pallete, search "uninstall 'code'" and select the first option to uninstall. Do same for installing too. That should fix it.
Found this solution on github
Try run:
sudo chown -R yourUsername /usr/local/bin
This command solves user just for copy paste.
sudo chown -R $USER /usr/local/bin
From a sample size of me and three friends, this is a common problem on M1 MacBooks and Mac Minis. Running the command:
sudo chown -R yourUsername /usr/local/bin
This resolved the VS issue for me and allowed me to install npm packages globally.
For Mac I have run below steps in my terminal and it resolve my issue.
you can also Try:
Open terminal.
sudo chown -R your_user_name /usr/local/bin
Open visual studio code.
use keybord command + shift + p
Type the bellow command.
install 'code'
Vs Code
For test go to terminal and run code .
I've run into this a few times on before. Steps I took to that fixed it for me:
open vs code and press cmd + shift + p to open the command palette
search for uninstall 'code' and press Enter
lastly, search for install 'code' and press Enter
For macOS:
Try uninstalling and reinstalling. (command + shift + p) >shell Command: Uninstall 'code' command from Path
append the following to your ~/.bash_profile file (~/.zshrc in case you use zsh).
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
I was getting same error to Install on Windows 11:
Just deleted folder C:\Users\my-username\AppData\Local\Programs\Microsoft VS Code\bin
Also removed VS Code from environment variables
Installed successfully!
for any mac users, you can try
sudo rm -f /usr/local/bin/code
That should help. It's important to note that you should be careful using sudo, since you can do a lot of damage in files and folders with it. But in the most dire instances, you should use it, similar to using any kind of --force commands, you should not use it often.
I edit my code inside tomcat root folder. So I need VSCode to run in mode. I used to write sudo code --user-data-dir and VSCode happily started in root mode. However I do not know what exactly happened yesterday and vscode doesn't simply respond. It doesn't start at all and neither is their any error message. Please help. Noob here
Update : I just figured it out. Apparently there has been an update somewhere and now you need to run sudo code --user-data-dir --no-sandbox
i recommend to use alias to run code --user-data-dir="portable-vscode"
for example
echo "alias vscode='code --user-data-dir="portable-vscode" --no-sandbox --extension-dir portable-vscode/" >> /etc/bash.bashrc
Hey bro open the terminal and type sudo code
When I tried to open vscode in WSL bash on Ubuntu 20.04 using command code ., it failed and the following message was logged:
/mnt/c/Users/john/.vscode/extensions/ms-vscode-remote.remote-wsl-0.50.1/scripts/wslCode.sh: 57: /home/john/.vscode-server/bin/d2e414d9e4239a252d1ab117bd7067f125afd80a/bin/code: not found
I would like to ask how to fix this problem? Thx a lot!
I found the solution. Even though I think that you've already know it.
You need to delete the folder /home/john/.vscode-server/ with sudo rm -rf /home/john/.vscode-server.
Then, you just run code . or try to open any project that you want it.
Then a script will load and will install a new .vscode-server in your machine with the right files.