问题
I keep getting the following error when I run any sort of rake command, and in particular rake db:seed which will abort without completing:
$ rake db:seed
/Users/rachel/.rvm/gems/ruby-2.2.0@rails4.2/gems/activesupport-4.1.1/lib/active_support/values/time_zone.rb:285: warning: circular argument reference - now
rake aborted!
ActiveRecord::UnknownAttributeError: unknown attribute: description
I did some research and discovered this is an error (I think?) caused by an incompatible gem in Rails 4.1.9 so I was hoping to create a new rvm to update Rails to 4.2.0 so I can proceed with my projects. However, every time I try to update Rails it says 'installed' but fails to actually install into the ruby version I created. Here's the typical command line pattern when I try to update Rails:
$ rvm gemset create rails420
ruby-2.2.0 - #gemset created /Users/rachel/.rvm/gems/ruby-2.2.0@rails420
ruby-2.2.0 - #generating rails420 wrappers........
$ rvm 2.2.0@rails420
$ gem install rails -v 4.2.0
Fetching: rails-4.2.0.gem (100%)
Successfully installed rails-4.2.0
Parsing documentation for rails-4.2.0
Installing ri documentation for rails-4.2.0
Done installing documentation for rails after 339 seconds
1 gem installed
$ rvm 2.2.0@rails420
$ rails --version
Rails 4.1.1
Basically, it installs Rails 4.2.0 but then says it's not installed when I check the version immediately after installation. Any ideas for how I can either solve the error or get the Rails gem to update correctly in my rvm?
回答1:
Try the following :
rvm use ruby-2.2.0@rails4.2 --create
gem install rails
rails -v
This should give you rails 4.2
回答2:
The issue causing the "warning: circular argument reference" was that the files in my project's Gemfile.lock didn't match the versions I was installing so it kept reverting to an out-of-date version and causing an error.
To fix, I updated all my gemsets and ran cleanup to make sure there were no out of date versions remaining, then ran the following commands:
rvm use --create 2.2.0@newtest
gem install rails
Fetching: rails-4.2.0.gem (100%)
Successfully installed rails-4.2.0
Parsing documentation for rails-4.2.0
Installing ri documentation for rails-4.2.0
Done installing documentation for rails after 326 seconds
1 gem installed
$ bundle install
I then checked the version to make sure that activerecord, activesupport, rails, and railties all had at least 4.2.0. Once I was sure those gems were working I created a new Rails project in the new updated rvm:
$ rvm use ruby-2.2.0@newtest
$rails new projectname
This created a new project with Rails 4.2.0 which is compatible with the right gems to avoid the "warning: circular argument reference" error, so I am no longer seeing it when I use rake or any other command. For a more detailed explanation see api.rubyonrails.org/classes/Rails/Railtie.html - Railtie is the gem that coordinates Rails actions like rake, so if it is out of date in your Gemfile.lock but not in your Ruby rvm it will create the error.
回答3:
This has now been resolved.
http://weblog.rubyonrails.org/2015/6/16/Rails-3-2-22-4-1-11-and-4-2-2-have-been-released-and-more/
fix ruby 2.2 warning: circular argument reference https://github.com/rails/rails/commit/8fd52705eda6a2cd7e9a8a5bc723fa094e359eb7
use self.method syntax to resolve circular argument issues https://github.com/rails/rails/commit/3a30b12c774dfaa72acfe520e823374131631ea9
来源:https://stackoverflow.com/questions/28824040/rails-gem-update-not-working-version-4-1-1-to-4-2-0-as-a-solution-to-warning