M
Modular4w ago
Wouks

Error when running Mojo when path contains # (hash)

Since the introduction of Magic I have noticed that previous mojo scripts would give me an error when running "magic run mojo hello.mojo". Even using "magic shell" and then "mojo hello.mojo" does not solve the problem. The files are contained in a path where one of the folders starts with a #. When running mojo I get the following error: /home/user/Documents/#MojoProjects/hello-world/.magic/envs/default/bin/mojo: error: cannot map file that is not an actual file or block device When I rename the folder from #MojoProjects to MojoProjects I get the option to reinstall the environment:
? The environment directory seems have to moved! Environments are non-relocatable, moving them can cause issues.

/home/user/Documents/#MojoProjects/hello-world/.magic/envs/default -> /home/user/Documents/MojoProjects/hello-world/.magic/envs/default

This can be fixed by reinstall the environment from the lock-file in the new location.
? The environment directory seems have to moved! Environments are non-relocatable, moving them can cause issues.

/home/user/Documents/#MojoProjects/hello-world/.magic/envs/default -> /home/user/Documents/MojoProjects/hello-world/.magic/envs/default

This can be fixed by reinstall the environment from the lock-file in the new location.
After making this change to not have a # in the path the program runs without a problem. Magic version: 0.4.0 I am wondering if anyone else ran into this issue.
10 Replies
banananas
banananas4w ago
I'm pretty sure if you change the name of the folder in any way you have to rebuild the project iirc that doesn't change anything in your code tho
Wouks
WouksOP4w ago
My point is that this was never an issue before Magic. If the path to that .mojo file contained a # it would still build the executable and it would run without issue. Now I just get a error that says it cannot map a file that is an actual file or block device.
banananas
banananas4w ago
Tbh i've never used the modular cli so i'm not sure how that used to look
Wouks
WouksOP4w ago
Before magic you would use install modular. You would then just create the .mojo file and use mojo hello.mojo to run the script/file. Or you could do mojo build hello.mojo and it would build the file which you could then run using ./hello. And it all worked with a path that contained a #. Now with magic this doesn't work when the path contains a #.
banananas
banananas4w ago
Honestly i'm not sure why this happens; usually if i rename the directory and rebuild i can go on without any issues
Wouks
WouksOP4w ago
Yes. Once I have removed the # and rebuild it all works. If I then go and change it back to have the # and rebuild then the error pops up again. So for some reason if a # is in the path it causes the error.
banananas
banananas4w ago
That's... very strange indeed it may be a bug but i can't really go in deeper since magic isn't open-source i believe
Darin Simmons
Darin Simmons4w ago
Pixi, the software that magic is based on, would like us to "please use only lowercase letters, numbers and dashes" in environment names. My theory is that the # is being caught in the name parsing. In my case I used an underscore and it would let me create the environment, but would not let invoke the shell without throwing an error. .
GitHub
Environment names not sanitized · Issue #2245 · prefix-dev/pixi
Checks I have checked that this issue has not already been reported. I have confirmed this bug exists on the latest version of pixi, using pixi --version. Reproducible example darin@home:/media/dar...
Wouks
WouksOP4w ago
Yeah. The Mojo REPL/Shell doesn't work when the path has a #. It would have been great if the error message was more clear as to what the issue is and that it is from Pixi.
Darin Simmons
Darin Simmons4w ago
the upstream devs did put a sanitizer for environment creation names and agreed that the error message could be better. If you do find anything that Pixi does not do well, the prefix.dev team is incredibly responsive and both in their discord and on github. The fix will flow down.
Want results from more Discord servers?
Add your server