tools-deps

practicalli-johnny 2024-10-24T15:31:14.030639Z

Environment variables that I define in a shell config files (.bashrc .zshenv) are returning nil value in REPL run by clojure or clj script. The 'built-in' env vars like SHELL are returning correct values. e.g. I defined CLJ_WATSON_NVD_API_KEY in the .zshenv file, source the file and echo shows its value. Running clojure to start a repl and (System/getenv "SHELL") returns the full path of the current shell, but (System/getenv "CLJ_WATSON_NVD_API_KEY") returns nil If I pass the environment variable at the start of the clojure command, then I can see the correct value, e.g.

CLJ_WATSON_NVD_API_KEY=$CLJ_WATSON_NVD_API_KEY clojure
I get the same results regardless of Bash or Zsh and tried in both Gnome terminal and Kitty. Is there something in the clojure and clj scripts (or the way the JVM is run) that would prevent my own environment variables from being accessed correctly (or am I simply missing something laughcry ). I am sure I used to be able to do this last year 🤷‍♀️ • Clojure CLI version 1.11.1.1435 and 1.12.0.1479 • openjdk 21.0.1 2023-10-17

dpsutton 2024-10-24T15:38:22.964299Z

❯ echo $ALIASES
dev:ee:ee-dev:drivers:drivers-dev:socket:morse:reveal
❯ clj
Clojure 1.11.2
user=> (System/getenv "ALIASES")
nil
user=>
❯ ALIASES=$ALIASES clj
Clojure 1.11.2
user=> (System/getenv "ALIASES")
"dev:ee:ee-dev:drivers:drivers-dev:socket:morse:reveal"
user=>
❯ java -cp "$(clj -Spath)" clojure.main

Clojure 1.11.2
user=> (System/getenv "ALIASES")
nil
user=> ^D

dpsutton 2024-10-24T15:40:18.660899Z

but i can see some (System/getenv "JARS") works for me. in my .zshrc i have export JARS=~/projects/work/jars.

2024-10-24T15:43:07.361529Z

That sounds like you don't have the autoexport zsh setting turned on

practicalli-johnny 2024-10-24T15:46:16.816089Z

I tried on a different laptop and env vars are returning okay, so a shell issue sounds the most likely. I'll check for the autoexport zsh setting (and compare configs across laptops) Thanks for helping me narrow down the cause.

2024-10-24T15:46:33.698899Z

setopt allexport

💡 1