7

I just recently switched over to using zsh with oh-my-zsh and I am having issues using the rails command line tool. Here are the steps that I ran through, and the error that I am receiving.

I ran the curl command that the github page provides:

curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh

Then I went to run rails s, this is the following error message that I receive:

.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)

This looks like I am having a gem error so I reinstalled rvm, rails and bundler with nothing solving the issue. However if I switch my terminal back over to bash then I dont have any issues and rails works perfectly fine. Has anyone else run into a similar issue? I want to use zsh because it seems like it has better features but if I can't use rails then I have to dump it to the curb.

These are the lines at the end of my .zshrc file:

export PATH=/Users/thomascioppettini/.rvm/gems/ruby-1.9.3p0/bin:/Users/thomascioppettini/.rvm/gems/ruby-1.9.3-p0@global/bin:/Users/thomascioppettini/.rvm/rubies/ruby-1.9.3-p0/bin:/Users/thomascioppettini/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
tomciopp
  • 2,602
  • 2
  • 31
  • 60

4 Answers4

11

What I have done to work bundle zsh and rvm, that is couple of body movies:

1) add to .zshrc at first line to correct find bin direcrory (your CO):

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

2) add next line after previous one:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

3) and at the end change PATH:

export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

For me it is work fine (now it correct define $PATH with all rvm gemsets)

mart7ini
  • 1,519
  • 2
  • 16
  • 21
7

did you put the

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

into your .zshrc?

I assume the rvm-installer installs it only into .bashrc

fenton
  • 134
  • 6
  • This is what exists at the bottom of my .zshrc file: export PATH=/Users/thomascioppettini/.rvm/gems/ruby-1.9.3-p0/bin:/Users/thomascioppettini/.rvm/gems/ruby-1.9.3-p0@global/bin:/Users/thomascioppettini/.rvm/rubies/ruby-1.9.3-p0/bin:/Users/thomascioppettini/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting – tomciopp Mar 05 '12 at 12:46
  • When I added the lines you suggested I still ran into the same issue – tomciopp Mar 05 '12 at 12:48
  • Looks like you only added rvm into your PATH. – fenton Mar 05 '12 at 12:48
  • Ah. Sorry... Posted to early and now I see your comment. You tried a "gem update --system"? – fenton Mar 05 '12 at 12:50
  • Btw: I'm just wondering _why_ you have the ruby version (1.9.3) explicitly being set in your .zshrc. I'd assume you have to use "rvm --default use ruby-1.9.3" _once_ and then rvm does the rest (using the environment script I posted in the beginning) – fenton Mar 05 '12 at 12:53
  • When oh-my-zsh was generated it included the line about RVM in the bottom of the zshrc file. I literally haven't touched anything other than changing the theme. – tomciopp Mar 05 '12 at 13:06
  • 1
    Hmm... It might be that this disturbs the rvm environment. Please try to remove these lines. I don't have any of them in _my_ .rvmrc. I see conflicts arise at least if you change your ruby version (rvm --use ...) – fenton Mar 05 '12 at 13:30
3

Ok I got it to work by deleting the path that was set in the zshrc and copying the rvm lines from my bash_profile in order to get the right configuration from rvm. If you run the following command in your terminal it should work:

cat ~/.bash_profile >> ~/.zshrc
tomciopp
  • 2,602
  • 2
  • 31
  • 60
  • it's somehow wrong, .zshrc should not be used for sourcing rvm, are you sure you do use login shell (-l swithc to zsh) ? some terminals like gnome-terminal or screen do not have it on as default. – mpapis Mar 06 '12 at 01:08
  • I don't know why my comment is getting negative votes, as this was the solution to my problem. Here were the missing code that I needed to add to the zshrc in order to get ruby to work properly: [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" – tomciopp Mar 06 '12 at 13:57
  • I got a down-vote because .zshrc is not the right place to source rvm, you should read this https://rvm.beginrescueend.com/support/faq/#shell_login - it was written for bash but the same rules apply to zsh, so put sourcing into `~/.zprofile` or `~/.zlogin` – mpapis Mar 06 '12 at 18:40
0

If you are using rbenv then copy this line from bash.rc which you can access by sudo gedit ~/.bashrc

export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/bin:$PATH"enter code here eval "$(rbenv init -)"

then paste it to zshrc, which can be accessed by sudo gedit ~/.zshrc