1

This question already has an answer here:

I am trying to add ruby binaries to my path with this :

$ PATH=$PATH:/home/ehsan/.gem/ruby/2.3.0/bin

This works fine in that terminal session and I get :

$ rails -v
Rails 5.0.0

But after I close that terminal session and open new one and I enter rails :

$ rails -v
rails : command not found

Any ideas?

marked as duplicate by Gilles, Kusalananda, roaima, don_crissti, Jeff Schaller Jul 27 '16 at 23:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    use export PATH=$PATH:/home/ehsan/.gem/ruby/2.3.0/bin and put that line in ~/.bashrc – Rahul Jul 27 '16 at 6:06
  • 1
    @Rahul No, not .bashrc. Don't set environment variables in .bashrc. – Gilles Jul 27 '16 at 21:56
  • there's nothing wrong with setting env vars in ~/.bashrc. it's useful to set vars etc for both login and non-login environments, and can be sourced from ~/.bash_profile or ~/.profile. – cas Jul 28 '16 at 1:19
2

PATH is an environment variable like any other.

To make a permanent change, put it in the startup script for your shell. e.g. ~/.bashrc or ~/.bash_profile or for bash. or ~/.profile for bash and other bourne-like shells.

Not the answer you're looking for? Browse other questions tagged or ask your own question.