简体   繁体   English

切换到zsh会在命令行中断开rails

[英]Switching over to zsh breaks rails in command line

I just recently switched over to using zsh with oh-my-zsh and I am having issues using the rails command line tool. 我刚刚切换到使用zsh和oh-my-zsh,我在使用rails命令行工具时遇到了问题。 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: 我运行了github页面提供的curl命令:

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: 然后我去运行rails s,这是我收到的以下错误消息:

.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. 这看起来像我有一个宝石错误所以我重新安装rvm,rails和bundler没有解决问题。 However if I switch my terminal back over to bash then I dont have any issues and rails works perfectly fine. 但是,如果我将我的终端切换回bash,那么我没有任何问题,导轨工作得非常好。 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. 我想使用zsh,因为它似乎有更好的功能,但如果我不能使用rails,那么我必须将其转储到路边。

These are the lines at the end of my .zshrc file: 这些是我的.zshrc文件末尾的行:

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

What I have done to work bundle zsh and rvm, that is couple of body movies: 我做了什么工作捆绑zsh和rvm,这是几部身体电影:

1) add to .zshrc at first line to correct find bin direcrory (your CO): 1)在第一行添加.zshrc以更正查找bin direcrory(您的CO):

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting PATH = $ PATH:$ HOME / .rvm / bin#将RVM添加到PATH以进行脚本编写

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

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . [[-s“$ HOME / .rvm / scripts / rvm”]] &&。 "$HOME/.rvm/scripts/rvm" “$ HOME / .rvm /脚本/ RVM”

3) and at the end change PATH: 3)并在最后改变路径:

export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games 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) 对我来说它工作正常(现在它正确定义所有rvm gemsets的$ PATH)

did you put the 你放了吗?

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

into your .zshrc? 进入你的.zshrc?

I assume the rvm-installer installs it only into .bashrc 我假设rvm-installer只将它安装到.bashrc中

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. 好的,我通过删除zshrc中设置的路径并从我的bash_profile复制rvm行以便从rvm获得正确的配置来实现它。 If you run the following command in your terminal it should work: 如果在终端中运行以下命令,它应该工作:

cat ~/.bash_profile >> ~/.zshrc

If you are using rbenv then copy this line from bash.rc which you can access by sudo gedit ~/.bashrc 如果您正在使用rbenv,那么从bash.rc复制此行,您可以通过sudo gedit ~/.bashrc访问该行

export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/bin:$PATH" enter code here eval "$(rbenv init -)" export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/bin:$PATH"在这里输入代码eval "$(rbenv init -)"

then paste it to zshrc, which can be accessed by sudo gedit ~/.zshrc 然后将其粘贴到zshrc,可以通过sudo gedit ~/.zshrc .zshrc访问

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

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