Changing the MAX SDK through the vscode extension

Hi all,

I’m looking into how to change the MAX SDK on the fly for the vscode extension.
The documentation mentions that the place of the sdk should have a modular.cfg file.

On my system, there’s a few of them:

# Cursor's 
/home/dhoogla/.cursor-server/data/User/globalStorage/modular-mojotools.vscode-mojo/magic-data-home/envs/max/share/max/modular.cfg

# VsCode's
/home/dhoogla/.vscode-server/data/User/globalStorage/modular-mojotools.vscode-mojo/magic-data-home/envs/max/share/max/modular.cfg

# Global version from`magic global install max --expose mojo
/home/dhoogla/.modular/envs/max/share/max/modular.cfg

# Others for projects initialized with `magic init my-project --format mojoproject` that have max as a dependency

In Cursor and in Vscode, in the bottom right , next to the language, I can see MAX SDK: MAX SDK (stable) which is 25.2. The vscode and cursor versions are 25.2 when I look into their modular.cfg files so that checks out. The chosen SDK is definitely not my global install because that’s a nightly 25.3.

What I wanted to do, but can’t: invoke Mojo: select the default SDK in either editor and set the SDK to my global, nightly max and mojo 25.3. The dialog box opens and I point it to the path: /home/dhoogla/.modular/envs/max/share/max/modular.cfg and nothing happens. If I change the path to the parent folder of the modular.cfg file nothing happens either.

The documentation page of the Mojo extension mentions:

Configuration

The extension will attempt to find the path of the Mojo SDK installation using the MODULAR_HOME environment variable. If MODULAR_HOME is not set within the environment, the path can be explicitly set via the mojo.modularHomePath extension setting.

My $MODULAR_HOME is /home/dhoogla/.modular, but it definitely doesn’t take the SDK from there because that would be 25.3

I’m on WSL Ubuntu 22.04.

How am I doing this wrong?

Is this possible, no matter what setting I change the SDK installed with the extension always persists? Should I be able to select the version installed in my pixi environment?

The documentation on the old VS Code extension is a little out of date, because we’ve moved away from using some of those older configuration parameters. I believe the current way this works is that an internal version of Magic within the stable and nightly extensions keys off of the latest versions of either of those and installs an LSP to match. I’m not sure if there’s a good way to override this.

We are in the later stages of preparing a completely rewritten VS Code extension that will replace both the nightly and stable Mojo extensions. It will source the LSP from your project’s environment, whether that’s the Pixi environment or a Python virtual environment. In that extension, you’ll also be able to override the environment and point it somewhere else if you want a different LSP to be used. We’ll announce when that’s available, but hopefully it’ll be soon.

1 Like

Thanks @BradLarson thats great news!