Microsoft Visual Studio Code Issues

Overview

Microsoft Visual Studio Code is software Microsoft makes available for free at https://code.visualstudio.com/Download.  While Microsoft generally fixes issues the crop up on Windows operating systems, they have very little incentive to patch issues the crop up on their competitors operating systems, this results in a variety of issues that are known, have workarounds posted, but have not had their underlying issues solved. As Microsoft does not fully support their own software, all support from ECI is best effort, especially if installed on non UC computers.

VS Code requires free quota, aka free space to write files, to work. If you are getting multiple error messages at one time or ssh via terminal works while VS code does not, the most likely culprit is being over quota: VS Code not being able to write the files it needs, and thus generating other errors.

See Solution 5 below or Why can't I login graphically? : Going over quota

VS Code normally requires either a wired campus internet connection or the VPN to connect to the CSIL and Honea computers.

If you have a weak or unstable connection, VS Code tries to compensate by using less secure methods to connect, several of which are explicitly blocked by the campus border firewalls.

Use the VPN to ensure a secure connection in all circumstances. If you visit https://next.noc.ucsb.edu/ip and do not see "On-campus address" you need to restart your VPN connection.

please see: VPN FAQ or Solution 8 below

If the below guide does not help you troubleshoot your issue and you need to contact ECI for additional support, please provide the following:

  1. Your CoE account username so we can look you up and make sure you are under quota
  2. The IP of the device you are remoting into our labs from: https://next.noc.ucsb.edu/ip to make sure you are connected to the VPN
  3. The Virtual Machine (VM) you are trying to remote to. Please note csil.cs.ucsb.edu is a load balancer, when you are assigned a VM, the VM name should appear in terminal so we can look at the logs and make sure there is no issue with the VM itself.
  4. Screenshot of the error message. for example: you will give a lot more information in vscode if you open output then select ssh-remote as the source with the below command than if you connect regularly.
    1. ssh your_CoE_username@csil.cs.ucsb.edu -verbose
  5. Acknowledgement you have read the below KB article

Problem 1

When accessing the software remotely from a Mac computer, certain keys do not work as intended. symptoms include pressing AltGr acts as Backspace, pressing C acts as ArrowLeft, or pressing e acts a delete, etc.

Solution 1

VS Code on Linux dispatches keybindings using scan codes to accommodate various keyboard layouts. This works well when sitting physically at the machine and the OS is the one creating keyboard events, but some virtualization / remote desktop software creates keyboard events with incorrect scan codes.

  1. go to file >> preferences>>settings

  2. search for "keyboard"

  3. click on "keyboard" (bottom one)

  4. use "keyboard.dispatch": "keyCode" in your settings instead of "Code"

  5. restart VS Code.

Problem 2

On a Mac or Linux computer, pressing key combinations results in no action. If solution 1 does not work, this might help

Solution 2

  1. go to file >> preferences>>keyboard shortcuts

  2. search for the action you want to the combination to call

  3. Right click on the listed combination and then click "remap"
  4. type the combination you want to use and then click enter

Problem 3

Microsoft Visual Studio Code is consuming a lot of CPU

Solution 3

High CPU consumption is often caused by an issue in an extension, especially if running remotely or from a non-windows environment. VS Code running multiple processes and extensions are executed by the Extension Host process.

Find out whether an extension is causing the high CPU load. You can open the Process Explorer using Help>Open Process Explorer to open a new window with a continuously updating list of VS Code processes.

Disable extensions one at a time to see if that extension is the one causing an issue

Problem 4

Microsoft Visual Studio Code is giving useless error messages

Solution 4

  • You can use a keyboard shortcut, Control+Shift+P on Windows or Command+Shift+P on MacOS to open the command palette.
  • type "show log"
  • you will see "Remote-SSH: Show Log" as an option. it opens the bottom pane to show the log while it's connecting. It is similar to running ssh with the -v option (verbose)
  • (Optional) In a normal terminal window type "quota your_username" where your_username is your CoE username. If you are over the space or file quota indicated by an * next to a number, VS will act weird.

Problem 5

Microsoft Visual Studio Code is not allowing a person to login to a remote computer, also known as a remote target after said remote computer has not been used for some time.

