halcyon / asdf-java

A Java plugin for asdf-vm.
MIT License
454 stars 86 forks source link

[macOS] Zulu install in /Library/Java/JavaVirtualMachines fails when java_macos_integration_enable = yes #137

Closed delgurth closed 3 years ago

delgurth commented 3 years ago

After enabling

java_macos_integration_enable = yes

It seems the location for the MacOS folder and Info.plist files for Zulu is not working as expected:

$ asdf install java zulu-8.52.0.23
...
Integrating with /usr/libexec/java_home needs root permission for it to create folders under /Library/Java/JavaVirtualMachines
cp: /Users/<username>/.asdf/Contents/MacOS: No such file or directory
cp: /Users/<username>/.asdf/Contents/Info.plist: No such file or directory

Which results in the MacOS java_home command being unable to find the installed runtime:

$ /usr/libexec/java_home -V
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

Installing for example Adopt OpenJDK I'm getting the expected results:

$ asdf install java adoptopenjdk-15.0.2+7
...
Integrating with /usr/libexec/java_home needs root permission for it to create folders under /Library/Java/JavaVirtualMachines

And then

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
    15.0.2 (x86_64) "AdoptOpenJDK" - "OpenJDK 15.0.2" /Library/Java/JavaVirtualMachines/adoptopenjdk-15.0.2+7/Contents/Home
/Library/Java/JavaVirtualMachines/adoptopenjdk-15.0.2+7/Contents/Home

The problem resides in the usage of absolute_dir_path combined with a file (release) and not a directory.

Changing release into bin/.. fixes it for me.

$ asdf install java zulu-11.45.27
Integrating with /usr/libexec/java_home needs root permission for it to create folders under /Library/Java/JavaVirtualMachines
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    15.0.2 (x86_64) "AdoptOpenJDK" - "OpenJDK 15.0.2" /Library/Java/JavaVirtualMachines/adoptopenjdk-15.0.2+7/Contents/Home
    11.0.10 (x86_64) "Azul Systems, Inc." - "Zulu 11.45.27" /Library/Java/JavaVirtualMachines/zulu-11.45.27/Contents/Home
/Library/Java/JavaVirtualMachines/adoptopenjdk-15.0.2+7/Contents/Home
paddyroddy commented 11 months ago

Mine works now but this message

Integrating with /usr/libexec/java_home needs root permission for it to create folders under /Library/Java/JavaVirtualMachines

at first glance suggests to me it isn't