modular / modular/vscode-mojo

How to configure vsc debug

Open
#106 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
38
Forks
17
Avg merge
4d 13h
Merged PRs (30d)
13

Description

Description

I installed Mojo using Pixi; running pixi shell followed by mojo run main.mojo works fine. I also installed the Python and Mojo extensions in VSCode, but pressing F5 results in an error from Python. Alternatively, if I want to use VSCode for debugging, are there other ways or more detailed reference links? Thank you in advance.

shell info

stephanie@swift hello-world % pwd     
/Users/stephanie/Desktop/mojo-project/hello-world
stephanie@swift hello-world % pixi shell

(hello-world) stephanie@swift hello-world % mojo --version
Mojo 0.26.2.0.dev2026030616 (c1bd447c)
(hello-world) stephanie@swift hello-world % mojo run main.mojo 
z: 17
x: 15

error info


cd /Users/stephanie/Desktop/mojo-project/hello-world ; /usr/bin/env /usr/bin/python3 /Users/stephanie/.vscode/extensions/ms-python
.debugpy-2025.18.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher 61802 -- /Users/stephanie/Desktop/mojo-project/hello-world/main.mojo 
Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/stephanie/.vscode/extensions/ms-python.debugpy-2025.18.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in <module>
    cli.main()
  File "/Users/stephanie/.vscode/extensions/ms-python.debugpy-2025.18.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 508, in main
    run()
  File "/Users/stephanie/.vscode/extensions/ms-python.debugpy-2025.18.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 358, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/Users/stephanie/.vscode/extensions/ms-python.debugpy-2025.18.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 309, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "/Users/stephanie/.vscode/extensions/ms-python.debugpy-2025.18.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 283, in _get_code_from_file
    code = compile(f.read(), fname, "exec")
  File "/Users/stephanie/Desktop/mojo-project/hello-world/main.mojo", line 1
    fn add_two(y: Int):
       ^
SyntaxError: invalid syntax

main.mojo

fn add_two(y: Int):
    # y += 2  # This would cause a compiler error because `y` is immutable
    # We can instead make an explicit copy:
    var z = y
    z += 2
    print("z:", z)

def main() raises:
    var x = 15
    add_two(x)
    print("x:", x)

vscode lanch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Mojo Debug via Pixi",
      "type": "python",
      "request": "launch",
      "program": "${workspaceFolder}/main.mojo",
      "console": "integratedTerminal",
      "cwd": "${workspaceFolder}",
      "env": {
        "PATH": "/Users/stephanie/Desktop/mojo-project/hello-world/.pixi/envs/default/bin:${env:PATH}"
      }
    }
  ]
}

https://marketplace.visualstudio.com/items?itemName=modular-mojotools.vscode-mojo

System information
  • Provide the system information by running pixi info.
pixi info
System
------------
       Pixi version: 0.59.0
           Platform: osx-arm64
   Virtual packages: __unix=0=0
                   : __osx=26.2=0
                   : __archspec=1=m2
          Cache dir: /Users/stephanie/Library/Caches/rattler/cache
       Auth storage: /Users/stephanie/.rattler/credentials.json
   Config locations: No config files found

Global
------------
            Bin dir: /Users/stephanie/.pixi/bin
    Environment dir: /Users/stephanie/.pixi/envs
       Manifest dir: /Users/stephanie/.pixi/manifests/pixi-global.toml

Workspace
------------
               Name: hello-world
            Version: 0.1.0
      Manifest file: /Users/stephanie/Desktop/mojo-project/hello-world/pixi.toml
       Last updated: 07-03-2026 10:22:57

Environments
------------
        Environment: default
           Features: default
           Channels: https://conda.modular.com/max-nightly, conda-forge
   Dependency count: 1
       Dependencies: mojo
   Target platforms: osx-arm64
    Prefix location: /Users/stephanie/Desktop/mojo-project/hello-world/.pixi/envs/default


  • Provide version information for MAX (includes Mojo) by pasting the output of pixi list max.
 pixi list max
Error:   × No packages found in 'default' environment for 'osx-arm64' platform.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported .vscode/launch.json configuration, main.mojo, and the linked VS Code Mojo extension; compare the F5 path with the successful pixi shell command. Done means documenting a supported VS Code debugging setup or clearly identifying the missing configuration or extension guidance behind the Python traceback.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, vscode
Domain
developer-experience, tooling
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.