or

Microsoft Visual Studio Code is not allowing a person to login to a remote computer such a CSIL, but you are still able to login via ssh and terminal

Solution 5

This is actually multiple possible problems 1) saved credentials do not match current credentials or 2) saved computer does not match current computer or 3) unspecified other permissions issue, but since the VS error message can be the same as well as the solution, we are lumping them together. If its a type 3) situation, please see Solution 4 above or 4) you don't have quota space in your CoE home directory to write the files VS code needs to write.

"Host key verification failed" means that the host key of the remote host was changed. This happens after major changes such as when we reimage our computers every quarter.

VS code will stop you from connecting because it can also be a sign of spoofing, that the remote computer is not the one you think it is. So good security if you assume your remote computer never changes, which is a bad assumption in our case.

If you have a saved entry for csil.cs.ucsb.edu or linux.engr.ucsb.edu for example you may need to delete and readd said entry.

"invalid credentials" means that you changed your password and your current credentials do not match your saved credentials.

Once you clear credentials from the current instance, some extensions may prompt for authentication the next time you open VS Code. You can continue working in the current session.

"permission denied" can be either of the above as well as several other errors. e.g. your are using your ECE or UCSBnetID credentials on a CoE computer or vice versa. See Solution 4 above.

  • to clear ssh keys, also known as ssh targets, you can remove it on the SSH config file ~/.ssh/config where ~ is your home directory and exact path will vary person to person.
  • It is also a good idea to clear the ssh host key/target off ~/.ssh/known_hosts which is the file used by almost every other ssh program.
  • (Optional) Some extensions save credentials and need to be cleared as well.
    • On Windows: you can press windows key + r then type %USERPROFILE%\.%EXTENSION_NAME_HERE% where % indicates a variable and EXTENSION_NAME_HERE is your extension

    • On Linux and Mac OS: ~/.EXTENSION_NAME_HERE

    • For Ubuntu/GNOME Visual Studio Code users, the Credential Manager can be accessed by launching the "Passport and Keys" application. You can delete the Visual Studio Code/GitHub entry by clicking "Password", looking for the entry and delete

    • some extensions (no where near a complete list) are ~/.vscode-server for the default server, .sfdx for salesforce, .git or .github or .git-credentials for git/gitlab/github and assorted other repositories
    • In that directory you'll find a json file for each login saved, each one named after your username in that org. That json holds the following properties:

      • username
      • orgId
      • accessToken
      • refreshToken
      • instanceUrl
      • loginUrl
      • clientId

      You can delete the ones you don't need.

  • (Optional) Navigate to Code > Preferences > Settings > Workspace > Extensions > your_extension_name_here  to check whether the credentials and the instance URL have been deleted for all extensions

"over quota" means you have used up your quota, you allocation of space and files, and cannot write the files that VS code needs to write to in order to login. In most cases you will still be able to connect via ssh and terminal. Solution is the same as Solution 4 above.

#To see your current quota: 
quota -s USERNAME

#To see your 10 biggest files:
top10

#To see the size of a specific directory such as .cache
du -sh example_directory
du -sh .cache

#Misconfigured VS code logs set to never delete anything is a common cause of quota issues
#To clear your cache
clearcache

Solution 5 (Long Term Mitigation)

VS Code Logs, general cache, and intellisense (a.k.a. cpp tools) cache all can grow exponentially depending on your settings. RAM and CPU usage can also grow exponentially. Setting hard limits in settings is generally a good idea. One user reported that with no limits set, their caches grew at 45 GB per hour until it completely filled their hard drive and crashed their computer.


MacOS: File > Preferences (Code > Preferences or Code > Settings on macOS) > Settings.

PC: in VSCode --> Ctrl + SHIFT + P --> type: settings --> click: "Preferences: Open Settings (JSON)"


