modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
23.17k stars 2.59k forks source link

[BUG] VSCode extension doesn't run simple file after switch to magic #3560

Open kishmakov opened 4 weeks ago

kishmakov commented 4 weeks ago

Bug description

I am trying to run simplest file:

fn main():
    var a = 1
    print(a)

within project set up by magic init mojo-examples --format mojoproject

The result is it looks like Mojo extension is not aware of anything:

Failed to initialize Crashpad.  Crash reporting will not be available.  Cause: while locating crashpad handler: unable to locate crashpad handler executable
/home/kishmakov/Documents/mojo-examples/7.mojo:1:1: error: unable to locate module 'stdlib'
fn main():
^
/home/kishmakov/Documents/mojo-examples/7.mojo:1:4: error: unable to locate module 'builtin'
fn main():
   ^
/home/kishmakov/Documents/mojo-examples/7.mojo:2:1: error: 
    var a = 1
^
/home/kishmakov/Documents/mojo-examples/7.mojo:2:13: error: could not find an 'IntLiteral' type
    var a = 1
            ^
/home/kishmakov/Documents/mojo-examples/7.mojo:3:5: error: use of unknown declaration 'print'
    print(a)
    ^~~~~
/home/kishmakov/.config/Code/User/globalStorage/modular-mojotools.vscode-mojo/magic-data-home/envs/max/bin/mojo: error: failed to parse the provided Mojo source module

Though it works through console as follows:

$ magic run mojo 7.mojo 
1

Steps to reproduce

System information

$ magic --version
magic 0.3.0

Mojo VSCode extension: v24.5.2

$ echo $MODULAR_HOME
/home/kishmakov/.modular

$ tree $MODULAR_HOME
/home/kishmakov/.modular
├── bin
│   └── magic
└── webUserId
walter-erquinigo commented 3 weeks ago

Could you try again but removing the $MODULAR_HOME environment completely out of your system? With magic and the new conda-based SDK, users shouldn't set this variable on their own, which might confuse automated tools like VS Code.

antonl321 commented 3 weeks ago

I have uninstall modular and vs code for good measure to no avail. On a simple hello world I got the output from the screen shot from below. After I do magic shell MODULAR_HOME points inside hello-world dir: $ echo $MODULAR_HOME /home/syla/Apps/mojo/hello-world/.magic/envs/default/share/max

But VS code in the log window shows a strange path : /home/~/.modular/pkg/packages.modular.com_max/venv/bin/python

/home and ~ don't go together!

image

walter-erquinigo commented 3 weeks ago

Would you be up to some zoom call any time this week to try to debug this? I might be able to figure out a solution that way. Otherwise, I'm kind of lost :(

antonl321 commented 3 weeks ago

Hi,

Yes, starting from tomorrow (Thursday. 3/10). I live in the UK, so it will probably be evening for me.

Lucian

On Wed, 2 Oct 2024 at 00:18, Walter Erquinigo @.***> wrote:

Would you be up to some zoom call any time this week to try to debug this? I might be able to figure out a solution that way. Otherwise, I'm kind of lost :(

— Reply to this email directly, view it on GitHub https://github.com/modularml/mojo/issues/3560#issuecomment-2387247627, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMSEMBRHX5OIUKG4P7UTHNDZZMUTNAVCNFSM6AAAAABPAW6GZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBXGI2DONRSG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

walter-erquinigo commented 3 weeks ago

Cool, feel free to schedule a 15 min meeting on my calendar. My work email is walter@modular.com. I leave on the US East Coast

antonl321 commented 3 weeks ago

I sent you an invite. L

On Wed, 2 Oct 2024 at 17:25, Walter Erquinigo @.***> wrote:

Cool, feel free to schedule a 15 min meeting on my calendar. My work email is @.*** I leave on the US East Coast

— Reply to this email directly, view it on GitHub https://github.com/modularml/mojo/issues/3560#issuecomment-2389095653, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMSEMBV5YNRRXOAWHDR5X4TZZQNABAVCNFSM6AAAAABPAW6GZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBZGA4TKNRVGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

martinvuyk commented 3 weeks ago

Having a similar issue since a while ago and was too lazy to try and solve it. I've been programming like a caveman having to use control f to jump to function definitions ever since magic 0.3.0 update that broke something (used to work with 0.2.3) :(

Getting an error Couldn't install the MAX SDK for VS Code every time I open VSCode.

I tried removing every declaration regarding Mojo from my ~/.bashrc file and even deleted the whole ~/.modular/ folder and reinstalled magic to no avail.

Tried executing from the command palette select default MAX SDK and i get No MAX SDKs were found.

magic --version: 0.3.0 code --version: 1.93.1 mojo nightly extension: v2024.10.205

~$ tree ~/.modular
$HOME/.modular
├── bin
│   └── magic
└── webUserId

1 directory, 2 files

Current workaround

Downgrading with magic self-update --version 0.2.3 Upgraded again with magic self-update, restarted VSCode, waited for a while and the LSP worked again :man_shrugging:

No idea if you just fixed it and that's why it worked..

PS: I thing formatting and basic docstring rendering and jumping to function definitions should still work even if there is no MAX SDK since these are all Mojo standards... And keep in mind I also would like to be able to develop software without an internet connection or a slow one, I still dislike bundling MAX and Mojo together since MAX is a library that I am not using so why punish with 300 megabytes that my 1-3 MiB/s connection takes minutes to download...

walter-erquinigo commented 3 weeks ago

I have a fix in mind for this, which will also stop forcing downloading the SDK over the internet all the time. Please give me a couple of days.

kishmakov commented 3 weeks ago

@walter-erquinigo Thank you, clearing $MODULAR_HOME solved the issue.

There is still a message about broken Crashpad:

Failed to initialize Crashpad. Crash reporting will not be available. Cause: while locating crashpad handler: unable to locate crashpad handler executable

But besides this everything is fine.

josiahls commented 3 weeks ago

I also still see:

Failed to initialize Crashpad.  Crash reporting will not be available.  Cause: while locating crashpad handler: unable to locate crashpad handler executable 

This is a fresh docker image also. MODULAR_HOME is completely removed

soraros commented 3 weeks ago

I also still see:

Failed to initialize Crashpad.  Crash reporting will not be available.  Cause: while locating crashpad handler: unable to locate crashpad handler executable 

Disable telemetry and this goes away:

magic telemetry --disable
JamesNewborn commented 1 week ago

Downgrading with magic self-update --version 0.2.3 Upgraded again with magic self-update, restarted VSCode, waited for a while and the LSP worked again 🤷‍♂️

Did not help. Still getting No MAX SDKs were found. and Couldn't install the MAX SDK for VS Code waiting for a fix ASAP, cause I have some ideas to make a pure-mojo implementation of postgresql driver.... 🙄 And little time to do it)

walter-erquinigo commented 1 week ago

Hi everyone. I'm the maintainer of the VS Code extension. I'm sorry for responding a bit late, but I live in Florida and these past 2 weeks have been very complicated because of the hurricane, but I'm back at work finally.
I have come up with a new design for SDK handling that will make the VS Code extension less reliant on downloads, while at the same time making downloads more robust. I also plan to have the extension use the SDK provided by each individual MAX project, which would make the LSP work accurately.
Please give me a few days to fix this.