How to install VSCode in a Toolbox on Fedora Silverblue
June 30, 2024•520 words
Context
This guide explains how to install Visual Studio Code on Fedora Silverblue using Toolbox, and how to create desktop shortcuts for the GNOME application overview.
Under the hood, toolbox is a Fedora-native CLI tool to manage Podman containers. This guide describes how to install VSCode into Fedora Silverblue using this tool, and also create the necessary desktop shortcut for GNOME's app overview.
Installing Visual Studio Code in a Toolbox
- Open a terminal
Create a Toolbox container
Note: If you'd like to name this container to be something else, rename it with the Podman CLI after following these instructions to the end!
toolbox create vscode-containerEnter the container
toolbox enter vscode-containerDownload the Visual Studio Code RPM package
wget https://update.code.visualstudio.com/latest/linux-rpm-x64/stable -O code-latest-x64.rpmInstall the Visual Studio Code RPM package
sudo dnf install ./code-latest-x64.rpm rm ./code-latest-x64.rpm
Creating the Desktop shortcut
Enter the container
toolbox enter vscode-containerCopy the VSCode desktop shortcut to your shared home directory
cp /usr/share/applications/code.desktop ~/.local/share/applications/code.desktop cp /usr/share/applications/code-url-handler.desktop ~/.local/share/applications/code-url-handler.desktopUpdate the executable path in both
.desktopfilessed -i 's|Exec=/usr/share/code/code|Exec=toolbox run -c vscode-container code|g' code.desktop sed -i 's|Exec=/usr/share/code/code|Exec=toolbox run -c vscode-container code|g' code-url-handler.desktopThe scripts above do a text replacement with
sedto update the executable path fromExec=/usr/share/code/codewithExec=toolbox run -c vscode-container code.Download the icon pack from the official Visual Studio Code branding site and copy the icon to the
~/.local/share/iconsdirectoryNote: This is needed since the icon is not included with the RPM.
wget https://code.visualstudio.com/assets/branding/visual-studio-code-icons.zip unzip visual-studio-code-icons.zip cp ./visual-studio-code-icons/code.svg ~/.local/share/icons/code.svg rm -r ./visual-studio-code-iconsThe
Icon=line on the desktop shortcut will find this new icon based on its name.
(Recommended) Install a Web Browser inside the container
VSCode often requires opening a web browser to do various things like authentication or viewing documentation. Installing a web browser into the container will allow those actions to work instead of failing silently.
Here are some well-maintained options to choose from:
GNOME Web (Epiphany) is a lightweight option native to GNOME, and fits well in Fedora Silverblue.
sudo dnf install epiphanyQutebrowser is a lightweight option for those that prefer keyboard navigation.
sudo dnf install qutebrowserFirefox is the standard browser in most Linux distributions.
sudo dnf install firefox
Tips
Interact with the container directly through Podman for troubleshooting: If you make a mistake or want to alter the container after initializing (such as rename it or update it), you can also use the Podman CLI to interact with the containers directly.
Update your desktop shortcuts if you rename your container: If you rename your container, make sure to also rename the
Exec=line in the desktop shortcuts files as well so that the shortcuts do not break. To do this, altering thesedscript should also make this process relatively easy.
References
- Toolbox documentation: https://containertoolbx.org/
- Podman commands documentation: https://docs.podman.io/en/latest/Commands.html
- Visual Studio Code Linux installation documentation: https://code.visualstudio.com/docs/setup/linux