Toolbox and Visual Studio Code Remote Containers

One of the main sticking points in using Silverblue and/or Toolbox for development has been IDEs.

The choices come down to:

  • Builder in a Flatpak: great integration, small community
  • Anything else in your homedir: poor integration into updates, system UI, etc.
  • Anything else in a Flatpak - isolated from system, can only use Flatpak SDK extensions

A few years ago I was playing around with toolboxd, which was a pretty complicated attempt to provide seamless IDE/Toolbox integration. It sort of worked, but getting it to 100% would have required extensive IDE modification.

Last week, I decided to look into what it would be required to use the Remote Containers extension for Visual Studio Code with Toolbox. People (particularly Laércio de Sousa) have already done good work to figure out the necessary configuration to make it work. But how do you make it usable? For the related Remote WSL extension, Microsoft injects a code cli command into the WSL environment and I decided to try something similar for Toolbox.

What I came up with was a visual-studio code wrapper script, which you can put into ~/.local/bin/code and have available in any Toolbox. When you run code MyProject it does a bunch of work to set up the configuration for the current toolbox and then internally runs some command line like:

flatpak-spawn --host flatpak run com.visualstudio.Code --remote attached-container+6665646f72612d746f6f6c626f782d3333 /var/home/otaylor/Source/MyProject

At which point VIsual Studio Code will, if necessary, prompt to install the Remote Containers extension, then load your project, nicely hooked up inside the Toolbox where you ran ‘code .’ You can have different projects in different toolboxes - one Fedora 33, one Fedora 34, one RHEL, or whatever.

The good: it’s slick from the CLI, most extensions should just work.

The bad: poor integration into the Visual Studio Code GUI

The ugly: The Remote Containers extension is closed-source and only works with the closed-source-bits included “offical builds” of VSCode

You can find my script at:

Let me know how it works for you - there’s a lot of different workarounds packed in, so lots of potential for things to go astray!

Regards,

Owen

2 Likes