Fork me on GitHub
#spacemacs
<
2019-09-18
>
jumar06:09:37

Has someone ever head problems with env vars in Spacemacs, more specifically JAVA_HOME?

jumar06:09:16

I'm not sure when that started to happen (can be a few days ago) but suddenly my JAVA_HOME is set to 1.8 although I use 11 almost everywhere. I'm on Mac OS X. I certainly have such 11 set in my shell and even in the OS environment it seems (e.g. HelloWorld run in Intellij IDEA reports 11). I use jenv to manage java home and event set it in /Library/LaunchDaemons/setenv.java.plist

spfeiffer06:09:52

Spacemacs has a .env file that contains the env variables and values it „sees“. These are not the ones you set in your shell.

spfeiffer06:09:09

I still not get the rationale for this „feature“.

jumar06:09:01

Hm, I had two values there; delete them but still no change.

jumar06:09:03

It seems that I need to start the GUI app from the terminal...

ag06:09:42

@U06BE1L6T first SPC f e C-e, then SPC f e e - check if JAVA_HOME is there

jumar06:09:11

I think it used to work properly with jenv - e.g. when I ran the repl in a directory where jenv local version was 1.8 it used 1.8. For other projects it used 11

ag06:09:14

then try adding it manually to exec-path-from-shell-variables

ag06:09:07

have you played with graal? graal can fubar java

jumar06:09:14

some time ago

jumar06:09:35

I actually think I might have executed force-init-spacemacs-env accidentaly in the past

ag06:09:41

then in emacs open eshell and type which java

jumar06:09:44

before that it was working ok I think

ag06:09:31

make sure it’s pointing to the version you want

jumar06:09:52

Hm, still doesn't work as expected. It's setting duplicate JAVA_HOME values. Maybe I need to do this somewhere in emacs config:

echo 'eval "$(jenv init -)"'

jumar06:09:14

This is what I have in my /etc/profile:

eval "$(jenv init -)"
  eval "$(jenv enable-plugin export)"

jumar06:09:51

No luck, very frustrating 😞. It used to work just fine - proper java version was picked up as per jenv settings (as in terminal).

practicalli-johnny06:09:00

It sounds like you have different Java settings between shell and login shell. I.e a terminal has one setting and gui apps have another

jumar07:09:18

That might be true since it's notoriously hard to set this in Mac OS, but at least InteliJ IDEA seems to have the right setting

jumar07:09:18

I'm using this jenv thing and its exporter plugin and also setting it in /Library/LaunchDaemons/setenv.java.plist

jahson07:09:11

~/.spacemacs.env

jumar07:09:29

I checked that and also deleted the JAVA_HOME occurences

jumar07:09:57

At this point, I have no idea where the emacs app is getting its' env...

jahson07:09:14

You could rename the .spacemacs.env and try to find out what would happen.

jumar07:09:50

I did it and I think spacemacs automatically re-created it

jumar07:09:54

will try one more time

jumar07:09:26

Yes, the same thing again

jahson07:09:13

So, basically, it uses the wrong JDK?

jumar07:09:37

But now I kept that file and just removed all the content and it's at least using the proper global JDK (11)

jumar07:09:28

but it still doesn't work with "local versions" that is for projects that have different java set locally with jenv (like 1.8)

jumar07:09:53

it seems I need to do this trick with:

eval "$(jenv init -)"
  eval "$(jenv enable-plugin export)"

jumar07:09:27

does anyone know how to do that?

jumar07:09:35

@U05254DQM not yet, will check it

jahson07:09:22

Looks like the section 11.2 can be somewhat helpful

jumar07:09:47

I'm now trying the latest develop version. It's been a long while since I updated it the last

jumar09:09:32

After removing JAVA_HOME related stuff from .spacemacs.env, removing everything from various .plist files (/Library/LaunchDaemons/setenv.java.plist, /.MacOSX/environment.plist, /Library/LaunchAgents/environment.plist) and restarting my computer a couple of times it finally works as before! Thanks everyone for your help

jumar09:09:02

I also added the jenv init code (see above) to .bash_profile but not sure if that had any effect at all.

spfeiffer05:09:18

Oh my, what a ride… 😐

jumar06:09:14

Yeah, kind of unexpected 3 hours spent on this thing 😈

Drew Verlee21:09:51

general emacs question, has anyone found a way to fold jsx? e.g <div> <h2>* pressing fold at h2 would collapse everything inside of it. I really like being able to look at as little code as possible, i'm willing to use other methods beyond fold to achieve that. RIght now the fold function i use folds all the jsx into one ... fold.

Drew Verlee21:09:38

in that same vein, but for editing clojure, i feel like i could probably use something more powerful then fold. Like a focus, that hid everything on the page except the s-expression i picked.

Drew Verlee21:09:04

maybe a heavy blur on other code

Drew Verlee21:09:21

maybe intelliji does this 😏

practicalli-johnny22:09:01

@drewverlee SPC n f will give you exact focus on the current function under the cursor. I use narrowing mainly for find/replace, but could be useful for focus. You can also narrow to page or region. SPC n w to restore the full view.

👍 4
practicalli-johnny22:09:51

Yes, it's something lisp developers have used a lot

Drew Verlee22:09:04

awesome! thanks a lot for putting this together and answering questions on slack.

👍 4