I had a problem very much like this, except with LiClipse version 8.2.0, running on macOS 12.4 Monterey, with Python interpreters installed by MacPorts. The symptoms were similar, except that LiClipse returned error code 316 instead of 0. What I wanted to know: how can I resolve this problem, so that LiClipse can add new interpreter entries in PyDev, and not display errors?
I came up with a workaround. I don't fully understand why it works, but I have some clues.
Workaround:
Install a standard Eclipse app of the same vintage (Eclipse 2021-12, version 4.22, corresponds to LiClipse 8.2.0).
Quit LiClipse.
Using a plain text editor, edit the file within LiClipse.app, LiClipse.app/Contents/Eclipse/LiClipse.ini
. Change the lines in that file which read:
--launcher.defaultAction
openFile
-vmargs
to read (of course replacing <myuserid>
with your home directory name, and no line break in the very long line starting "/Users/"…):
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
/Users/<myuserid>/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.macosx.x86_64_18.0.1.v20220515-1614/jre/lib/libjli.dylib
-vmargs
save LiClipse.ini.
run LiClipse.app. It should now be able to add new interpreter entries in PyDev, with no errors.
delete the Eclipse.app. (This should leave behind /Users//.p2/ undisturbed.)
What it does:
I am not an expert on the internals of either LiClipse or Eclipse. What I think is happening is that Eclipse supplies an OpenJDK for the app to run, it is different than the OpenJDK supplied by LiClipse, and it supports recent version of macOS better. Evidence of difference:
% /Applications/LiClipse.app/jre/Contents/Home/bin/java --version
openjdk 14.0.2 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.2+12)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.2+12, mixed mode, sharing)
% /Users/<myuserid>/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.macosx.x86_64_18.0.1.v20220515-1614/jre/bin/java --version
openjdk 18.0.1 2022-04-19
OpenJDK Runtime Environment Temurin-18.0.1+10 (build 18.0.1+10)
OpenJDK 64-Bit Server VM Temurin-18.0.1+10 (build 18.0.1+10, mixed mode)
The LiClipse.ini
file controls how the app starts up. macOS runs a launcher program, and the launcher is guided by the contents of the ini file. The inserted lines look to me like they tell the launcher to specify a different Java VM to use when running the main Eclipse/LiClipse application — to use the OpenJDK 18.0.1 supplied by Eclipse, saved in ~/.p2/
, instead of the OpenJDK 14.0.2 supplied by LiClipse; and also to invoke a library libjli.dylib
.
Clues about the cause
I don't know enough about the JDK to know what library libjli.dylib
does. There are clues in a StackOverflow answer, What is the Java libjli library for?, and in a blog post, Calling Java From C. It looks like it helps interaction between the Java VM environment and the hosts's native language environment. The StackOverflow reply mentions,
The libjli.so contains a launcher interface for preparing arguments passed in the command line and launching the virtual machine with them.…
The error message in my case read,
java.io.IOException: Cannot run program "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python": error=316, posix_spawn failed
I speculate that LiClipse was trying to call macOS to run the Python interpreter, but this attempt failed because the Java VM environment could not call the host's native environment successfully.
The change to LiClipse.ini means that LiClipse uses a different OpenJDK, and invokes libjli differently. The combination of these differences seems to let the Java VM environment succeed in calling the host's native environment.
I speculate that a proper fix requires an update to LiClipse. I have opened ticket 239, 8.2.0 cannot run pythons and pips, "java.io.IOException: Cannot run program"... error=316, posix_spawn failed, to track it.