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:
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
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
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.Tbh i've never used the modular cli so i'm not sure how that used to look
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 #
.Honestly i'm not sure why this happens; usually if i rename the directory and rebuild i can go on without any issues
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.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
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...
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.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.