I've been using VSCode as my primary code editor for a long time, but recently I've been doing more and more working on code that will run on remote machines. The whole edit, rsync, edit cycle ws getting a little boring so I finally looked at using the remote extensions.

I added the Remote-SSH extension, added the first host (a RaspberryPi)  I needed and suddenly I was editing the code directly on that machine. Simples! Why didn't I do this before? :-)

The second host proved a problem as it was running FreeBSD. Looking around for a solution I soon found this post which mentions the feature request. Frankly, it doesn't look like it will happen anytime soon, so time to look at plan B, code-server from coder.com.

FreeBSD isn't supported, but after looking at the install script it seemed that the "fallback" NPM installed solution should work. The script needs a few tweaks, but with them it should be able to install the server via npm. Of course, first we need a working npm...

The www/npm port advises not to install it and given how joined at the hip node and npm are, I simply decided to try and build from source. The current stable version was 12.18 and I simply downloaded it from https://nodejs.org/en/download/

To configure and build I needed to use

$ CXX=c++ CC=cc ./configure
$ make -j4

I needed to install the devel/libuv port/package, but once complete the configure/build proceeded without issue. Once complete,

$ sudo make install
$ node -v    
$ npm -v

So far, so good. Now to modify the install.sh script. The patch is very simple :-)

$ git diff
diff --git a/install.sh b/install.sh
index 64bac20..8c500c3 100755
--- a/install.sh
+++ b/install.sh
@@ -360,6 +360,9 @@ os() {
     echo macos
+  FreeBSD)
+    echo freebsd
+    ;;
Add FreeBSD support for an npm based install by zathras777 · Pull Request #1802 · cdr/code-server
With this small change code-server can be installed via npm on a FreeBSD amd64 install.

Once the changes were made, I ran the script and waited for the install to complete. There were a couple of minor issues around missing packages or headers, so I also needed to install the following ports/packages,

  • devel/libsecret
  • x11/libxkbcommon

Once the install completed, it was as simple as

$ code-server
info  Using config file ~/.config/code-server/config.yaml
info  Using user-data-dir ~/.local/share/code-server
info  code-server 3.4.1 48f7c2724827e526eeaa6c2c151c520f48a61259
info  HTTP server listening on
info      - Using password from ~/.config/code-server/config.yaml
info      - To disable use `--auth none`
info    - Not serving HTTPS

The final steps are to tinker with the settings and enable it to run by default.

It may not be as simple to use as the Microsoft provided remote-ssh plugin, but it does give me the ability to edit the code in a familiar environment :-)