This procedure was tested on FreeBSD-CURRENT build from d8819d88af52.
-
Enable linuxulator and install linux userland:
# sysrc linux_enable="YES" # service linux start # pkg install linux_base-c7Test it:
$ /compat/linux/usr/bin/uname -a Linux monster-1 4.4.0 FreeBSD 14.0-CURRENT #1 main-n254392-d8819d88af52: Wed Apr 6 22 x86_64 x86_64 x86_64 GNU/LinuxFor more details on linuxulator setup please refer to handbook.
-
remote-ssh seem to ignore bash config files so we need to change
$PATHin/etc/login.confor send custom env withSetEnvdirective inssh_config. Choose which fits you better.By default it's class
default, we need to give priority to linux binaries::path=/compat/linux/usr/sbin /compat/linux/usr/bin /sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin ~/bin:\rebuild CAP database:cap_mkdb /etc/login.confHost your-freebsd.box SetEnv PATH="/compat/linux/usr/sbin:/compat/linux/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" -
Set you normal PATH for your every day use in your shell's config file (.bashrc od .zshrc, etc)
-
Connect to your FreeBSD box with VScode's remote SSH extension!
Ok so it seems that since the latest VS Code update (1.86.0) the glibc version in the CentOS-7 based in
linux_base-c7is finally too old to run thevscode-server. However, I found out how to achieve the same thing using Linux emulation +debootstrap. Note, that I am using FreeBSD 14.0 and Debian bookworm emulation. From my understanding Linux emulation gained some additional capabilities in FreeBSD 14 and it may well be that you have to use an older Debian/Ubuntu version on FreeBSD 13.Steps:
Install
debootstrappackage:# pkg install debootstrapEnable linux emulation and change the emulation path:
The last settings can also be persisted, if desired:
# echo "compat.linux.emul_path=/compat/debian" >> /etc/sysctl.confInstall Debian bookworm (or any other distro, adjust paths as necessary):
# debootstrap bookworm /compat/debianAt this point it should be possible to
chrootinto the emulated Linux distribution (just for testing):But trying to directly execute
bash(which we need for runningvscode-serverwhile also being able to access the remote host system) might * fail with an error like this:* I think I have tried with some Ubuntu version where this worked out of the box.
Fix this by repairing the incorrect symlink [1]:
Finally,
vscode-serverwants to useawkduring installation but can't resolve the symlink in the emulated Debian for some reason, so I added another symlink:# ln -s /compat/debian/usr/bin/mawk ../usr/local/bin/awkAt this point, the remaining steps are the same as before. I basically use the following
.ssh/configentry to connect via VS Code: