Search code examples
macosintellij-ideainstallationmountfinder

`GetJREPath()` when installing IntelliJ via command line OSX


I was trying to be able to install Intellj hands free by running this:

wget https://download.jetbrains.com/idea/ideaIC-2017.2.3.dmg
hdiutil mount -nobrowse ideaIC-2017.2.3.dmg
mkdir /Applications/IntelliJ\ IDEA\ CE.app
cp -r /Volumes/IntelliJ\ IDEA\ CE/IntelliJ\ IDEA\ CE.app/ /Applications/IntelliJ\ IDEA\ CE.app/
hdiutil unmount /Volumes/IntelliJ\ IDEA\ CE/ 
rm ideaIC-2017.2.3.dmg

I notice when installing on OSX and the Intellij.app file gets coppied from the mount in /Volumes/IntelliJ into a dir in my /Applications folder from the command line with cp, I have the error:

Error: could not find libjava.dylib
Failed to GetJREPath()

When running the executable file in /Applications/IntelliJ IDEA CE.app/Contents/MacOS.

Specifically, I got:

LSOpenURLsWithRole() failed with error -10810 for the file /Applications/IntelliJ IDEA CE.app.

when I tried to:

open /Applications/IntelliJ\ IDEA\ CE.app/

But none of this goes wrong when I try manually "drag-and-drop" the app from the Finder window. What's going on here?

Info:

Output when I "drag-and-drop":

./idea 
2017-08-31 18:14:27.258 idea[5098:151348] allVms required 1.8*,1.8+
2017-08-31 18:14:27.260 idea[5098:151359] Value of IDEA_VM_OPTIONS is (null)
2017-08-31 18:14:27.260 idea[5098:151359] fullFileName is: /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions
2017-08-31 18:14:27.260 idea[5098:151359] fullFileName exists: /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions
2017-08-31 18:14:27.260 idea[5098:151359] Processing VMOptions file at /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions
2017-08-31 18:14:27.260 idea[5098:151359] Done
/Applications/IntelliJ IDEA CE.app/Contents/bin/idea.properties: 'java.endorsed.dirs = ' already defined in system properties: /Applications/IntelliJ IDEA CE.app/Contents/jdk/Contents/Home/jre/lib/endorsed

Output when I mkdir then cp:

./idea 
2017-08-31 18:15:56.295 idea[5134:152286] allVms required 1.8*,1.8+
2017-08-31 18:15:56.297 idea[5134:152301] Value of IDEA_VM_OPTIONS is (null)
2017-08-31 18:15:56.297 idea[5134:152301] fullFileName is: /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions
2017-08-31 18:15:56.297 idea[5134:152301] fullFileName exists: /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions
2017-08-31 18:15:56.297 idea[5134:152301] Processing VMOptions file at /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions
2017-08-31 18:15:56.298 idea[5134:152301] Done
Error: could not find libjava.dylib
Failed to GetJREPath()
2017-08-31 18:15:56.298 idea[5134:152301] JNI_CreateJavaVM (/Applications/IntelliJ IDEA CE.app/Contents/jdk) failed: 4294967295

Solution

  • You should use the following command instead:

    cp -R /Volumes/IntelliJ\ IDEA\ CE/IntelliJ\ IDEA\ CE.app/ /Applications/IntelliJ\ IDEA\ CE.app/
    

    Notice -R option instead of -r.

    According to this man page, -r works differently on macOS:

    COMPATIBILITY

    Historic versions of the cp utility had a -r option. This implementation supports that option; however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links, or fifo's.