[英]Why does the Rails Composer update Rails when it builds an app?
# I run these commands:
$ rvm current
ruby-2.3.3@rails500
$ gem list | grep '^rails '
rails (5.0.1, 5.0.0)
$ gem uninstall rails -v 5.0.1
Successfully uninstalled rails-5.0.1
$ gem uninstall railties -v 5.0.1
Successfully uninstalled railties-5.0.1
$ gem list | grep railties
railties (5.0.0)
$ rails -v
Rails 5.0.0
$ rails new . -m \
https://raw.github.com/RailsApps/rails-composer/master/composer.rb
# After I answer all the prompts, a Gemfile is created, which requires
# rails '~> 5.0.1'. After running to completion, Rails Composer leaves
# me with Rails 5.0.1:
$ rails -v
Rails 5.0.1
I didn't explicitly ask for Rails 5.0.1. 我没有明确要求Rails 5.0.1。 Then why am I getting it?
那我为什么要得到它? It appears to interfere with Rails Composer.
它似乎会干扰Rails Composer。 See https://github.com/RailsApps/rails-composer/issues/261 and https://github.com/RailsApps/rails-composer/issues/260
参见https://github.com/RailsApps/rails-composer/issues/261和https://github.com/RailsApps/rails-composer/issues/260
You've observed a behavior of the Rails new
command. 您已经观察到
Rails new
命令的行为。 Rails Composer is a Rails application template and piggybacks on the Rails new
generator. Rails Composer是一个Rails应用程序模板,并在
Rails new
成器上搭载。 The Rails new
command generates a simple default Rails application and then Rails Composer modifies it. Rails new
命令生成一个简单的默认Rails应用程序,然后Rails Composer对其进行修改。 The Gemfile generated by the Rails new
command contains gem 'rails', '~> 5.0.0'
. Rails new
命令生成的Gemfile包含gem'rails gem 'rails', '~> 5.0.0'
。 Note the "pessimistic versioning" specified by ~> 5.0.0
. 注意
~> 5.0.0
指定的“悲观版本控制”。 It means use any version greater than 5.0.0 and less than 5.1 (any patch version can be used). 这意味着使用大于5.0.0且小于5.1的任何版本(可以使用任何补丁程序版本)。 When the
Rails new
generator runs, it updates the gems, including the Rails gem, using the Gemfile provided by the simple default Rails application. 当
Rails new
成器运行时,它将使用简单的默认Rails应用程序提供的Gemfile更新gem,包括Rails gem。 Thus, the Rails 5.0.1 gem is installed before Rails Composer runs. 因此,在Rails Composer运行之前,已安装Rails 5.0.1 gem。
You can observe this behavior by running the Rails new
command without the Rails Composer application template. 您可以通过在没有Rails Composer应用程序模板的情况下运行
Rails new
命令来观察此行为。
myapp/2.4.0@rails500 $ rvm current ruby-2.4.0@rails500 myapp/2.4.0@rails500 $ gem list | grep '^rails ' rails (5.0.0) myapp/2.4.0@rails500 $ rails -v Rails 5.0.0 myapp/2.4.0@rails500 $ rails new . . . . run bundle install . . . Installing rails 5.0.1 . . . myapp/2.4.0@rails500 $ rails -v Rails 5.0.1
In summary, your issue is with the Rails new
command, not with Rails Composer. 总之,您遇到的问题是Rails
new
命令,而不是Rails Composer。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.