Environment variable not found in kotlin notebook
Need: Read variables from system env
System: Intellij IDEA (Ultimate), Windows 11
Context: Writing kotlin code in a kotlin notebook and reading an env variable
Problem:
System.getenv("USERNAME") ?: error("USERNAME not found")
System.getenv("AWS_DEFAULT_REGION") ?: error("AWS_DEFAULT_REGION not found")
USERNAME is found in system variables
AWS_DEFAULT_REGION is not found! Although it is set in “User environment variables” by hand.
The variable should be found. Best case scenario automatically by
DynamoDbClient.builder()
.credentialsProvider {
EnvironmentVariableCredentialsProvider.create().resolveCredentials()
}
Running the ipynb file in IDEA as “Run in IDE Process”, the variables are not found although i see them in notebook settings > JVM and Build > Environment variables.
Also when i set them in console, IDEA does not show the in “Include system environment variables”. Not after restart or any other way..
Can someone confirm this behavior or give a hint what i am doing wrong? Why is IDEA not listing the system variables although i set them and see them in the console or even in idea itself…
(i am new to notebooks and windows :))
thanks
Please sign in to leave a comment.
Hi Alexander Mas , may I know where the environment variable is stored? In the Run Configuration of your Project or the Environment Variable of Windows 11?
If the variable is newly added in the environment variable of Windows 11, please restart the IDE and try again.
Hi Alexander!
We had a similar issue reported, and restarting the IDE resolved it. Please share if you still encounter this problem - then we will try to fix it.
Hello, i apologize for the late response.
Jerome Guan I tried all possible locations. I added them in IDEA to the notebook settings > JVM and Build > Environment variables. I also tried to add them over the command line in Windows 11 (this way i was expecting to see them in the notebooks settings as well, but didn't. like explained in the original post). Restarting did not help.
@Teodor Irkhin Restarting the IDE did not help
thanks