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

Storage plugin file errors on Windows #6

Closed
tecosaur opened this issue Jul 30, 2023 · 12 comments
Closed

Storage plugin file errors on Windows #6

tecosaur opened this issue Jul 30, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@tecosaur
Copy link
Owner

tecosaur commented Jul 30, 2023

It seems that on windows, an error may be thrown during precompilation at

isdir(dirname(path)) || mkpath(dirname(path))

The issue seems to be that somehow (mysteriously) the cache folder is already created as a file not a folder, leading to a mkdir error.

I have absolutely no idea what's going on with this ATM.

@vtfanta
Copy link

vtfanta commented Feb 12, 2024

I also had this error and posted on the Discourse.

I tried tinkering around for a bit and found the following:

  • The USER_INVENTORY contains the path C:\\Users\USERNAME\\AppData\\Local\\cache\\julia\\DataToolkit\\cache\\Inventory.toml.
  • When dirname(path) is called, the result is C:\\Users\\USERNAME\\AppData\\Local\\cache\\julia\\DataToolkit\\cache.
  • Finally, the mkpath(dirname(path)) treats the cache at the end as a file name and so it creates a file called cache in the ...\\DataToolkit\\ folder.

Temporary solution
Just create the C:\\Users\\USERNAME\\AppData\\Local\\cache\\julia\\DataToolkit\\cache\\ folder yourself (you can leave it empty). This worked for me; the compilation proceeded without problems and the Inventory.toml file was created in the manually created ...\\cache folder.

@tecosaur
Copy link
Owner Author

tecosaur commented Feb 12, 2024

Thanks for looking into this!

That behaviour is interesting, I thought mkpath always created a directory, not a file 😕.

@chris-b1
Copy link

chris-b1 commented Feb 12, 2024

I don't think it's this mkpath itself that's the issue. If I run the steps @vtfanta outlined above, with an empty C:\Users\USERNAME\AppData\Local\cache\julia\DataToolkit then cache gets created as a folder as expected. So presumably something earlier in the precompilation process is touching that dir?

@vtfanta
Copy link

vtfanta commented Feb 12, 2024

Heh, not for me unfortunately:( With the empty DataToolkit I, again, get the chache 'file' and the error.

@chris-b1
Copy link

Hmm, interesting. I should have noted originally, I do get the same precompilation error, but if I manually run those steps mkpath makes a path, not a file.

@vtfanta
Copy link

vtfanta commented Feb 12, 2024

So presumably something earlier in the precompilation process is touching that dir?

I think you are correct. When I commented out the initially suspicious lines 232-240 in inventory.jl the cache file still got created. Now after commenting out the BaseDirs.User.cache(BaseDirs.Project("DataToolkit"), create=true) in Store.jl it no longer happens, so I think that nails it down to this line.

@tecosaur
Copy link
Owner Author

Thanks for narrowing it down guys! The BaseDirs code may be slightly hard to navigate at a glance, the relevant bit is this: https://github.com/tecosaur/BaseDirs.jl/blob/d6c8e0d9bd5910395890d8a18b4fb1242d91aebe/src/internals.jl#L50-L67

So in order to create a directory, BaseDirs.projectpath(BaseDirs.Project("DataToolkit")) needs to end with a /.

On my Linux machine, I see this:

julia> BaseDirs.projectpath(BaseDirs.Project("DataToolkit"))
"julia/datatoolkit/"

The code for Windows implementation of projectpath is here: https://github.com/tecosaur/BaseDirs.jl/blob/d6c8e0d9bd5910395890d8a18b4fb1242d91aebe/src/nt.jl#L277-L289

So from that, it looks like the fix would be adjusting how BaseDirs behaves on Windows appropriately.

@tecosaur
Copy link
Owner Author

The use of a hardcoded / instead of something platform-adaptive is so that it can be used in strings and be consistent across all platforms, e.g. BaseDirs.User.cache(BaseDirs.Project("DataToolkit"), "subfolder/", create=true).

I think what needs to be changed here might just be the behaviour when only a project is provided.

@tecosaur
Copy link
Owner Author

I've just pushed tecosaur/BaseDirs.jl@729a9e33f23, if you might be able to try using (]add BaseDirs#729a9e33f) and seeing if it works now, that would be much appreciated!

@vtfanta
Copy link

vtfanta commented Feb 12, 2024

Brilliant! This works on my Win10 :)

@tecosaur
Copy link
Owner Author

I'll see if I've thought of any issues with the approach in the next ~day, and if not tag that as BaseDirs v1.2.2, and close this issue.

Thanks for the help!

@tecosaur
Copy link
Owner Author

v1.2.2 is now being registered (JuliaRegistries/General#100782), so I think I can (finally) close this 🥳

@tecosaur tecosaur added the bug Something isn't working label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants