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?
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 ~/.
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.
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.
Edit /usr/share/applications/eclipse.desktop with write privileges, i.e. sudo gedit /usr/share/applications/eclipse.desktop
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With