1

maybe someone has seen this..

fairly old Mac OS which might cause this, but mostly everything works OK:

  • Mac OS 10.14.6 (18G9323)
  • LiClipse 8.1.0.202110030926 com.brainwy.liclipse.rcp.product null
  • Homebrew freshly updated (even though also complains OS is too old) and some packages reinstalled to make sure it's all cleared
$ pyenv versions
  system
  3.9.5
* 3.9.7 (set by /Users/aanisimov/.pyenv/version)

$ which python
/Users/aanisimov/.pyenv/shims/python

$ python --version
Python 3.9.7

LiClipse just cannot find it! tried all these buttons there (PATH, pip, what not) still the same error:

Errors getting info on discovered interpreter(s).
See error log for details.
  
  java.lang.RuntimeException: java.io.IOException: Cannot run program "/usr/bin/python": error=0, posix_spawn failed
  
  java.lang.RuntimeException: java.io.IOException: Cannot run program "/usr/bin/python2.7": error=0, posix_spawn failed
  
  java.lang.RuntimeException: java.io.IOException: Cannot run program "/usr/local/bin/python3": error=0, posix_spawn failed
  
  java.lang.RuntimeException: java.io.IOException: Cannot run program "/usr/local/bin/python3.9": error=0, posix_spawn failed

looks like it is trying to find it in most obvious locations, but unable to spawn the process to run it?

Python works OK via terminal and things like Sublime Text.

Thanks for any advice!

See attached screenshot as well!

realaaa
  • 11
  • 1
  • I am seeing a very similar problem with LiClipse 8.2.0 on macOS 12.4 Monterey. But I did not have this problem on a different system with LiClipse 8.1.0 on macOS 10.13.6 High Sierra. – Jim DeLaHunt Jun 04 '22 at 01:55
  • What is your question? What answer are you looking for? You don't say. – Jim DeLaHunt Jun 05 '22 at 18:22

1 Answers1

1

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:

  1. Install a standard Eclipse app of the same vintage (Eclipse 2021-12, version 4.22, corresponds to LiClipse 8.2.0).

  2. Quit LiClipse.

  3. 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
    
  4. save LiClipse.ini.

  5. run LiClipse.app. It should now be able to add new interpreter entries in PyDev, with no errors.

  6. 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.

Jim DeLaHunt
  • 10,960
  • 3
  • 45
  • 74