If you do not want to use the IntelliSense caching feature (such as to work around a bug that may only occur when the cache is enabled), you can disable the feature by setting the IntelliSense Cache Size setting to 0 (or "C_Cpp. intelliSenseCacheSize": 0" in the JSON settings editor.
You can increase/decrease the available RAM for VS Code on its Settings.value you want to look for is maxMemoryForLargeFilesMB and change the value for your desired maximum RAM
Logging can be set to none, directed to >/dev/null 2>&1 or a test file or set to a preset maximum size

External Sources of information

https://code.visualstudio.com/docs/getstarted/settings

https://github.com/microsoft/vscode/wiki

Problem 6

After being over quota, issues are still happening despite now being under quota.

Solution 6

Unfortunately when you hit the quota limit and can no longer write to files, things do not close neatly and can get corrupted.

You may need to delete the following in your CoE account:

  • .vscode
  • .vscode-server
  • .ICEauthority
  • .cache

You may also need to delete and re-add the following on your personal computer:

  • saved entry for csil.cs.ucsb.edu or linux.engr.ucsb.edu or whichever system is non accessible
  • saved account, username or passwords in vscode
  • vscode local cache


Rebooting is recommended. Many operating systems hold stuff in memory or cache and will not let go of changed files until you either reboot or force a recheck.


Problem 7


The "vscode-server" process, automatically used as part of the VSCode "SSH-Remote" extension to provide helper communication between the local VSCode client and the remote SSH server, may have a stuck file lock which can't be fixed locally. The causes are most likely an exceeded file quota which would cause file corruption problems with the vscode-server state/cache files on the remote, or a non-graceful sudden loss of connectivity to the remote server which could also cause corruption of the same files.

The evidence of this problem would show up in the VSCode terminal output, the key lines being "Acquiring lock" followed by "Installation already in progress...":

vscode-server file lock log
[20:56:40.619] Log Level: 2
[20:56:40.639] SSH Resolver called for "ssh-remote+csil.cs.ucsb.edu", attempt 1
[20:56:40.640] "remote.SSH.useLocalServer": false
[20:56:40.641] "remote.SSH.useExecServer": false
[20:56:40.641] "remote.SSH.showLoginTerminal": false
[20:56:40.642] "remote.SSH.remotePlatform": {}
[20:56:40.642] "remote.SSH.path": undefined
[20:56:40.642] "remote.SSH.configFile": undefined
[20:56:40.643] "remote.SSH.useFlock": true
[20:56:40.643] "remote.SSH.lockfilesInTmp": false
[20:56:40.643] "remote.SSH.localServerDownload": auto
[20:56:40.644] "remote.SSH.remoteServerListenOnSocket": false
[20:56:40.644] "remote.SSH.showLoginTerminal": false
[20:56:40.644] "remote.SSH.defaultExtensions": []
[20:56:40.645] "remote.SSH.loglevel": 2
[20:56:40.647] "remote.SSH.enableDynamicForwarding": true
[20:56:40.648] "remote.SSH.enableRemoteCommand": false
[20:56:40.648] "remote.SSH.serverPickPortsFromRange": {}
[20:56:40.648] "remote.SSH.serverInstallPath": {}
[20:56:40.655] VS Code version: 1.86.2
[20:56:40.656] Remote-SSH version: remote-ssh@0.109.2024021615
[20:56:40.656] win32 x64
[20:56:40.660] SSH Resolver called for host: csil.cs.ucsb.edu
[20:56:40.660] Setting up SSH remote "csil.cs.ucsb.edu"
[20:56:40.667] Using commit id "903b1e9d8990623e3d7da1df3d33db3e42d80eda" and quality "stable" for server
[20:56:40.673] Install and start server if needed
[20:56:44.459] Checking ssh with "C:\Program Files\Eclipse Adoptium\jdk-17.0.4.101-hotspot\bin\ssh.exe -V"
[20:56:44.462] Got error from ssh: spawn C:\Program Files\Eclipse Adoptium\jdk-17.0.4.101-hotspot\bin\ssh.exe ENOENT
[20:56:44.462] Checking ssh with "C:\Windows\system32\ssh.exe -V"
[20:56:44.464] Got error from ssh: spawn C:\Windows\system32\ssh.exe ENOENT
[20:56:44.464] Checking ssh with "C:\Windows\ssh.exe -V"
[20:56:44.466] Got error from ssh: spawn C:\Windows\ssh.exe ENOENT
[20:56:44.467] Checking ssh with "C:\Windows\System32\Wbem\ssh.exe -V"
[20:56:44.468] Got error from ssh: spawn C:\Windows\System32\Wbem\ssh.exe ENOENT
[20:56:44.468] Checking ssh with "C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[20:56:44.470] Got error from ssh: spawn C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[20:56:44.470] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V"
[20:56:44.528] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[20:56:44.535] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 16852 "csil.cs.ucsb.edu" bash
[20:56:44.540] Terminal shell path: C:\Windows\System32\cmd.exe
[20:56:45.291] > ]0;C:\Windows\System32\cmd.exe
[20:56:45.292] Got some output, clearing connection timeout
[20:56:45.565] > someuser@csil.cs.ucsb.edu's password: 
[20:56:45.566] Showing password prompt
[20:56:49.171] Got password response
[20:56:49.171] "install" wrote data to terminal: "**************"
[20:56:49.196] > 
[20:56:49.583] > 7b8709ba4652: running
[20:56:49.613] > Acquiring lock on /cs/student/someuser/.vscode-server/bin/903b1e9d8990623e3d7da
> 1df3d33db3e42d80eda/vscode-remote-lock.someuser.903b1e9d8990623e3d7da1df3d33db3
> e42d80eda
[20:56:49.622] > Installation already in progress...
> If you continue to see this message, you can try toggling the remote.SSH.useFloc
> k setting
> 7b8709ba4652: start
> exitCode==24==
> listeningOn====
> osReleaseId==fedora==
> arch==x86_64==
> vscodeArch==x64==
> bitness==64==
> tmpDir==/run/user/43085==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime====
> 7b8709ba4652: end
[20:56:49.623] Received install output: 
exitCode==24==
listeningOn====
osReleaseId==fedora==
arch==x86_64==
vscodeArch==x64==
bitness==64==
tmpDir==/run/user/43085==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime====
serverStartTime====


