jamesrhester / CrystalInfoFramework.jl

Julia tools for reading Crystallographic Information Framework (CIF) files and dictionaries
GNU General Public License v3.0
12 stars 3 forks source link

Possible error with `fix_url` when path contains a space #11

Closed kbarros closed 9 months ago

kbarros commented 9 months ago

On Windows, users are reporting that CrystalInfoFramework won't precompile if their username contains a space. I think the error originates in fix_url converting the space character to %20.

For the user, this runs without error

realpath("C:\\Users\\Chaebin Kim\\.julia\\packages\\CrystalInfoFramework\\sNz0e\\test\\templ_enum.cif")

But this throws ERROR: IOError: [...] no such file or directory (ENOENT)

realpath("C:\\Users\\Chaebin%20Kim\\.julia\\packages\\CrystalInfoFramework\\sNz0e\\test\\templ_enum.cif")

The latter case arises because, I think:

parent = "C:\\Users\\Chaebin Kim\\.julia\\packages\\CrystalInfoFramework\\sNz0e\\test"
s = "templ_enum.cif"
println(CrystalInfoFramework.fix_url(s, parent))
# "C:\Users\Chaebin%20Kim\.julia\packages\CrystalInfoFramework\sNz0e\test\templ_enum.cif"
# Observe that `%20` got inserted!
jamesrhester commented 9 months ago

Thanks for the report and tracking down the origin. I have reproduced the error on Linux. The Path constructor from FilePaths is not converting the %20 back to a space when provided with a URI type, and this is likely true for any special character in the file path. Will work on a fix.

jamesrhester commented 9 months ago

The patch will be simple, if you want to apply it manually, the line

        Path(u.path[2:end])
    else
        Path(u.path)

should be

        Path(unescapeuri(u.path[2:end]))
    else
        Path(unescapeuri(u.path))

in file src/ddlm_dictionary_ng.jl

I will prepare the patch and put out a bugfix release.

chaebinkim commented 9 months ago

Hi, I was struggling with this issue. I tried this solution, and it works for me! Thank you very much for your assistance.

jamesrhester commented 9 months ago

Fixed in v0.6.3

kbarros commented 9 months ago

Thank you James, this fixes it!