1

I have installed Eclipse Oxygen;when I type

 export PATH=$PATH:/home/ivan/java-oxygen/eclipse

in the bash, I can launch eclipse from bash from any location, however, no matter whether I add

PATH=$PATH:/home/ivan/java-oxygen/eclipse

or

export PATH=$PATH:/home/ivan/java-oxygen/eclipse

to /.bashrc or /etc/bash.bashrc, I cannot launch Eclipse without typing

export PATH=$PATH:/home/ivan/java-oxygen/eclipse

every time I launch the new bash.

NiHao92
  • 141
  • Post an echo $PATH output from a new bash session. – L29Ah Aug 13 '17 at 10:29
  • @L29Ah /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: /usr/local/games:/home/ivan/Documents/node-v6.11.0-linux-x64/bin/ – NiHao92 Aug 13 '17 at 11:36
  • @GAD3R doesn't work – NiHao92 Aug 13 '17 at 11:36
  • Are there additional PATH definitions? grep PATH /etc/bash.bashrc ~/.bashrc Did you really mean /.bashrc or is that a typo? Add the line echo foo below your export PATH line and see whether it is executed. – Hauke Laging Aug 13 '17 at 12:23
  • @HaukeLaging solved. What needed was to add export PATH=$PATH:/home/ivan/java-oxygen/eclipse to ~/.profile – NiHao92 Aug 13 '17 at 13:02
  • Seems like a lot of people like to argue about .bashrc vs .bash_profile but as Gilles pointed out in a previous post, and I agree: Environment variables should be set in one of the profile files as they should only need to be set once at login. That being said I think it should still be working if placed in .bashrc so this isn't being offered as a solution to the problem. – jesse_b Aug 13 '17 at 13:03
  • @NiHao92 You can have your .profile file source your .bashrc and it shouldn't be an issue. – jesse_b Aug 13 '17 at 13:04
  • @Jesse_b in my case, it should have been in ~/.profile. Can you explain, please, why all these differences in locations of PATH vars? – NiHao92 Aug 13 '17 at 13:04
  • .bash_profile is sourced when you start a login bash shell. .profile is used by all (maybe not all?) other shells for the same purpose, additionally some systems don't have a .bash_profile or you can remove your .bash_profile altogether and this will cause bash to use .profile. .bashrc is sourced whenever you start an interactive shell. http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html – jesse_b Aug 13 '17 at 13:07
  • @Jesse_b however, somewhy adding echo.. to .bash_profile made no effect – NiHao92 Aug 13 '17 at 13:20
  • Well you mentioned your default shell is /bin/sh I'm not sure where that points on linux mint (readlink -f /bin/sh). If it's pointing to /bin/dash it may not source your .bash_profile. Also did you log out and back in or just open a new terminal? – jesse_b Aug 13 '17 at 13:22
  • @Jesse_b just opened. But somewhy with ~/.profile that worked – NiHao92 Aug 13 '17 at 13:27
  • It depends on what terminal app you're using then. Some terminal apps will source your .profile or .bash_profile each time you open it. In this case I think .bash_profile is not being called because your default shell is dash and not bash. – jesse_b Aug 13 '17 at 13:29
  • @Jesse_b maybe that's cuz I am using xfce, not gnome or kde? – NiHao92 Aug 13 '17 at 13:41

1 Answers1

0

Maybe just for the sake of clarity

/.bashrc would be a file in your root directory /. This file could never be read by any user.

On the other hand ~/.bashrc means the .bashrc file from the current user.

Another option is to edit the .bashrc file in your /etc/skel directory, this change is global and every user in the system would have it as default when created.

.bash_profile as the official docs say:

This is the preferred configuration file for configuring user 
environments individually. In this file, users can add extra 
configuration options or change default settings:

This file adds some per user extra variables.

PS. If we talk about security, it is not recommendable to have exec paths in your home directory, the most secure option would be to have your eclipse in some place like /opt and as root create a symlink to the binary like:

cd /usr/bin 
ln -s /opt/path/to/eclipse

This will produce a link for all the users and you won't need to add this specific ( and probably dangerous ENV var for every user)