To be clear, don't follow the suggestion in the output to disable remote.SSH.useFlock in VSCode, that's not the correct solution. The file lock mechanism shouldn't be bypassed/disabled.

Solution 7

Before you address this, make sure your disk quota has not been exceeded. This issue would never resolve until there's free space.

See Solution 5 above or Why can't I login graphically? : Going over quota


Removing the old lock is the way to go. There are two ways:

Solution 7 (preferred): Use the VSCode client to clear the lock with a hidden command

In the VSCode window that's being used for remote SSH, press Ctrl+Shift+P (on PC) or ⇧⌘P (on MacOS), type the command

kill vs code server on host

and then choose the host from the drop-down.

The VSCode client may reload the active window, then it should ask for your credentials to the remote server. The client will then issue whatever required commands are needed on the remote host to clear the lock gracefully and minimize the possibility of losing any unsaved files in the session cache. 

Solution 7: Delete the vscode-server files on the remote system without care for the loss of any uncommitted files

This solution option could introduce other problems to work through, so do this as a last resort. If any files were open and modified (but not saved yet) using Remote-SSH, via regular terminal NOT VS Code, deleting the vscode-server's files manually could cause cached files open in the editor to be lost. That can't be predicted ahead of time, so just be aware.

First, back up the contents of ~/.vscode-server where ~ is the path to your home directory, before continuing by copying the directory such as:

cp -pr $HOME/.vscode-server $HOME/.vscode-server-backup

if you're worried about vitally important cached information being lost, the files may be retrievable manually. The next step will delete the cache entirely and irretrievably.

The server process binary and its associated files and cache usually are in the $HOME/.vscode-server/bin directory. Get rid of all the vscode-server files by running the following command on the remote server from an ordinary SSH terminal window:

rm -rf $HOME/.vscode-server

The next time the VSCode client is used to remotely connect, it should re-install the vscode-server files and provide a working session.

Problem 8

You previously were using UCSB Eduroam or UCSB Secure while using VSCode to connect to the CSIL and and Honea computers without using the VPN, VScode is now requiring the VPN.

ECI has no control over the Campus Border Firewalls, the Campus Unified Threat Management (UTM) software, Enterprise Technology Services, Campus Wifi or people's personal computers.

Solution 8

Basically if your computer is 100% up to date, has no sketchy software installed, is on a stable secure connection, and luck favors you, you can probably connect without without the VPN, that being said, since that depends on a variety of factors, the majority of which are outside of ECI control, best we can say is:

