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

Import can't find files #223

Open
infu opened this issue Jul 5, 2023 · 9 comments
Open

Import can't find files #223

infu opened this issue Jul 5, 2023 · 9 comments

Comments

@infu
Copy link

infu commented Jul 5, 2023

Sometimes Motoko language server works and finds its files, sometimes it doesn't. Reloading doesn't help. Everything seems to be set properly, mops & dfx.json. Can't even find a local file. The only difference I can see is my git root is not where dfx.json is. Perhaps that path is being used? How the language server detects its dfx.json ?
image

@rvanasa
Copy link
Contributor

rvanasa commented Jul 5, 2023

Thanks for the bug report; I'll see if I can reproduce this on my end.

Everything seems alright for a simplified example, so would you be able to send a screenshot of your file / directory structure?

Also, does anything seem unusual in the extension log ("Output" -> "Motoko Language Server")?

The language server is able to handle multiple dfx.json files at a time in any subdirectory, so this is supposed to work even with a different Git root.

@infu
Copy link
Author

infu commented Jul 6, 2023

Thanks for pointing out where I should be looking.
image
It seems it doesn't like the simlinks my npm setup has and ends in infinite loop. I can fix that on my end.

Edit: Removing looping npm packages fixed it

@rvanasa
Copy link
Contributor

rvanasa commented Jul 6, 2023

Just to confirm, did this fix the original issue ("sometimes Motoko language server works and finds its files, sometimes it doesn't")?

I'll look into fixing this infinite loop condition to minimize the chance of the same situation happening in the future.

@infu
Copy link
Author

infu commented Jul 10, 2023

It works most of the time. (On Mac/Intel)
However, sometimes I get these errors. (not too often)
reloading VScode or Motoko language server thru palette doesn't help.
I have to close VScode and start it again. Then it works.
image

@rvanasa
Copy link
Contributor

rvanasa commented Jul 10, 2023

That is quite strange. What operating system are you using?

This might have something to do with VS Code itself rather than the extension, since the error messages indicate that the system path doesn't include npx or mops while the extension is being initialized.

@infu
Copy link
Author

infu commented Jul 11, 2023

MacOs 13.4

@rvanasa
Copy link
Contributor

rvanasa commented Jul 11, 2023

Thanks! I'll let you know if I find a way to reproduce this issue on my end (also on macOS 13.4).

You could try running mops sources and npx ic-mops sources in a terminal to see if anything unexpected happens (and then running code . from the same terminal to inherit the system path). If this doesn't help, then it might be worth reinstalling VS Code and perhaps running the Motoko extension by itself to try and narrow down the root cause.

@rvanasa
Copy link
Contributor

rvanasa commented Aug 22, 2023

Hi @infu, are you still running into this issue? Here are a few more debugging steps that might help narrow down what's happening:

  • What happens if you remove or change defaults.build.packtool in your dfx.json file?
  • Do you get a "command not found" message when running which npx and which mops in the VS Code dev console?

@ottodevs
Copy link

same issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants