所以我的目标是在Windows 10上将Rails从5.0.6升级到最新版本,以便遵循使用它的教程。如果我理解正确,那么我需要安装RVM才能升级我的Rails版本。从RVM站点https://rvm.io/rvm/install开始安装它的第一个命令是:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BD
然而我收到以下错误:
'gpg' is not recognized as an internal or external command,
operable program or batch file.
所以我的问题是,我是否需要安装RVM,如果是,我该如何进行?
如果我升级到Rails 5.1.5,我用我的5.0.6制作的应用程序是否会向后兼容,仍可在我的机器上运行或者它们会破坏吗?我对升级问题感到很困惑,因为所有关于升级的视频和文章似乎都涉及升级个人应用而不是实际的Rails软件本身。
编辑1:添加了gemfile
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
ruby '2.2.6'
gem 'rails', '~> 5.1.2'
# Rails defaults
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# learn-rails
gem 'bootstrap-sass'
gem 'gibbon'
gem 'high_voltage'
gem 'jquery-rails'
group :development do
gem 'better_errors'
gem 'rails_layout'
end
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
group :test do
gem 'minitest-spec-rails'
end
现在rails服务器无法启动错误:
C:\Sites\learn-rails>rails s
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.14.5/lib/bundler/rubygems_ext.rb:45:in `full_gem_path': uninitialized constant Bundler::Plugin::API::Source (NameError)
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/basic_specification.rb:145:in `block in full_require_paths'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/basic_specification.rb:144:in `map'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/basic_specification.rb:144:in `full_require_paths'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/basic_specification.rb:77:in `contains_requirable_file?'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/specification.rb:949:in `block in find_in_unresolved'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/specification.rb:949:in `each'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/specification.rb:949:in `find_all'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/specification.rb:949:in `find_in_unresolved'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:74:in `require'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.14.5/lib/bundler/plugin/api/source.rb:2:in `<top (required)>'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.14.5/lib/bundler/rubygems_ext.rb:45:in `full_gem_path'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/basic_specification.rb:145:in `block in full_require_paths'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/basic_specification.rb:144:in `map'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/basic_specification.rb:144:in `full_require_paths'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/specification.rb:1370:in `add_self_to_load_path'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/specification.rb:1283:in `activate'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:67:in `block in gem'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:66:in `synchronize'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:66:in `gem'
from C:/Sites/learn-rails/bin/spring:14:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
答案 0 :(得分:1)
你没有让拥有一个Ruby版本管理器(如RVM)来使用Rails,但是如果您打算在多个项目上工作,建议您使用。与Gemfiles使用相同的宝石保持每个人同步的方式类似,Ruby版本管理器也可以帮助确保每个人都使用相同版本的Ruby。
这里的主要复杂因素是您使用的是Windows,RVM 不支持。如果你想使用RVM,你需要使用像cgywin这样的东西,或者在Windows上试用Ubuntu。
或者,您可以尝试使用Windows本机工具,例如Uru。
您可以继续使用RVM或任何其他版本管理器,如果5.0已经为您顺利运行,升级到5.1可能不会给您带来任何问题。