How can I get the Mojo VS Code extension to work?

Hi everyone,

I have not been able to get the Mojo VS Code extension to work properly. For example, when I hover over a symbol, I do not get the expected documentation popup.

I first tried installing the extension from the VS Code Marketplace:

  • Identifier: modular-mojotools.vscode-mojo
  • Version: 26.2.0

I also tried installing the latest extension build artifact:

  • Artifact name: extension-a4cc82148a335cf3540f51b5f43bda2eb1075758
  • Artifact digest: sha256:1d20713d638c8d7867b485e483aad8c80aebd45a0a22ce1553c9f61267fc06af

I tried opening VS Code both before and after starting a shell in the Pixi environment.

I also ran Python: Select Interpreter and selected:

/home/leandro/projects/github/modular/mojo-gpu-puzzles/.pixi/envs/default/bin/python

However, none of that made the extension work.

The best result I got was this error message:

A crash happened in the Mojo Language Server when processing this document. The Language Server will try to reprocess this document once it is edited again. Please report this issue in https://github.com/modular/modular/issues along with all the relevant source codes with their current contents.mojo

The file I am trying to open is:

  • File: problems/p01/p01.mojo
  • Repository: https://github.com/modular/mojo-gpu-puzzles
  • Current branch: main
  • Current commit: 34402ff (Edit the problems with a print statement indicating completion (#236))

In addition, VS Code shows the following notification:

Parsing document: /home/leandro/projects/github/modular/mojo-gpu-puzzles/problems/p01/p01.mojo

Has anyone seen this before, or is there any additional setup required to make the extension work correctly with a Pixi-based Mojo environment?

This has been pretty frustrating.

Thanks.

“Mojo from Modular” extension in my VSCode works as expected. I’m using Python venv for Mojo on Ubuntu.

I’ll try installing Mojo that way. Thanks.

Hey! This usually happens when the Mojo Language Server can’t fully see your Pixi environment. The easiest fix is to start VS Code from a terminal where Pixi is already activated, so all paths and environment variables line up. Also, make sure your extension version matches the Mojo runtime you’re using. Sometimes certain code patterns in .mojo files can crash the server, so if it keeps failing, try simplifying the file or checking which part triggers it. Most people get it working this way — it’s just a bit picky about the environment.