Developing in Lima with Visual Studio Code

Kadir Islow | Jun 6, 2022 min read

Lima

After discovering Lima (a Linux subsystem for macOS), Docker Desktop was the first thing to go and replaced with Docker in Lima. While I won’t get into how to set up Lima in this post, if you are interested in trying out Lima, I can recommend the following links:

Developing in Lima

Having started developing on my guest OS, I was hesitant to use vim only. As a result, I began looking for a way to use VSCode with Lima, which ultimately brought me to needing access to my guest files.

To begin with, let’s start our instance:

$ limactl start ubuntu

You can run the following command and check the status of your instance to make sure it’s running:

$ limactl list
> NAME     | STATUS    |  SSH            | ARCH    | CPUS   | MEMORY  | DISK    | DIR </p>
> ubuntu   | Running   |  127.0.0.1:2222 | x86_64  |   4    |  4GiB   | 30GiB   |  /Users/kislow/.lima/ubuntu

Having installed all the necessary tools on my ubuntu instance, we can now create a test project that can be accessed through VS Code.

$ mkdir hello
$ cd hello
$ touch hello.go
$ go mod init example/hello
$ cat <<EOF>> hello.go
package mainimport "fmt"func main() {
    fmt.Println("Hello, world!")
}
EOF

Prepare the remote ssh access

Step 1: Add the configuration of our instance to the hosts’ ~/.ssh/config file:

$ limactl show-ssh --format config colima >> ~/.ssh/config

Next, we need to retrieve the hostname of the instance:

$ limactl shell ubuntu hostname
lima-ubuntu

Now verify, ssh access from host to guest stance using the hostname only:

ssh lima-ubuntu

Setup VSCode remote access

Install Remote-SSH extention

Go to settings and enable Remote Server Listen on Socket

Connect to the ssh host. You can use the hostname without ssh (e.g. lima-ubuntu)

We now have the ability to use Visual Studio Code with Lima