0
  1. It's a macOS High Sierra 10.13.2
  2. I put export DATABASE_URL=mysql://username:password@localhost:3306/mydb in ~/.bash_profile, restarted the machine and made sure that I get the value when in terminal I run echo $DATABASE_URL. 2.I launch eclipse using sudo ./eclipse 3.Also played around with launchd.conf but apparently that's not supported in the latest version of MacOS.

What am I missing here?

Update 1 When I run ./eclipse I get this error on the console:

java.lang.RuntimeException: Error initializing storage.
    at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:77)
    at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:295)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:231)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
Caused by: java.io.FileNotFoundException: /Users/myuser/eclipse/configuration/org.eclipse.osgi/.manager/.fileTableLock (Permission denied)
    at java.io.RandomAccessFile.open0(Native Method)
    at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
    at org.eclipse.osgi.internal.location.Locker_JavaNio.lock(Locker_JavaNio.java:36)
    at org.eclipse.osgi.storagemanager.StorageManager.lock(StorageManager.java:388)
    at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:701)
    at org.eclipse.osgi.storage.Storage.getChildStorageManager(Storage.java:1749)
    at org.eclipse.osgi.storage.Storage.getInfoInputStream(Storage.java:1766)
    at org.eclipse.osgi.storage.Storage.<init>(Storage.java:126)
    at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:85)
    at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:75)
    ... 10 more
Arian
  • 7,397
  • 21
  • 89
  • 177
  • I have sometimes seen in IntelliJ the same problem of export's missing. Could you try exporting the DATABASE_URL on eclipse terminal and give a shot? We can dig into details if that works. – St1id3r Jun 03 '18 at 19:54
  • Tried it, but still I get null. I also did `System.getenv()` to get a list of all environment variables. Apparently I don't get the environment variable set in `.bash_profile` – Arian Jun 03 '18 at 20:03
  • Try putting it in `.bashrc` – David Conrad Jun 03 '18 at 20:05
  • 2
    I wouldn't think that Eclipse would pass its environment variables to its processes. You should specify those explicitly in the [launch configuration](https://stackoverflow.com/questions/7048216/environment-variables-in-eclipse#12810433). – Chris Smith Jun 03 '18 at 20:06
  • Is it different between Ubuntu and Mac? because it works fine on my Ubuntu. – Arian Jun 03 '18 at 20:08
  • Are you sure you set the environment variable for the same user that owns the JVM process? Why do you run Eclipse with ``sudo``, anyway? – Jan B. Jun 03 '18 at 20:11
  • I also ran `sudo echo $DATABASE_URL` and I see the value I want. I run eclipse with sudo because otherwise it gives me some weird error (I put it on the original post) – Arian Jun 03 '18 at 20:15
  • Hmm, permission errors can sometimes have weird symptoms. I'd first try to make Eclipse work without sudoing with ``sudo chown myuser -R /Users/myuser/eclipse`` – Jan B. Jun 03 '18 at 20:21
  • I think Chris Smith is right, you have to put the environment variables in the launch configuration. Or run your project from the command line (possibly after building in eclipse). – David Conrad Jun 03 '18 at 20:21
  • @Matt I tried changing the owner, but when eclipse loads, there are many other files from different directories it fails to load. Like the files inside `/private/var/root/.gradle/caches/...` – Arian Jun 03 '18 at 20:34
  • `sudo` normally sanitizes environment vars. Try `sudo sh -c 'echo $DATABASE_URL'` or `sudo env | grep DATABASE_URL` to see this. – dave_thompson_085 Jun 03 '18 at 22:17
  • @dave_thompson_085 huh! when I run `sudo env` I see the variables that are returned by `System.getenv()`. How can I add a new environment variable to that list? is it a good idea ? – Arian Jun 03 '18 at 23:59
  • If you have certain privileges set in `sudoers` or privilege to change it (which on a singleuser system you presumably do), there are several ways to enable an env var in sudo; there may be some variation depending on the version you have (and I don't), so see the man page. On a singleuser system as long as you are careful and don't use sudo to run untrusted or suspect software, there should be no risk. – dave_thompson_085 Jun 05 '18 at 04:19

0 Answers0