Why, rails server not running in zsh terminal?

1.2k views Asked by At

After installing zsh i'm unable to start rails server i'm getting the following error:

In bash it is working properly

Error:

╭─love@Love ~/rails/nbt1 ‹system› ‹master*› 
╰─➤  rs
Could not find rake-10.1.0 in any of the sources
╭─love@Love ~/rails/nbt1 ‹system› ‹master*› 
╰─➤  bundle                                                                                                                                7 ↵
/usr/lib/ruby/1.8/fileutils.rb:243:in `mkdir': Permission denied - /var/lib/gems  (Errno::EACCES)
from /usr/lib/ruby/1.8/fileutils.rb:243:in `fu_mkdir'
from /usr/lib/ruby/1.8/fileutils.rb:217:in `mkpath'
from /usr/lib/ruby/1.8/fileutils.rb:215:in `reverse_each'
from /usr/lib/ruby/1.8/fileutils.rb:215:in `mkpath'
from /usr/lib/ruby/1.8/fileutils.rb:201:in `each'
from /usr/lib/ruby/1.8/fileutils.rb:201:in `mkpath'
from /usr/lib/ruby/1.8/pathname.rb:1035:in `mkpath'
from /usr/lib/ruby/vendor_ruby/bundler/installer.rb:15:in `run'
from /usr/lib/ruby/vendor_ruby/bundler/installer.rb:8:in `install'
from /usr/lib/ruby/vendor_ruby/bundler/cli.rb:222:in `install'
from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `send'
from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `run'
from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor.rb:246:in `dispatch'
from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/base.rb:389:in `start'
from /usr/bin/bundle:13
╭─love@Love ~/rails/nbt1 ‹system› ‹master*› 
╰─➤  bash                                                                                                                                  1 ↵
love@Love:~/rails/nbt1$ rails -v
Rails 3.2.14
love@Love:~/rails/nbt1$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
love@Love:~/rails/nbt1$ 

I have placed this line at the end of ~/.zshrc.

 source $ZSH/oh-my-zsh.sh
3

There are 3 answers

0
Patrick Brinich-Langlois On

I had my PATH configured correctly, but I was still getting the error. Adding the following to my .zshrc file fixed the problem:

unalias rails
unalias rake
0
Adnan Bilaç On

Below code add to ~/.zshrc in last

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
0
Sumit Munot On

I think yes, the rails wrapper script was moved to the bin directory, there might be compatibility issue.

Couple of things to get it work, bundle zsh and rvm,

1) Add to .zshrc at first line to correct find bin direcrory:

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

Now it correct define $PATH with all rvm gemsets

It's work fine for me.

Thanks.

Helpful link http://railscasts.com/episodes/308-oh-my-zsh