简体   繁体   English

为什么,Rails服务器无法在zsh终端中运行?

[英]Why, rails server not running in zsh terminal?

After installing zsh i'm unable to start rails server i'm getting the following error: 安装zsh后,我无法启动Rails服务器,出现以下错误:

In bash it is working properly 在bash中,它工作正常

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 . 我将这一行放在~/.zshrc的末尾。

 source $ZSH/oh-my-zsh.sh

I think yes, the rails wrapper script was moved to the bin directory, there might be compatibility issue. 我认为是的,Rails包装器脚本已移至bin目录,可能存在兼容性问题。

Couple of things to get it work, bundle zsh and rvm, 使它起作用的几件事,将zsh和rvm捆绑在一起,

1) Add to .zshrc at first line to correct find bin direcrory: 1)在第一行中添加.zshrc以更正查找bin direcrory的方法:

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

2) Add next line after previous one: 2)在上一个之后添加下一行:

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

3) And at the end change PATH: 3)最后更改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 现在,它$PATH with all rvm gemsets正确定义$PATH with all rvm gemsets

It's work fine for me. 对我来说很好。

Thanks. 谢谢。

Helpful link http://railscasts.com/episodes/308-oh-my-zsh 有用的链接http://railscasts.com/episodes/308-oh-my-zsh

I had my PATH configured correctly, but I was still getting the error. 我的PATH配置正确,但是仍然出现错误。 Adding the following to my .zshrc file fixed the problem: 将以下内容添加到我的.zshrc文件中可解决此问题:

unalias rails
unalias rake

Below code add to ~/.zshrc in last 下面的代码最后添加到〜/ .zshrc

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM