Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse doesn't use the path set in .bashrc

whenever I run eclipse from the shortcut I am unable to correctly build some of my projects because the PATH variable that I configured in .bashrc doesn't get used.

When I run eclipse from my terminal, I can build all my projects perfectly fine because it's running through the correct shell.

The problem is that I want to use the PATH variable from my .bashrc without permanently having a terminal open. I tried this before, but every day I accidentally close the terminal that's running eclipse by accident and lose all my unsaved code.

Can anyone help me?

like image 866
JREN Avatar asked Aug 07 '13 09:08

JREN


People also ask

How do you set a PATH in bash?

For Bash, you simply need to add the line from above, export PATH=$PATH:/place/with/the/file, to the appropriate file that will be read when your shell launches. There are a few different places where you could conceivably set the variable name: potentially in a file called ~/. bash_profile, ~/. bashrc, or ~/.

Do we need to set environment variables for Eclipse?

You can also define an environment variable that is visible only within Eclipse. Go to Run -> Run Configurations... and Select tab "Environment". There you can add several environment variables that will be specific to your application. Max, this is applicable only for the current running Program.


2 Answers

Your tooling probably utilizes the embedded eclipse terminal. This terminal does not start providing your login/user shell. So you need to set the eclipse terminal in your Eclipse preferences to start as --login shell:

Go to:

Preferences -> Terminal -> Local Terminal

and set

"Arguments" to "--login"

restart Eclipse and your users $PATH should be used from now on.

like image 99
Martin Peter Avatar answered Nov 10 '22 23:11

Martin Peter


  1. Edit /usr/share/applications/eclipse.desktop with write privileges, i.e. sudo gedit /usr/share/applications/eclipse.desktop

  2. Change the setting Exec=/usr/bin/eclipse to Exec=bash -ic "/usr/bin/eclipse" and save

The underlying issue is that .bashrc is not loaded in a non-interactive shell. When you start Eclipse normally clicking on its symbol, .bashrc quits early. This solution applies to all programs that are defined by a .desktop file. In contrast, bash -i opens an interactive shell, -c "" runs a command in that shell.

like image 12
SpamBot Avatar answered Nov 10 '22 21:11

SpamBot