1

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?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
ehsan
  • 13
  • 4
  • 1
    use `export PATH=$PATH:/home/ehsan/.gem/ruby/2.3.0/bin` and put that line in `~/.bashrc` – Rahul Jul 27 '16 at 06:06
  • 1
    @Rahul No, [not `.bashrc`](http://unix.stackexchange.com/questions/3052/is-there-a-bashrc-equivalent-file-read-by-all-shells/3085#3085). Don't set environment variables in `.bashrc`. – Gilles 'SO- stop being evil' 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 01:19

1 Answers1

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.

cas
  • 1
  • 7
  • 119
  • 185