I added a new environment variable into ~/.zshrc
in macOS 13.2 few minites ago, this is the content about the variable in .zshrc
:
export ALT_DATABASE_URL=postgres://postgres:123456@reddwarf-postgresql.reddwarf-storage.svc.cluster.local:5432/alt
then run the source command to make it works:
source ~/.zshrc
check the variable:
> env|grep "DATABASE_URL"
DATABASE_URL=postgres://postgres:123456@127.0.0.1:5432/dolphin
CV_DATABASE_URL=postgres://postgres:123456@reddwarf-postgresql.reddwarf-storage.svc.cluster.local:5432/cv
ALT_DATABASE_URL=postgres://postgres:123456@reddwarf-postgresql.reddwarf-storage.svc.cluster.local:5432/alt
when I using this rust code to read the environment variable in visual studio code with lldb plugin:
fn main() {
let cv = std::env::var("CV_DATABASE_URL").expect("get cv url error");
print!("cv:{}", cv);
let alt = std::env::var("ALT_DATABASE_URL").expect("get alt url error");
print!("alt:{}", alt);
}
the newly add variable read failed:
thread 'main' panicked at 'get alt url error: NotPresent', src/main.rs:4:49
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cv:postgres://postgres:123456@reddwarf-postgresql.reddwarf-storage.svc.cluster.local:5432/cv%
am I missing something? what should I do to fixed this issue? I have do some investgate seems the visual studio code lldb plugin could not read the os environment variable.