Installing VSCode extension on air-gapped machine?

I am starting out with Scala. I have Java and Scala installed. The machine is air-gapped, so I always need to download the zips/jars from another machine and then move them over.

Now I try to install the Scala/Metal extension for VSCode. I was able to install the extension itself from the .vsix file, but when the extension startups up, it complains with the following:

Failed to download Metals, make sure you have an internet connection, the Metals version ‘1.2.0+12-644090c2-SNAPSHOT’ is correct and the Java Home ‘/usr/lib/jvm/jdk-17-oracle-x64’ is valid. You can configure the Metals version and Java Home in the settings.

So Metals (and its dependencies) don’t seem to be part of the vsix file.

How do I get Metals on the air-gapped machine and where should I then put it?

1 Like

Welcome to the Scala community.
Not sure about this, but for some reason you are getting the latest snapshots (I couldn’t find a setting for it). Maybe uncheck this box? (Ctrl+, to open Settings, then type “Metals” and scroll down)
Screenshot from 2024-01-05 11-04-28

Maybe you can edit this setting manually to the version you downloaded?

Main developer Tomasz is fairly active on the Discord, you might want to try there: Scalameta I mentioned this over there.

There was a previous approach at the topic in though we weren’t exactly succesful.

What I would do currently:

  1. Install coursier on the airgapped machine, add it to PATH, so that Metals doesn’t try to download it.
  2. On another machine run also with coursier cs launch org.scalameta:metals_2.13:1.2.0 -M scala.meta.metals.DownloadDependencies
  3. Copy coursier cache to the airgapped machine.
  4. If there is anything missing you might need to fetch more artifacts (and possibly fix our DownloadDependencies utility)

This should work, but I never managed to take a stab at this setup. It’s pretty hard to make everything work as we usually need to download additional dependencies for Metals and the ones coming from the build tool.


In general Scala projects then to download a bunch of stuff. I do not recommend trying to run it on a machine that has not access to the internet.
Rather develop in another machine and then sent the final binary as an assembly jar to be run on that machine

1 Like

Thanks a lot for chiming in. Really appreciate all comments!

Great step-by-step guide! I will try it.

Good point. But I have to develop on the air-gapped machine. (Maybe I then better stick with Java. All the JARs we need there we have already locally.)

I have a totally different idea: Can I get at least some syntax highlighting in VS Code without Metals with a simpler non-LSP-based Scala plugin?

There’s the basic scala syntax plugin.

1 Like

Yep, this works. Thanks.

1 Like