问题
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]
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.
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
Here is the result of 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
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?
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
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
results in /Users/home/.rbenv/shims/ruby
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.
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.
回答1:
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.
回答2:
@usernm ... I think you should have a GEMFILE
in your directory . Problem is pretty confusing . So just try to add ruby 'version'
on the top line. I hope this is one option to look at . Well example would be:
ruby '2.1.4'
来源:https://stackoverflow.com/questions/36387192/my-ruby-gems-path-is-messed-up-after-switching-from-rvm-to-rbenv