Setting fish shell environment variables correctly for julia shell

I need to come back to an old question. I am unable to see my system ENV variables in the julia shell.

I set the env vars in fish with set -U key value like so:

floswald@PTL11077 ~> set -U JULIA_VAR howdie
floswald@PTL11077 ~> head ~/.config/fish/fish_variables
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR JULIA_VAR:howdie

and I can get this variable in any new login shell on my machine:

Last login: Sat Nov 12 12:01:20 on ttys003
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
floswald@PTL11077 ~> echo $JULIA_VAR 
howdie

notice that this fish shell is my default login shell:

floswald@PTL11077 ~> echo $SHELL
/opt/homebrew/bin/fish

however, I cannot see the variable in the shell that is called by julia:

floswald@PTL11077 /etc [1]> julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.0 (2022-08-17)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

shell> echo $SHELL
ERROR: UndefVarError: SHELL not defined
Stacktrace:
 [1] top-level scope
   @ none:1

shell> echo $JULIA_VAR
ERROR: UndefVarError: JULIA_VAR not defined
Stacktrace:
 [1] top-level scope
   @ none:1

shell> 

This is trying to interpolate a Julia variable SHELL into the command:

julia> SHELL = "hello, world";

shell> echo $SHELL
hello, world

Compare with

shell> echo $(ENV["SHELL"])
/bin/bash

shell> bash -c 'echo $SHELL'
/bin/bash

good point! - that’s obviously wrong. notice however that this was not the solution - the ENV var was still invisible. fully due to my ignorance about my own shell. anyway, hopefully some other fish users could use this. The key is to set the fish variable not only as Universal but also as exported:

floswald@PTL11077 > set -U JULIA_VAR howdie
floswald@PTL11077 > julia -q -e 'using Test; @test haskey(ENV,"JULIA_VAR")'
Test Failed at none:1
  Expression: haskey(ENV, "JULIA_VAR")
ERROR: There was an error during testing

now set the env variable with the export (x) flag:

floswald@PTL11077 > set -Ux JULIA_VAR howdie
floswald@PTL11077 > julia -q -e 'using Test; @test haskey(ENV,"JULIA_VAR")'
floswald@PTL11077 >