vaibhavatul47
vaibhavatul47

Reputation: 2895

Environment variables not found in IntelliJ using zsh

I switched to zsh from bash. I updated the shell in Preferences > Terminal settings inside RubyMine.

But, now environment variables are not being loaded inside my Rails application. I can still access them inside the terminal in RubyMine editor!

I tried printing the value of environment variable inside a yml file (where all the DB related environment variables are required). I could access the home variable but not custom variables set by me.

Database.yml file:

database.yml file

Output while starting Rails server in Rubymine:

Output while starting Rails server in Rubymine

Output inside Rubymine terminal:

Output inside Rubymine terminal

My /etc/zshrc:

My zshrc

DB settings inside my vaibhavatul47_zsh_profile.sh file:

DB settings inside my custom profile file

Upvotes: 3

Views: 5161

Answers (2)

ori888
ori888

Reputation: 750

Check that your env var are loaded correctly in the terminal and then open IDE from the terminal. Then check if the build configuration env vars contains the profile env vars.

Before opening the idea make sure your environment variables are actually loaded when running the terminal:

  1. open your zsh profile (vim ~/.zshrc)
  2. insert a test env var (something like TEST_1="mytest")
  3. restart the terminal and check if you see TEST_1 value (echo $TEST_1)

In case you see TEST_1 value open intelij idea by entering "idea ."

Now, open your module build configuration and look for the env vars list, check if they contain your zsh env vars (or you can type "echo TEST_1" in the idea terminal) gl:)

Upvotes: 0

rdj7
rdj7

Reputation: 1955

Automatic loading Environment variables from bash into IntelliJ works while reading and loading from zsh doesn't work for Intellij.

Starting IntelliJ from Terminal will load environment variables from zsh too, please try following:

open -a "IntelliJ IDEA"

Note: here IntelliJ IDEA is name of my application, in case you have renamed your IntelliJ application to something else please enter that.

Hope this helps!

Upvotes: 4

Related Questions