0
votes

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
3
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 and followed the troubleshooting tips?the Tin Man
pastebin.com/kdqnfjEH <-- rvm info , I followed the instructions on the official rvm page yesJ-Dizzle
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
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

3 Answers

1
votes

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.

1
votes

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"

0
votes

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"