"Could not find activesupport" when 3 versions installed - ruby

I'm just trying to use the simple career_builder gem and just get it imported by running the simple script:
require 'career_builder'
puts 'Hello world!'
and yet get the following error: /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:315:in 'to_specs': Could not find 'activesupport' (~> 2.3.5) - did find: [activesupport-4.2.1,activesupport-3.1.12,activesupport-3.0.3] (Gem::LoadError)
I installed the gem with gem install career_builder and ran bundle install and even updated activesupport to the most recent version, but for some reason, the program can't find the newer version of activesupport. Does the gem require version 2.3.5?

http://guides.rubygems.org/patterns/
The ~>or 'twiddle-waka' is a ruby gems shortcut to specify the earliest version of the gem you can use without letting you go up to the next major release.
Your gem is being a bit unorthodox and also specifying a patch level.
So the gem_specification you're working with (activesupport' (~> 2.3.5)) really means minimum version of 2.3.5 maximum of the last patch released before 2.4.0.
The activesupport versions you have installed are all for subsequent major releases and won't work. Install something between 2.3.5 and 2.4.0 and you should be good to go.

Yes. It does require Active Support version >= 2.3.5 and < 2.4.0. All of your Active Support versions are > 2.4.0.
~> is called the spermy operator. See Meaning of tilde-greater-than (~>) in version requirement?
The gem has not been updated in 4 years, so it uses Rails 2.
FWIW, I don't think you'll have much luck getting it to work, so you may want to find a similar gem that works with Rails 4 and has been updated within the last few months.

Related

enforcing a ruby gem version

I am completely new to ruby, don't know the 1st thing about rvm, gemset etc. Just forced to use a CLI tool (kensa by heroku) written in ruby and facing an issue.
The kensa tool seems to use a gem named rest-client. When I run it it throws an error:
/Users/shaharsol/.rvm/gems/ruby-2.4.2/gems/rest-client-1.8.0/lib/restclient/request.rb:163:in `fetch': key not found: :ciphers (KeyError)
Some searches suggest that v1.8 of rest-client is too old so I installed v2.0.2. Now when I do a gem list I get:
rest-client (2.0.2, 1.8.0)
When I run kensa again it still used to old version. So I went and modified it kensa.gemspec file (which is referred to from Gemfile) and to my best understanding told it to use the newer version:
s.add_runtime_dependency(%q<rest-client>, "~> 2.0")
Yet, when I run kensa again, it still uses the old rest-client 1.8.0!
What am I missing? What am I doing wrong? Or what else is required for the kensa to run with the new rest-client 2.0.2 ???
PS - If my problem doesn't relate at all to changing 1.8.0 => 2.0.2 please tell me what else to do. I really don't care which rest-client version kensa uses, I just need it to run!
To remove older version of the gem, you have two options:
# remove all versions of the gem
gem cleanup rest-client
After this, you can do 'bundle install' and only install the version you want.
# choose which one you want to remove
gem uninstall rest-client --version 1.8.0
After this, you will only have 2.0.2 version.
Hope this solves your problem.

Which version of gem is used when there is no Gemfile

There is similar question here.
Ruby: Rails: Which version of a gem is used?
But it's about when Gemfile is used.
I want to know if there is no Gemfile, which version of gem is used.
For example I have 4 versions of selenium-webdriver in my system.
% gem list | grep selenium
selenium-webdriver (2.53.0, 2.48.1, 2.46.2, 2.45.0)
And I just use it by pry and require 'selenium-webdriver. How can I know which version is used? Only the latest is selected?
You probably have more than one gem because each project with Gemfile in your machine have one different version of it.
When using the gem via require or command line without specifying the version the last one - the greater version - will be automatically used.
By convention, in the most part of the cases, you can print the version doing the following:
require 'some_gem'
puts SomeGem::VERSION
# => "3.0.3"

Issues using the latest Psych with Rails 3.2.8 & ruby 1.9.3

I recently hit some JSON parse issues and discovered we are using a pretty old version of Psych and libyaml: Psych version: 1.2.2; Psych libyaml version: 0.1.4
The latest Psych has much better JSON parsing support (subset of YAML) and I verified this fixes my issues, however I'm having issues configuring our Rails app to use the latest Psych gem versus the Psych version bundled with ruby.
I simply add gem 'psych' in the gemfile and run bundle install according to the online docs.
Now when I try to run anything I hit errors:
uninitialized constant Psych::Streaming::ClassMethods (NameError)
While it makes no sense, I know whats going on here, internally Rails is using the OLD version of Psych::Streaming which doesn't have these new methods. When I debug I see it using the old dir (e.g. ~Ruby1.9.3\lib\ruby\1.9.1\psych\streaming.rb) versus the NEW lib it should be using (e.g. ~Ruby1.9.3\lib\ruby\gems\1.9.1\gems\psych-2.0.8\lib\psych\streaming.rb)
So this seems like general confusion where code in the new Psych gem is calling code from the old bundled Psych version. How do I get Rails to not use the old bundled version and use the latest Psych??
We're using an older version of Rails (3.2.8) and ruby (1.9.3-p125) and unfortunately upgrading is not an option for the project right now...
** UPDATE **
It seems like root causing this problem will be a nightmare so maybe I need a new approach. Is there a way to ONLY use the latest Psych gem in my new code, but let everything else (like the external ruby libs) continue using the old bundled version? We had no issues with the old Psych version until I started passing around & parsing more complex JSON in my new code...

Trouble with Gem version ahead of what Rubygems expects

I seem to have an issue with the version of a gem that I am using.
I have no internet access, I downloaded the gem straight from the Rubyforge and then SCPed it to the target machine and I used gem install --force --local to install it. Ruby/Rubygems comes from a snapshot of the EPEL repo taken about a month ago. It is hosted on on a machine in the network and YUM is configured across the network to point to the correct location.
I am trying to use the Net::SSH family of gems (Net:SSH, Net::SSH::Shell, Net::SSH::Multi, Net::SSH::Gateway, Net::SCP). When I run my file.rb I get this:
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': RubyGem version error: net-ssh(2.6.6 not ~> 2.1.0) (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in `require'
from ./cluster_config.rb:12
I have seen a lot of issues around the internet about the actual version being less that than the expected version, but I have only found on example where the actual version was newer than the expected, but it was "resolved" with a response from the OP saying "My buddy got it, thanks."
This is also the first time I have seen the ~> operator in this use. Usually I have seen the >= operator here.
Any suggestions?
~> is used inside Gemfiles to allow a gem to be used whose patch version is greater or equal to the specified version, provided that the major and minor versions are identical. For example:
~> 2.1.0 would allow version 2.1.9, but not 2.2.0 or 2.0.0.
~> 2.1.3 would also allow 2.1.9 but not 2.1.0 or 2.2.0.
Also, you could probably download the exact version you need directly from RubyGems. In your case, the link would be http://rubygems.org/downloads/net-ssh-2.1.0.gem .

