-
Notifications
You must be signed in to change notification settings - Fork 29
On Windows + AdoptOpenJDK 8 232-b09, ProjectDirectories.fromPath returns "null" directories #26
Comments
@eed3si9n Thanks, I will look into this! |
Why not use the environment variable |
I've been wondering why we're not using the |
Especially since sbt + Coursier doesn't need "Music" directory. |
The powershell stuff seems to be required for |
@eed3si9n @alexarchambault There was a reason why I abandoned that approach, but I don't remember the reason anymore... Not sure it is this: https://stackoverflow.com/questions/1198911/how-to-get-local-application-data-folder-in-java#comment4791986_1198954. To make things complete: The corresponding registry keys are deprecated and not necessarily in sync¹, |
If you're ok with JNA here's an implementation from a library that's doing similar things - https://github.com/harawata/appdirs/blob/master/src/main/java/net/harawata/appdirs/impl/ShellFolderResolver.java |
@eed3si9n See #16 (comment) for a discussion about JNA. AFAIC, I'm glad directories-jvm doesn't use it, so that it's more lightweight. |
I was able to reproduce the steps above on a Windows 10 machine. Something really weird though: I can't reproduce that error from Ammonite. From sbt (getting nulls):
From Ammonite (almost no nulls):
|
Same when loading lm-coursier-shaded from Ammonite (no nulls):
|
I tried printing the error stream of the powershell process too, and saw nothing suspicious there. Also, for an easy repro, one can just run |
Ok, that seems to originate from these JDK changes (AdoptOpenJDK/openjdk-jdk8u@048eb42). I think sbt sets up a security manager, and Ammonite doesn't hence the discrepancy above. Calling |
@alexarchambault Thanks for digging through this! Seems to be a response to a CVE: https://bugzilla.redhat.com/show_bug.cgi?id=1777929 I can't find anything helpful on how to escape/rewrite the command though, because that would have been my first approach: The JDK doesn't like ambiguous commands anymore? Fine, I will change them to make them unambiguous. |
Nevertheless, I think there is also a bug in handling the |
What do you mean by something to resolve it? |
@szeiger What I meant is that you can't use %LocalAppData% in your file/path APIs expecting that it gets turned into a real path when it hits the Win32 API. |
I still don't see the problem. It's an environment variable. Use |
@szeiger this comment https://stackoverflow.com/questions/1198911/how-to-get-local-application-data-folder-in-java#comment4791986_1198954:
|
I'd also be unsure whether the Win32 API takes a modified environment variable into account (and I think it's reasonable to consider the API the source of truth). |
Probably not: https://devblogs.microsoft.com/oldnewthing/20200115-00/?p=103329 Changing |
I found out that powershell accepts base64-encoded programs via It seems to work well (using it in another context in coursier). |
Heads up: I just published v12. |
The powershell command with -EncodedCommand still fails on my Windows 10 system, due to a missing .NET Framework:
I never use powershell. A possible workaround:
Not sure what the ramifications of that might be, but it does hide the problem. |
@soc ahh, thanks, sorry for the noise! |
no problem! |
This was originally reported as sbt/sbt#5206 On Windows, Coursier creates "./null/Coursier/cache/v1" directories as cache and coursier/coursier#1438
steps
problem
It points a relative path named
"null"
.expectation
https://github.com/soc/directories-jvm#projectdirectories
notes
https://github.com/soc/directories-jvm/blob/8849872b9b71a378e6356f69bcf58427cb681e2f/src/main/java/io/github/soc/directories/Util.java#L113-L145
The text was updated successfully, but these errors were encountered: