How do I avoid the circular argument reference warning in activesupport - ruby-on-rails

How do I avoid the circular argument reference warning in activesupport. Happens on ruby 2.2.0
/home/ec2-user/apps/foo_prod/shared/bundle/ruby/2.2.0/gems/activesupport-3.2.21/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
/home/ec2-user/apps/foo_prod/shared/bundle/ruby/2.2.0/gems/ruby-ole-1.2.11.7/lib/ole/types/base.rb:265: warning: duplicated key at line 266 ignored: 4095

Use Rails 3.2.22
gem 'rails', '3.2.22'
OR
warning fixes in version 1.2.11.8:
bundle update ruby-ole

This is an issue of Active Support and has been fixed with these two commits:
https://github.com/rails/rails/commit/8fd52705eda6a2cd7e9a8a5bc723fa094e359eb7
https://github.com/rails/rails/commit/3a30b12c774dfaa72acfe520e823374131631ea9
Unfortunately, these commits have been never included into the 3.2 releases,
because the current last release (v3.2.21) was out on 18 Nov 2014
and after that these commits were merged.
If you don't want to see this warning message definitely, you should change
your Gemfile like this:
# gem 'rails', '3.2.21'
gem 'rails', git: 'https://github.com/rails/rails.git', branch: '3-2-stable'
Otherwise, you should downgrade ruby to 2.1 or wait the release of v3.2.22,
which won't come until a grave security hole is found.
After all, there is no easy way to avoid this issue. Changing Gemfile
for such a trivial annoyance may be an overreaction in my view.
It will delay your deployment process quite a lot.

I was not using compass in my application Based on this post here I upped my Rails version from 4.1.1 to 4.1.9 which worked.

This is compass issue here. They haven't release new version yet so you may need to wait for it.

here is what i did to resolve that, i had the latest ruby and the gems are not compatible with that, so after having a fight for nearly a day i switched to older ruby version using rvm
from ruby-2.2.1 to ruby-2.0.0 ,
again this is not an issue with ruby version but incompatibility with gems,try and have good luck with that.

Well, Here is a solution to this:
Try doing all these changes in your .rbenv/.rvm folder and change in these files:
https://github.com/tmm1/rails/commit/8fd52705eda6a2cd7e9a8a5bc723fa094e359eb7

Hypothetically, updating to Rails 4.2.0 - which you should be able to do via the following commands - should fix this error, although it hasn't worked for me:
rvm use ruby-2.2.0#rails4.2 --create
gem install rails
rails -v
I'm getting the same "circular argument error" message as well (I posted more about my failed attempts to fix it here, will update if I find an answer: Rails gem update not working (version 4.1.1 to 4.2.0) as a solution to "warning: circular argument reference" error).

I altered the time_zone.rb file, instead of now=now, I entered now=Time.now and problem solved.

I ran into the same issue as well, yo can sue the following steps to resolve it (worked for me).
$ gem uninstall compass
$ gem update --system
$ gem install compass

Related

Ruby 3 overcommit & psych issue

I am upgrading a Rails project to Ruby 3.1.2, from 2.6.6. I initially ran into this problem, but fixed it with adding gem 'psych', '< 4' into the Gemfile. I should note that an answer there mentioned downgrading to Ruby 3.0.3, but that does not fix my issue.
After adding that, the project worked fine regarding Psych. Unfortunately, when trying to commit/push, the overcommit hook returns this error:
/.rbenv/versions/3.1.2/lib/ruby/3.1.0/bundler/runtime.rb:309:in 'check_for_activated_spec!': You have already activated psych 4.0.4, but your Gemfile requires psych 3.3.2. Prepending 'bundle exec' to your command may solve this. (Gem::LoadError)
I also tried changing overcommit's version and got this error:
Since "psych" is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports psych as a default gem.
Is there any way to fix this, or a specific overcommit version that would bypass this error?
Came across similar issue. So, posting here in case it may help somebody.
With Ruby 3, you need to add psych ~>3.0 to the Gemfile explicitly, because the default version of psych which comes bundled with Ruby 3 starts giving errors as it doesn't quite understand how to handle aliases.
If you still wish to use default psych which comes bundled in with Ruby 3. You can load your YAML files like:
YAML.load_file(file_path, aliases: true).
In my case, I had dependencies loading YAML files so I decided to downgrade the psych version instead of loading YAML file with aliases: true.

How to fix warning in Rails

I'm newbie in Rails. I did something and this warning appear:
warning: parser/current is loading parser/ruby22, which recognizes
warning: 2.2.3-compliant syntax, but you are running 2.2.1.
warning:please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Can anyone help me explain why it appear and how to fix it?
Thanks a lot!
I got this error because I had the rubocop gem in my project which requires parser. I fixed it by locking my parser gem to the current ruby version we use.
For us, we use ruby 2.2.2, so I added gem 'parser', '~> 2.2.2.5' to my test group.
Since rubocop 0.24, he has used parser v2.2.x which means we we need to use ruby >= 2.2.2 to avoid that warning. Though the gem only requires ruby 1.9.3, so you can still use it but you're going to get warnings.
I was seeing this not only for rubocop but also for rspec and so. Fixed it by updating the parser gem with bundler. Didn't really specify a gem version. Just the latest one.
If you're using RuboCop, you may want to add require: false after the gem 'rubocop' statement in your Gemfile, so that you only load RuboCop when you use it.
Upgrading ruby to the newest version worked for me.
In my specific case I had
warning: parser/current is loading parser/ruby30, which recognizes warning: 3.0.1-compliant syntax, but you are running 3.0.0. warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
and had to upgrade ruby from 3.0.0 to 3.0.1

2 gems need different versions of the same dependency

Using Rails 3, I'm trying to figure out what I think should be pretty straightforward...
I have 2 gems that require 2 different versions of the same gem dependency. Both versions of the dependent gem are installed on my system but I still get an error from Rails: "Bundler could not find compatible versions for gem XXX".
What is the best practice to handle a scenario like this?
I'd go for what #BaroqueBobcat suggests. I just want to add that - if you need the latest Twitter gem and can't wait for the maintainer of Groupon2 to update his gem - you can fork the Groupon2 on GitHub, update its gemspec, see if it still works by running its tests (and try to fix it if it doesn't) and include your own version using its Git URL in your Gemfile like so: gem "groupon2", :git => "https://github.com/yourgithubuser/groupon2.git".
If you want to be nice you can offer your changes to the maintainer of Groupon2 with a pull request for bonus points :)
If you don't need all the features of the Twitter gem version 1.4.1, you could use version 1.2.0, which needs faraday ~> 0.5.4. and that should work. If that doesn't, you could try
poking the owner of groupon2 to update his gem--it's on github https://github.com/gangster/groupon2
.
I was having the same issue, but in a different context: Writing an app which uses two different versions of the hashie dependency (1.2.0 and 3.1.0)
I went into the Gemfile.lock and specified the older version in parentheses hashie (1.2.0), ran bundle install, and it worked.
If you're in a situation where the gems are being used in different projects or at least not at the exact same time you can use RVM's gemset feature as a workaround. I recently had a gem incompatibility similar to yours and that's what I used.
If you have RVM installed, do this:
rvm gemset create gemset_name_here
rvm gemset use gemset_name_here
So what you're doing is creating a gem environment that's totally fresh and from scratch while still being able to revert back to the gems you were working with before at any time. The first line creates a new gemset and the second line tells RVM to start using it.
At this point you'll need to run bundle install or rake or whatever you're using to get the gems you need but this should take care of the problem.
So when you're using gem 1 with dependency 1 you use the gemset that has the required version. Then when you're using gem 2 with dependency 2 you switch to the gemset that has that.
Now, if both gems are part of one larger project this will not be feasible and you'll most likely need to edit the source to of the gem to run the new version of the dependency like #BaroqueBobcat said. In a lot of cases this is actually pretty easy. Ruby developers tend to be very awesome about making their code easy to pick up on.
Take a look at this solution, maybe it will help you: gems
bundle update resolve conflicts

Rails Deprecated Warning

I have been trying to get rid of these deprecated warnings for 2 weeks now with no luck. Would truly be grateful if someone could point me in the right direction.
First Warning
WARNING: using the built-in Timeout class which is known to have issues when used for opening connections. Install the SystemTimer gem if you want to make sure the Redis client will not hang.
Second Warning
/Users/ChuckJHardy/.rvm/gems/ree-1.8.7-2010.02/gems/bundler-1.0.7/lib/bundler/shared_helpers.rb:101:Warning: Gem::LoadError#version_requirement= is deprecated and will be removed on or after January 2011. Use #requirement.
Third Warning
/Users/ChuckJHardy/Code/Sites/www/vendor/rails/railties/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
The first error is coming from REDIS. Judging by a quick googling, it's coming when Redis is trying to load the gem system_timer. Try adding that to your gems and see if it resolves.
The second and third error appear to be this problem in rails 2.3.5 and ruby enterprise edition. More information on the lighthouse ticket including a couple of fixes.
For the first one, just install the SystemTimer gem as instructed.
rvmsudo gem install systemtimer
For the next two, upgrade rubygems.
rvmsudo gem update --system
OK, a sideways solution. Place this in your Environments or Initializers file.
ActiveSupport::Deprecation.silenced = true

How can my Rails app accept RAILS_GEM_VERSION minor version bumps

My rails project has this line in /config/environment.rb
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
As we now have 2.3.5 as the most recent upgrade, is there a way to make my environment.rb accept minor version bumps?
(without I have to explicitly change 2.3.2 to 2.3.5)
No, there isn't.
You application needs to use a specific Rails version mostly because different tiny releases might require additional steps to upgrade the framework such as changes to boot.rb.
$ rake rails:update
Things have evolved a bit since Rails 2, so Ill share what I had to do to get from 5.0.0 to 5.0.0.1 today.
My Gemfile read gem 'rails', '~> 5.0.0'. I figured that was enough, but bundle install was not updating anything new. So I tried to force it with gem 'rails', '~> 5.0' which also did nothing new when I ran update (note: this is for an experimental app of my own, and not someone else's app I am working on - don't just default to allowing minor version updates to solve problems like this ;) ). So I had to try a few other ways to force this security patch/hotfix.
First, I had to install the package locally:
gem install rails --version 5.0.0.1
Next, I updated bundler:
bundle install
...and I saw this in the output: Using rails 5.0.0.1 (was 5.0.0)
When I ran ./bin/rake rails:update, it wiped the contents of my config/routes.rb file, changed many of my settings in various config files (some of which were dangerous security settings to change), among a few other seemingly benign changes. While this is the expected behavior, I am pointing this out as not exactly a desirable method for updating a minor patch/hotfix for rails.
Firstly, you need to change the version to 2.3.5 from 2.3.5 and then run
rake rails:update

Resources