0

I am using Arch Linux with MATE as desktop environment. So terminal emulator is MATE Terminal. Recently I installed Jekyll with gem install jekyll. But when I ran jekyll -v it says bash: jekyll: command not found. So I tried to add path of Jekyll to PATH variable.

I ran PATH=$PATH/$HOME/.gem/ruby/2.2.0/bin and it worked perfectly. Now I can run jekyll commands. To add it permanently to PATH variable I edited the ~/.bash_profile file like following. It is not working after reboot. But source ~/.bash_profile works perfectly.

#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc

export PATH="${PATH}:/home/heisenberg/.gem/ruby/2.2.0/bin"

According to ArchWiki this is the proper way to concat something permanantly to PATH. But it isn't working. Can somebody figure me out where the wrong is?

[N. B. : Adding the same line in ~/.bashrc is doing okay.]

4ae1e1
  • 7,228
  • 8
  • 44
  • 77
taufique
  • 2,701
  • 1
  • 26
  • 40
  • What is the output of `echo "$PATH==="`? – chepner Nov 18 '15 at 17:44
  • @chepner, `/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl===` – taufique Nov 18 '15 at 17:53
  • How are you logging in/running bash when this doesn't work? – Etan Reisner Nov 18 '15 at 18:14
  • `source ~/.bash_profile` is working fine but after rebooting it is gone. :( – taufique Nov 18 '15 at 18:25
  • It sounds like `bash` isn't your login shell, so that `.bash_profile` isn't being sourced at all. – chepner Nov 18 '15 at 18:28
  • It worked now. I put the same line in `.bashrc` instead of `.bash_profile` and it worked, But why is that? – taufique Nov 18 '15 at 18:30
  • @chepner, `echo $SHELL` output is `/bin/bash` – taufique Nov 18 '15 at 18:34
  • @taufique, the difference between `.bash_profile` and `.bashrc` is that the former is run for a *login* shell, whereas the latter is run for an interactive shell that is *not* a login shell. This is described in the "INVOCATION" section of the bash man page. Is it possible that your login shell is something other than bash, and that you launch bash after login? – ghoti Nov 18 '15 at 19:03
  • I don't see how this is a programming question (well documented as it is). Please use `flag` link at the bottom of your Q to as a moderator to move to http://unix.stackexchange.com . Good luck. – shellter Nov 18 '15 at 19:22

1 Answers1

0

Depending on the option it is given, bash can be run as an interactive shell or login shell. The default interactive shell mode does not read ~/.bash_profile. login shell bash do.

See:

First, some setup:

% cat ~/.bashrc
…
export BASHRC="yes"
…
% cat ~/.bash_profile
…
export BASH_PROFILE="yes"
…

Now run a regular (interactive) bash:

% bash
[galaux@magenta ~]$ echo $BASHRC
yes
[galaux@magenta ~]$ echo $BASH_PROFILE

Notice we did not get yes with this last one.

Now with a login shell:

% bash --login
[galaux@magenta ~]$ echo $BASHRC
yes
[galaux@magenta ~]$ echo $BASH_PROFILE
yes

See paragraph INVOCATION from man bash.

galaux
  • 375
  • 2
  • 14