rbenv: rails: command not found immediately after installing rails 5.2.1

此生再无相见时 提交于 2021-01-29 04:55:38

问题


I have spent the whole day trying to upgrade from Rails 4x to 5.2.1. I was following this guide for the upgrade and I was not able to upgrade successfully.

Issue: After "successfully" installing Rails 5 using: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin17] and did rails -v I get:

rbenv: rails: command not found

The `rails' command exists in these Ruby versions:
  2.2.0

Things that I have tried: gem pristine different gems gem pristine --all this and played around with paths but no luck so far.

Any help would be greatly appreciated

Additionally here is my gem environment:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.6
  - RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-darwin17]
  - INSTALLATION DIRECTORY: /Users/Matt/.rvm/gems/ruby-2.2.0
  - USER INSTALLATION DIRECTORY: /Users/Matt/.gem/ruby/2.5.0
  - RUBY EXECUTABLE: /Users/Matt/.rbenv/versions/2.5.3/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/Matt/.rvm/gems/ruby-2.2.0/bin
  - SPEC CACHE DIRECTORY: /Users/Matt/Tools/.rbenv/versions/2.2.0/lib/ruby/gems/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/Matt/.rbenv/versions/2.5.3/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-17
  - GEM PATHS:
     - /Users/Matt/.rvm/gems/ruby-2.2.0
     - /Users/Matt/Tools/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/Matt/.rbenv/versions/2.5.3/bin
     - /usr/local/Cellar/rbenv/1.1.1/libexec
     - /Users/Matt/.rbenv/plugins/ruby-build/bin
     - /Users/Matt/.rbenv/shims
     - /Users/Matt/.rbenv/bin
     - /Users/Matt/anaconda/bin
     - /Library/Frameworks/Python.framework/Versions/3.5/bin
     - /Users/Matt/.rbenv/shims
     - /Users/Matt/.rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /opt/X11/bin

回答1:


You installed ruby using rbenv and now you can install gems. and rails is a gem for ruby. So, first to set the global version of Ruby you should create .ruby-version file in your home directory and write your installed ruby version (2.5.3) on it.

and then you should run gem install rails command to install rails.



来源:https://stackoverflow.com/questions/53688962/rbenv-rails-command-not-found-immediately-after-installing-rails-5-2-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!