Ruby Twitter gem

-- UPDATE --
Ok its fixed. This is what I did. remove all ruby and rubygems completely. then install ruby1.9.1-full and rubygems1.9.1 then install the twitter gem.
Hi guys,
I am having trouble working with the Twitter gem. I am using ruby 1.8.7
After installing when I try to run a simple script I get this error
ruby twitter.rb
./twitter.rb:5: uninitialized constant Twitter (NameError)
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from twitter.rb:2
I running this on a Ubuntu box. I checked with gem -list and I see the Twitter (1.1.0) is listed there.
this is the code I am trying to run
require "rubygems"
require 'twitter'
puts Twitter.user_timeline("test").first.text
Any ideas ?
I believe it only works with Ruby 1.9 If you want to use twitter gem try version 0.9 with Ruby 1.8.x
This works for me:
ruby-1.9.2-p0 > require 'twitter'
=> true
ruby-1.9.2-p0 > puts Twitter.user_timeline("test").first.text
TExES Pedagogy and Professional Responsibilities EC-12 Teacher Certification Test Prep Study Guid… - by Sharon A Wynne http://amzn.to/f3kF74
=> nil
which version of ruby are you using?
gouravtiwari21's comment seems to fix the problem, but it's wrong to suggest that the twitter gem requires 0.9.0 if you want to run it using Ruby 1.8.x.
You can check out the version compatibility here:
http://travis-ci.org/#!/jnunemaker/twitter
It shows the twitter gem working with Ruby installs as low as 1.8.7.
For me, it was an issue with having the correct dependent gems, as well as the correct versions.
Here's how I got it working:
I ran:
sudo gem list
And compared the versions of specific gems with what I found here:
https://github.com/jnunemaker/twitter/blob/master/HISTORY.md (I simply searched for the word 'dependency' to see which versions twitter cared about.
I also found this diff:
https://github.com/jnunemaker/twitter/commit/ac8114c1f6ba2da20c2267d3133252c2ffc6b6a3
And I compared the gems listed there with what I had installed, and I just made sure my system lined up with what I was seeing in the version notes. Oftentimes what happened is that I had multiple versions of a gem, and for some reason, the lower version was taking precedence.
I'm not sure why I still have to add
gem 'twitter', '1.7.1'
to my Gemfile, but alas, that's the last step required in order to get this stuff working.
Don't forget to restart your server, and you should be good!

Resources