从 RVM 切换到 rbenv 后,我的 ruby​​ gems 路径搞砸了? [英] My ruby gems path is messed up after switching from RVM to rbenv?

查看:46
本文介绍了从 RVM 切换到 rbenv 后,我的 ruby​​ gems 路径搞砸了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照此指南从 RVM 切换到 rbenv,现在我可以使用 bundler 和运行纯 ruby​​,但是当我运行 bin/rails sbin/rails g model ModelNamerails g model ModelName 时,我得到以下信息错误:

I made the switch from RVM to rbenv following this guideline and now I can use bundler and run pure ruby, but when I run bin/rails s, bin/rails g model ModelName, or rails g model ModelName I get the below error:

Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
/Users/home/Development/blogger/vendor/bundle/gems/json-1.8.3/lib/json/ext/parser.bundle: [BUG] Segmentation fault at 0x00000000000418
ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-darwin15.0]

此后还有大量崩溃报告,但我选择不包含它,因为它超过了允许的 StackOverflow 帖子长度,而且我认为它没有任何价值.

There is also a massive crash report following this, but I have chose not to include it because it is longer than the allowed StackOverflow post length, and I don't think it says anything of value.

我在 ruby​​ 2.1.2 上尝试过同样的事情并得到了相同的结果.我也做了 gem install ruby​​gems-update 成功运行和 gem pristine --all 得到这个错误:

I have tried the same thing with ruby 2.1.2 and got the same result. I have also done gem install rubygems-update which runs successfully and gem pristine --all which gets this error:

ERROR:  While executing gem ... (Gem::Exception)
    Failed to find gems ["==all"] >= 0

这是gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.4 (2014-10-27 patchlevel 265) [x86_64-darwin15.0]
  - INSTALLATION DIRECTORY: /Users/home/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /Users/home/.rbenv/versions/2.1.4/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/home/.rbenv/versions/2.1.4/bin
  - SPEC CACHE DIRECTORY: /Users/home/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-15
  - GEM PATHS:
     - /Users/home/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0
     - /Users/home/.gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/home/.rbenv/versions/2.1.4/bin
     - /usr/local/Cellar/rbenv/0.4.0/libexec
     - /Users/home/.rbenv/shims
     - /Users/home/.rbenv/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin

在 GEM PATHS 下,为什么路径会进入 2.1.0?这是我的旧版本 ruby​​,我很确定它甚至不再出现在我的机器上.它没有列在 rbenv 版本 下.这是问题吗?如何更改 gem 路径以及将其更改为什么?

Under GEM PATHS, why is the path going into 2.1.0? This is my old version of ruby which I'm pretty sure is not even on my machine any more. It is not listed under rbenv versions. Is this the problem? How do I change the gem path and what do I change it to?

我在 .bash_profile 中设置了 $PATH

I set the $PATH in my .bash_profile

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

我的 .profile 为空,echo $PATH 结果为:/Users/home/.rbenv/shims:/Users/home/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

My .profile is empty, and echo $PATH results in:/Users/home/.rbenv/shims:/Users/home/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

which ruby​​ 结果在 /Users/home/.rbenv/shims/ruby

另一个问题是,如果我尝试在我的主目录中使用 bundle 命令,我得到 Could not locate Gemfile or .bundle/directory即使 bundler 包含在我的 gem 列表中.

Another issue is if I try to use the bundle command in my home directory I get Could not locate Gemfile or .bundle/ directory even though bundler is included in my gem list.

我已经尝试卸载并重新安装 ruby​​ 至少 3 次,但每次都遇到相同的错误.我再一次相信问题出在我的 GEM PATH 上,但我没有足够的经验来知道如何解决它.谢谢.

I have tried uninstalling and reinstalling ruby at least three times, and I get the same errors every time. Once again I believe the problem is with my GEM PATH but I don't have enough experience to know how to fix it. Thank you.

推荐答案

原来的解决方案是删除我的 rails 项目并开始一个新项目.我还卸载并重新安装了我的 gems,并在创建新项目之前进行了 rbenv rehash.我想我应该发布一个答案,而不仅仅是删除问题,因为我没有看到删除和重新制作 rails 应用程序在任何其他关于此错误的几个问题的答复中.

Turns out the solution was just to delete my rails project and start a new one. I also uninstalled and reinstalled my gems, and did rbenv rehash before creating a new project. I figured I should post an answer and not just delete the question, because I did not not see delete and remake the rails app in any other responses to the few questions about this error out there.

这篇关于从 RVM 切换到 rbenv 后,我的 ruby​​ gems 路径搞砸了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