In my .zshrc startup script I set some environment variables export FOO="BAR" which I’d like to use in Julia.
From a terminal I get
But from a VS code interactive session using shift+enter
Gives ERROR: KeyError: key "FOO" not found so it seems that the interactive session doesn’t execute the .zshrc. Previously this didn’t seem to be an issue, I’ve only noticed this since updating to MacOS 13.0, but I cannot confirm the update is related.
Yes, I was thinking could you run your .zshrc from Julia? You CAN… but it would clear out the ENVs when the process exits, as specified. I don’t know if there’s a workaround for that, I tried to google it, but gave up, though I was helpful already.
Well, I was thinking, that’s just standard shell/bash (and I guess .zshrc) code. I was aiming for as simple as possible, for you, at least on the shell side, and see it was just “standard env files”. I’ve never parsed JSON in a shell, it wasn’t invented (nor web browsers) when I started using shells… I’m sure it’s possible, just seemed like a heavier dependency (on both sides). Plain text files are as standard as they come (in Unix/LInux, and I guess by now in macOS), JSON (or e.g. XML) only needed for hierarchical, and extensibility which you don’t need there.
You wouldn’t even have to parse it on the shell side:
. FILE # POSIX compliant
Actually I forget export, and it should still be trivial to parse (and exclude that) on the Julia side:
export VARNAME="my value" # shorter, less portable version
@fredrikekre I see export isn’t used by DotEnv.jl files, and I think needed in shells, for sub-shells (or some workaround to not need that?).