phoihos / wsl2-vscode

How to setup Linux Native VS Code on WSL2 Ubuntu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wsl2-vscode

How to setup Linux Native VS Code on WSL2 Ubuntu

Install VS Code with Snap

ref : https://code.visualstudio.com/docs/setup/linux

  1. Install X-Server for GUI Rendering

    • Configurations
      • Configure Launch Setting
        1. Windows Firewall & network protection -> Allow VcXsrv on Domain / Public / Private checked
        2. Launch VcXsrv with "Disable access control" checked
      • Configure ~/.bashrc
        echo "export DISPLAY='$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0'" >> ~/.bashrc
        echo "export LIBGL_ALWAYS_INDIRECT=1" >> ~/.bashrc
  2. Install Snap for VS Code Installation

  3. Install VS Code

    sudo snap install --classic code # or code-insiders

Run VS Code

snap run code
# and type y <Enter> to pass the prompt

If you run code command with out snap run, it'll be launch The Windows Native VS Code.

Using Settings Sync (Built in VS Code)

ref : https://code.visualstudio.com/docs/editor/settings-sync

  1. Install GNOME Keyring for Settings Sync

    • Configurations
      • Configure ~/.bashrc
        echo "eval $(/usr/bin/gnome-keyring-daemon --start --components=gpg,pkcs11,secrets,ssh)" >> ~/.bashrc
        echo "export SSH_AUTH_SOCK" >> ~/.bashrc
        echo "dbus-update-activation-environment --systemd DISPLAY" >> ~/.bashrc
    • Optional
      • If you want to use GUI-Tool, install seahorse too
  2. Install Firefox for Settings Sync

~/.bashrc

bashrc

About

How to setup Linux Native VS Code on WSL2 Ubuntu

License:MIT License