Use the VPN to ensure a secure connection in all circumstances. If you visit https://next.noc.ucsb.edu/ip and do not see "On-campus address" you need to restart your VPN connection.
Latest Version of the Campus Ivanti VPN can be downloaded from: https://www.it.ucsb.edu/ivanti-secure-access-campus-vpn/get-connected-campus-vpn

please see: VPN FAQ for more details about the VPN

there are a couple of reasons why the Campus Border Firewalls or the Campus Unified Threat Management (UTM) may block you, but the generally fall into one of a few categories.

Insecure connection:

If you have a weak or unstable connection, VS Code tries to compensate by using less secure methods to connect, several of which are explicitly blocked by the campus border firewalls.

Given wifi will vary from location to location and device to device we cannot guarantee any connection made by wifi will be stable.

Additionally there are multiple forms of wifi at UCSB, wireless web, mainly used for guest access, is unencrypted and thus considered insecure by default.

Solution: try to get as stable and secure a connection as possible and configure VScode not to use less secure methods. or USE THE VPN to encrypt your connection and turn an insecure connection into a secure one.

Insecure device:

There is a UC system wide policy that you essentially agree to when you use either the wired or wireless networks on campus. This applies to everyone and all devices, regardless of if they are personally owned or not:

https://security.ucop.edu/policies/security-controls-everyone-all-devices.html

VScode out of the box does not have firewalls enabled, allows two way ssh without a password, meaning people can get into your personal laptop while you are trying to ssh to a remote computer, and has a whole host of other security issues.

We highly recommend you lock your computer down to require strong passwords, not allow inbound ssh connections via VScode, and have firewalls turned on preferably at the device level.

We also recommend do not have risky software installed, apply all OS and application updates as soon as possible, turn on automatic updates if possible and otherwise practice good security.

The more you look like a security risk to the Campus Border Firewalls or the Campus Unified Threat Management (UTM), the more likely you are to be blocked as a security risk.

Because the VPN requires you to sign in with both your UCSBnetID and DUO for MFA, it helps ensure that the person connecting is associated with UCSB  or at least gives the campus security people some contact info so they can contact you and ask you to secure your device.

USE THE VPN to lower your risk profile.

Active threat to other devices:

If a computer is far enough out of date, it becomes a risk not just to its user, but to other devices on its local network as bad actors can use it as a stepping stone to attack other devices.

Just because a computer was secure at the start does not mean it will remain secure, ALL OS that are no longer getting security updates have known security issues and vulnerabilities.

We have bad actors regularly scanning the entire internet looking for insecure devices.

For example, one recent test had a windows XP computer with a fresh install of the latest version of windows xp put online and within 10 minutes it was located and infected with multiple forms of malware.

If you have any form of Windows other than Windows 10 or 11, please update your OS to a version that is still getting security updates

https://support.microsoft.com/en-us/windows/get-the-latest-windows-update-7d20e88c-0568-483a-37bc-c3885390d212

If you have any form of MacOS other than Monterey, Ventura or Sonoma, please update your OS to a version that is still getting security updates

https://support.apple.com/en-us/108382

For Linux, supported OS are Ubuntu 20.04.6 LTS or higher, Fedora 38 or higher, and Centos 7 or higher

Ubuntu: https://ubuntu.com/tutorials/upgrading-ubuntu-desktop#1-before-you-start

Fedora: https://docs.fedoraproject.org/en-US/quick-docs/upgrading-fedora-new-release/

Centos: https://www.centos.org/centos-stream/

USE THE VPN to lower your risk profile in the short term, and AS SOON AS POSSIBLE, UPDATE YOUR COMPUTER

While Enterprise Technology Services does not immediately block unsupported OS, they want you to be able to connect to update your computer after all, their grace period is limited.

Apple has new OS every single year and security updates for supported OS every week, but only supports their last three operating systems.

A large number of Big Sur users started needing to use the VPN in late February 2024 because that was 90+ days after MacOS Sonoma was released and MacOS Big Sur stopped getting security updates.

External Sources of information:

https://code.visualstudio.com/docs/getstarted/settings

https://github.com/microsoft/vscode/wiki