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?

评论操作 固定链接

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
评论操作 固定链接

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
评论操作 固定链接

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

请先登录再写评论。