0

I don't understand what's going on here. I can do this in my shell script after installing ruby/rails/rspec/cucumber with RVM then 3x gem install __.

[name@server subapp]$ which ruby
~/.rvm/rubies/ruby-2.0.0-p481/bin/ruby
[name@server subapp]$ which rails
~/.rvm/gems/ruby-2.0.0-p481/bin/rails
[name@server subapp]$ which rspec
~/.rvm/gems/ruby-2.0.0-p481/bin/rspec
[name@server subapp]$ which cucumber
~/.rvm/gems/ruby-2.0.0-p481/bin/cucumber
[name@server subapp]$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [x86_64-linux]
[name@server subapp]$ rails -v
Rails 4.1.6
[name@server subapp]$ rspec -v
3.1.2
[name@server subapp]$ cucumber --version
1.3.16

Then I open a new shell window, and I source ~/.bashrc and say which ruby.

[name@server rubyDev]$ source ~/.bashrc
[name@server rubyDev]$ which ruby
/usr/bin/which: no ruby in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/name/.rvm/bin:/home/name/.rvm/bin:/home/name/.rvm/bin:/home/name/.rvm/bin)
[name@deliv rubyDev]$ ruby -v
-bash: ruby: command not found

Oh, and cucumber doesn't work, even before I open a new shell window. That looks like this: http://pastebin.com/WvMy6gQu ... I feel like a lot of things are going wrong with my install, but I don't know what or how to mend it. I installed this all yesterday and cucumber was working, I open the shell and it acts like it's never had cucumber or even ruby installed.

System info Centos 6.5 via ssh.

rvm info:
ruby-2.1.2:

  system:
    uname:       "Linux deliv.dev.corp.lyris.com 2.6.32-431.17.1.el6.x86_64 #1 SMP Wed May
