15

I am using IntelliJ IDEA, and it uses some of the environment variables defined in the .bashrc script.

If I run its shell script from the terminal everything works fine but if I create a .desktop file to run it from the launcher then it is loaded without the .bashrc environment.

I also tried using the "Run with terminal" option and it doesn't help. Is there a way to do those things?

The content of the desktop file:

[Desktop Entry]
Version=1.0
Type=Application
Name=IntelliJ IDEA
Icon=/home/gmarom/bin/idea-IU-135.1230/bin/idea.png
Exec="/home/gmarom/bin/idea-IU-135.1230/bin/idea.sh" %f
Comment=Develop with pleasure!
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-idea
4
  • Please edit to include information like that. What error does it give (if any) in terminal?
    – Tim
    Oct 27, 2014 at 7:39
  • 1
    You might want to add your .desktop file, and what is the env. variable? Oct 27, 2014 at 7:39
  • 4
    Just source .bashrc in your script.
    – muru
    Oct 27, 2014 at 7:46
  • One of the env variables missing is M2_HOME. I prefer IDEA to take the variables from the .bashrc instead of configuring the maven path manually.
    – Guy Marom
    Oct 27, 2014 at 8:12

3 Answers 3

9

When running from a launcher, the idea.sh script is started using a non-iteractive shell. In your .bashrc make sure the environment variables are exported before

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

Or alternatively place the environment variable exports in ~/.bash_profile

3
  • This did not work for me.
    – IARI
    Sep 21, 2016 at 14:11
  • 2
    @IARI did you relogin? Also note that Ubuntu uses ~/.profile instead of ~/.bash_profile
    – Lesswire
    Feb 1, 2018 at 16:50
  • thx - can't remember if I had overseen any of that - right now I'm not working with ubuntu, so I also cant reproduce.
    – IARI
    Feb 1, 2018 at 20:22
9

Moving the environment variables to .profile didn't work for me. Instead, I removed the code that @oliman suggests from my .bashrc and then I changed the my IntelliJ IDEA's launcher from this:

"/opt/idea-IU-163.12024.16/bin/idea.sh" %f

to this:

bash -c "source ~/.bashrc && /opt/idea-IU-163.12024.16/bin/idea.sh %f"
4

For me the fix was to move the environment variables from .bashrc to .profile and relogin. Komodo Edit now picks up the perlbrewed Perl from PATH.

https://help.ubuntu.com/community/EnvironmentVariables was very helpful.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .