directories-jvm
directories-jvm copied to clipboard
Evaluated path inside PowerShell has a leading null
When running the program using PowerShell 7, version 26 of directories-jvm returns a path with leading null.
Output in PowerShell:
ProjectDirectories (Windows 10):
projectPath = 'foo\bar'
cacheDir = 'null\foo\bar\cache'
configDir = 'PowerShell 7.1.3\foo\bar\config'
dataDir = 'PowerShell 7.1.3\foo\bar\data'
dataLocalDir = 'null\foo\bar\data'
preferenceDir = 'PowerShell 7.1.3\foo\bar\config'
runtimeDir = 'null'
Expected output (which you get for example in the default system embedded PowerShell or using cmd):
ProjectDirectories (Windows 10):
projectPath = 'foo\bar'
cacheDir = 'C:\Users\jakob\AppData\Local\foo\bar\cache'
configDir = 'C:\Users\jakob\AppData\Roaming\foo\bar\config'
dataDir = 'C:\Users\jakob\AppData\Roaming\foo\bar\data'
dataLocalDir = 'C:\Users\jakob\AppData\Local\foo\bar\data'
preferenceDir = 'C:\Users\jakob\AppData\Roaming\foo\bar\config'
runtimeDir = 'null'
Thanks for the report, @bluefireoly! Could you check whether the problem also exists on PowerShell 6?
Also, the non-null paths returned in your output look weird too. What was the input you used for ProjectDirectories.from
?
What was the input you used for ProjectDirectories.from?
foo is the corp and bar is the app
ProjectDirectories.from("com", "foo", "bar")
I recently came across this issue. I'm using PS 7.4.0. So running sbt test produces this output:
directories-jvm> sbt test
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by sbt.TrapExit$ (file:/C:/Users/liechtt/.sbt/boot/scala-2.12.13/org.scala-sbt/sbt/1.5.0/run_2.12-1.5.0.jar)
WARNING: Please consider reporting this to the maintainers of sbt.TrapExit$
WARNING: System::setSecurityManager will be removed in a future release
[info] welcome to sbt 1.5.0 (Amazon.com Inc. Java 17.0.9)
[info] loading project definition from C:\Users\liechtt\workspace\java\directories-jvm\project
[info] loading settings for project root from build.sbt ...
[info] set current project to directories (in build file:/C:/Users/liechtt/workspace/java/directories-jvm/)
UserDirectories (Windows 10):
homeDir = 'PowerShell 7.4.0'mpile 0s
audioDir = 'null'
fontDir = 'null'
desktopDir = 'null'
documentDir = 'null'
downloadDir = 'null'
pictureDir = 'null'
publicDir = 'null'
templateDir = 'null'
videoDir = 'null'
BaseDirectories (Windows 10):
homeDir = 'PowerShell 7.4.0'ile 0s
cacheDir = 'null'
configDir = 'null'
dataDir = 'null'
dataLocalDir = 'null'
executableDir = 'null'
preferenceDir = 'null'
runtimeDir = 'null'
ProjectDirectories (Windows 10):
projectPath = 'Baz Corp\Foo Bar-App'0s
cacheDir = 'null\Baz Corp\Foo Bar-App\cache'
configDir = 'PowerShell 7.4.0\Baz Corp\Foo Bar-App\config'
dataDir = 'PowerShell 7.4.0\Baz Corp\Foo Bar-App\data'
dataLocalDir = 'null\Baz Corp\Foo Bar-App\data'
preferenceDir = 'PowerShell 7.4.0\Baz Corp\Foo Bar-App\config'
runtimeDir = 'null'
[error] Test dev.dirs.UtilTest.testPowershell failed: java.lang.AssertionError: null, took 0.137 sec
[error] at dev.dirs.UtilTest.testPowershell(UtilTest.java:188)
[error] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[error] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:568)
[error] ...
[error] Failed: Total 24, Failed 1, Errors 0, Passed 23
[error] Failed tests:
[error] dev.dirs.UtilTest
[error] (Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 1 s, completed 27.11.2023, 10:38:00
It appears that the homeDir could not computed correctly (same as with or without admin privileges)
This seems to be a complete mess, my hope is to abandon this approach completely in favor of shipping a binary and reading its output.
I just haven't found the time yet to figure out the cross-compilation/distribution story yet.