7 23:32:49 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux"
    system:      "centos/6/x86_64"
    bash:        "/bin/bash => GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.25.30 (stable) by Wayne E. Seguin , Michal
 Papis  [https://rvm.io/]"
    updated:      "1 hour 12 minutes 42 seconds ago"
    path:         "/home/name/.rvm"

  ruby:
    interpreter:  "ruby"
    version:      "2.1.2p95"
    date:         "2014-05-08"
    platform:     "x86_64-linux"
    patchlevel:   "2014-05-08 revision 45877"
    full_version: "ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]"

  homes:
    gem:          "/home/name/.rvm/gems/ruby-2.1.2"
    ruby:         "/home/name/.rvm/rubies/ruby-2.1.2"

  binaries:
    ruby:         "/home/name/.rvm/rubies/ruby-2.1.2/bin/ruby"
    irb:          "/home/name/.rvm/rubies/ruby-2.1.2/bin/irb"
    gem:          "/home/name/.rvm/rubies/ruby-2.1.2/bin/gem"
    rake:         "/home/name/.rvm/gems/ruby-2.1.2/bin/rake"

  environment:
    PATH:         "/home/name/.rvm/gems/ruby-2.1.2/bin:/home/name/.rvm/gems/ruby-2.
1.2@global/bin:/home/name/.rvm/rubies/ruby-2.1.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/hom
e/name/.rvm/bin:/home/name/.rvm/bin:/usr/local/sbin:/home/name/.rvm/bin"
    GEM_HOME:     "/home/name/.rvm/gems/ruby-2.1.2"
    GEM_PATH:     "/home/name/.rvm/gems/ruby-2.1.2:/home/name/.rvm/gems/ruby-2.1.2@
global"
    MY_RUBY_HOME: "/home/name/.rvm/rubies/ruby-2.1.2"
    IRBRC:        "/home/name/.rvm/rubies/ruby-2.1.2/.irbrc"
    RUBYOPT:      ""
    gemset:       ""
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
export PATH="$HOME/.rvm/rubies/ruby-2.0.0-p481/bin:$PATH" #hack-fix
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
J-Dizzle
  • 3,176
  • 6
  • 31
  • 49
  • http://stackoverflow.com/questions/4911504/rvm-installed-by-ruby-not-working – Nimir Sep 12 '14 at 16:43
  • Why do you "source ~/.bashrc"? That's done automatically by the shell at login. Append the output of `rvm info` to your question by editing it and copy/pasting that information. How did you install RVM and what instructions did you follow? Have you read through [the official RVM installation page](http://rvm.io/rvm/install) and followed the troubleshooting tips? – the Tin Man Sep 12 '14 at 16:53
  • http://pastebin.com/kdqnfjEH <-- rvm info , I followed the instructions on the official rvm page yes – J-Dizzle Sep 12 '14 at 16:59
  • It looks like `/etc/profile.d/rvm.sh` or something similar to it is not being loaded when your shell starts. Without that RVM doesn't work. – tadman Sep 12 '14 at 17:00
  • No, don't use paste bin to supply information that is necessary for you question. Links rot away, then break, making your question difficult to use when future people search for similar answers. In addition, you discourage potential answerers from helping you by making them chase down the needed information. – the Tin Man Sep 12 '14 at 17:00
  • Wanted to avoid a wall of text but I'll put it directly into the question, thank you – J-Dizzle Sep 12 '14 at 17:00
  • @tadman so.... what next? – J-Dizzle Sep 12 '14 at 17:04
  • Have a look for where `rvm.sh` ended up and make sure that's loaded when you log in. Typically this shows up in your `.bashrc` or `.bash_profile` file near the end to get RVM running. It may also be in `/etc` if you've done a root install. – tadman Sep 12 '14 at 17:13
  • edited bashrc into question, essentially all bash_profile has is export PATH – J-Dizzle Sep 12 '14 at 17:18
  • I installed ruby with `\curl -sSL https://get.rvm.io | bash -s stable --ruby` – J-Dizzle Sep 12 '14 at 17:24

3 Answers3

1

Login vs. Interactive Shell Startup

IIRC, RVM is rather opinionated about where it installs itself in your shell startup scripts. One of the things it used to do (and may still do) is install to ~/.bash_profile rather than ~/.profile or ~/.bashrc.

This doesn't work for me personally, so the first thing I do after installing RVM is to remove any newly-created ~/.bash_profile (so that Bash uses ~/.profile instead) and paste:

PATH=$HOME/.rvm/bin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

at the bottom of my ~/.bashrc file so that RVM runs in every interactive shell, rather than just in login shells.

It may also help to understand more about your shell's startup file precedence. Your mileage may vary.

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
  • @J-Dizzle If RVM creates ~/.bash_profile, it then takes precedence over ~/.profile. If you *use* ~/.bash_profile, don't delete it; it just may surprise you when you realize that your shell is no longer sourcing ~/.profile if that's the behavior you're expecting. That's one of the many reasons YMMV. See https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html for more info on precedence. – Todd A. Jacobs Sep 12 '14 at 17:44
  • thorough and informative. now every time I start up a shell I've got everything and cucumber on command. – J-Dizzle Sep 12 '14 at 17:52
1

A possible solution is to not maintain two different configuration files .bash_profile and .bashrc

The solution as suggested in this excellent post on the difference between .bash_profile and .bashrc is to source .bashrc from your .bash_profile file, then putting PATH and common settings in .bashrc.

Quoting, "add the following lines to .bash_profile:

if [ -f ~/.bashrc ]; then source ~/.bashrc fi"

osehgol
  • 111
  • 1
  • 5
0

Add your binary executable path(i.e. ~/.rvm/rubies/ruby-2.0.0-p481/bin) into your $PATH environment in .bashrc if default shell is bash or in .profile if ksh is default.

 PATH="$HOME/.rvm/rubies/ruby-2.0.0-p481/bin:$PATH"
Amit Kumar
  • 313
  • 1
  • 4
  • 14
  • This solves the ruby problem.. do I rinse and repeat to solve the rails, rspec, and cucumber problem? – J-Dizzle Sep 12 '14 at 17:12
  • 1
    That's a pretty messy solution to this problem and also locks you in to a specific version, defeating the entire point of RVM. – tadman Sep 12 '14 at 17:12
  • @J-Dizzle : yes it will solve your problem, but as tadman said, it will lock you to specific version of ruby. But if we see your problem, its only with your path variable which need to be set manually or your binary should have soft link to existing path variable (in most of the case /usr/bin or /usr/local/bin). – Amit Kumar Sep 12 '14 at 17:17
  • I don't care too much about being locked into a version of ruby, I just want to be using cucumber already – J-Dizzle Sep 12 '14 at 17:20
  • Then you can go with the solution and it will defiantly works. Enjoy !!! and not to mention, mark as answered if it worked for you. – Amit Kumar Sep 12 '14 at 17:22