Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: VS Code - Mojo Nightly extension doesn't respect a project's local Python environment. #253

Open
johnsoez4 opened this issue Nov 15, 2024 · 0 comments
Assignees
Labels
bug Something isn't working max-repo

Comments

@johnsoez4
Copy link

Bug description

Discord: https://discord.com/channels/1087530497313357884/1306643450065719326

Debugging a Mojo project with Python dependencies is broken when VS Code is started from a Snap icon in Ubuntu. Also, regardless of how VS Code is started, clicking on Run Mojo File from the IDE's dropdown menu doesn't work until I run magic shell in the VS Code terminal.

Initially I could not use the Mojo debugger with my project which uses Python with dependencies installed from Conda and PyPi. I added these dependencies to the project's mojoproject.toml file using the magic add command. Within the VS Code IDE I've found that for my project to find these Python dependencies, I must execute the magic shell command in the terminal before clicking on the Run Mojo File in the IDE's dropdown menu.
When I try and run the debugger, VS Code does not respect the local Python environment in the active terminal after I've run the magic shell command, so the dependencies are missing.

Before magic shell

Python version: 3.12.7 (main, Oct  3 2024, 15:15:22) [GCC 14.2.0]
----module-paths----
/home/johnsoe1/dev/EzProjects/EzAsanaDL/AsanaDL
/usr/lib/python312.zip
/usr/lib/python3.12
/usr/lib/python3.12/lib-dynload
/usr/local/lib/python3.12/dist-packages
/usr/lib/python3/dist-packages

After magic shell

Python version: 3.12.7 | packaged by conda-forge | (main, Oct  4 2024, 16:30:45) [GCC 13.3.0]
----module-paths----
/home/johnsoe1/dev/EzProjects/EzAsanaDL/AsanaDL
/home/johnsoe1/dev/EzProjects/EzAsanaDL/.magic/envs/default/lib/python312.zip
/home/johnsoe1/dev/EzProjects/EzAsanaDL/.magic/envs/default/lib/python3.12
/home/johnsoe1/dev/EzProjects/EzAsanaDL/.magic/envs/default/lib/python3.12/lib-dynload
/home/johnsoe1/dev/EzProjects/EzAsanaDL/.magic/envs/default/lib/python3.12/site-packages

Steps to reproduce

After discussion in Discord with Ehsan M. Kermani.

I get the following behavior when I run magic shell then start VS Code from within a bash shell (see 1, 2, & 3 below).
In short, starting this way from the CLI allows me to use the debugger from within VS Code (2 & 3 below), but it's not intuitive and doesn't resolve item 1.

  1. Click on Run Mojo File - KO
  • Must run magic shell in the VS Code terminal for this command to work.
  • Same behavior regardless of how I start VS Code, from bash shell or Snap icon.
  1. Click on Debug Mojo File - OK
  • The sequence above uses the correct, local project Python environment.
  • When I start VS Code from the Snap icon, it's terminal uses the wrong Python environment.
  1. Click on Debug Mojo File in Terminal - OK
  • Same as 2 above.

System information

- Ubuntu 24.10
- VS Code v1.95.2
- VS Code extension = Mojo Nightly v2024.11.1405
- mojo 2024.11.1405 (d5d02e71)
- max 2024.11.1405 (d5d02e71)
- Modular version 2024.11.1405
@johnsoez4 johnsoez4 added the bug Something isn't working label Nov 15, 2024
@goldiegadde goldiegadde added the max-repo label Dec 18, 2024 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working max-repo
Projects
None yet
Development

No branches or pull requests

3 participants