Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » RCP, Environment Variables, OS X, Info.plist and LSEnvironment
RCP, Environment Variables, OS X, Info.plist and LSEnvironment [message #1703924] Wed, 05 August 2015 21:11 Go to next message
Jim Klo is currently offline Jim KloFriend
Messages: 49
Registered: September 2012
Member
I've got a somewhat challenging problem here.

I've got an RCP application that relies upon some shared dynamic libraries which might not be in standard locations (as this is OS X and they are user installed).

One of the things we need to configure is DYLD_LIBRARY_PATH in order for the shared libraries be discovered. The problem here is OS X doesn't have a simple way to set environment variables that applications launched from the Finder can "see".

One of the thing that I've found, but not had any success with, is to dynamically modify the RCP's Info.plist to have an additional key LSEnvironment whose value is a dictionary to set environment variables only visible to that application - okay this seems ideal for me. But it's not working.

I also found that I could use launchctl setenv to set a user global Environment variable, however it's not persistent across launches, and each time I set, I must restart the app. I really need this persistent.

Does anyone have any solution for setting Environment variables that are visible from the RCP app (and it's children) that works in OS X without having to launch the RCP app from a terminal?

Thanks in advance!
Re: RCP, Environment Variables, OS X, Info.plist and LSEnvironment [message #1703938 is a reply to message #1703924] Wed, 05 August 2015 23:54 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 877
Registered: January 2012
Senior Member

Sounds like you want to use System.loadLibrary() with absolute paths?

Brian.
Re: RCP, Environment Variables, OS X, Info.plist and LSEnvironment [message #1705197 is a reply to message #1703938] Wed, 12 August 2015 17:36 Go to previous message
Jim Klo is currently offline Jim KloFriend
Messages: 49
Registered: September 2012
Member
Brian de Alwis wrote on Wed, 05 August 2015 19:54
Sounds like you want to use System.loadLibrary() with absolute paths?


That doesn't quite work, as we aren't using JNI. Unfortunately the use-case details get pretty complicated - so I omitted in an effort to make it simpler to understand the problem.

Basically we have built an IDE that uses the Prolog interpreter, XSB. XSB natively connects to MySQL using the shared MySQL libs. Unfortunately on OS X, MySQL can get installed into possibly one of many locations, and it certainly doesn't install it's libs in /usr/local/lib or /usr/lib. We access XSB via a Java library called Interprolog, which I believe, is just a pipe interface to the command line shell - hence when the Interprolog engine object is instantiated, it fires up a shell process for XSB - which needs to locate those MySQL libraries. Hence, DYLD_LIBRARY_PATH needs to be set to have the path for /usr/local/mysql/lib (or wherever the user installed it) defined in the parent process in order for Interprolog's sub-process to pick up the environment variable.

Right now there are only 2 reliables ways I have found to get this to work.
1. Launch Terminal, export the environment variable. Then launch our RCP app from the Terminal. - cumbersome and unintuitive; bad user experience.
2. Launch Terminal, use `launchctl setenv DYLD_LIBRARY_PATH /usr/local/mysql/lib`. And then one can lacuna our RCP app using Finder. - problem is that DYLD_LIBRARY_PATH is now global to the environment and will not persist between reboots.

I've tried added the LSEnvironment dictionary to the Info.plist within the RCP application, but that just doesn't seem to work - and I'm not sure if that is because the OS X eclipse launcher doesn't propagate the environment forward or what. For the time being I have a way for the user to click a button which runs launchctl setenv and then prompts the user to exit the app, and then launch again from finder [IWorkbench.restart() doesn't work because new process is a child of the current] - which works but is undesirable workflow as it doesn't persist across a login/reboot.

My next step is to try what is outlined here: http://stackoverflow.com/questions/829749/launch-mac-eclipse-with-environment-variables-set
However it feels even more sketchy than just modifying the Info.plist to contain the right environment variables.

Previous Topic:shortcut keys of context menu not showing up (keybindings)
Next Topic:Remove toolbar Contribution Item throws NullPointerException
Goto Forum:
  


Current Time: Sun Nov 29 08:22:48 GMT 2020

Powered by FUDForum. Page generated in 0.01955 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top