Clojure REPL not picking environment variables

It seems the Clojure REPL (Tools | Start Clojure Console) does not pick up environment variables.  The following comes back empty,

(prn (into {} (System/getenv)))

However, in a Run/Debug configuration, I get environment variables.

The missing environment variables seem to cause a problem when I try to run an executable using clojure.java.shell/sh.  Any ideas on how to get Clojure REPL to pick up environment variables?

0
5 comments
Avatar
Permanently deleted user

Hi Michael.

There is no way to specify environment variables for REPL from IntelliJ. This functionality will be added to REPL settings soon.
For now, as a workaround, specify environment variables explicitly in the REPL using with-sh-env form.

Cheers!
Ilya

0
Avatar
Permanently deleted user

Thanks for the quick reply.  Btw, I really like the restructuring of the clj menu times into Clojure REPL and Start Clojure Console.

0

Does anyone have an example of how to "specify environment variables explicitly in the REPL using with-sh-env form"? I don't have any success finding examples. Specifically I assume I need to update the existing map, which is read-only. This is all a bit tricky for me, I'm trying to get labrepl working so I can learn some clojure, so  an exact example would be much appreciated

--PG

0
Avatar
Permanently deleted user

Peter,

I haven't quite figured it out but it seems to be something along the lines of:

(clojure.java.shell/with-sh-env {"SYSTEMROOT" '("C:\\windows")})

Now this doesn't actually seem to work as intended (at least running (get (into {} (System/getenv)) "SYSTEMROOT") returns nil), but it does run.

Any suggestions?

Mark

0

Sorry Mark - Beyond my expertise with the Java/Clojure environment currently...

--PG

0

Please sign in to leave a comment.