Ruby: Could not find ‘xxxxxx’

After upgrading my system my ruby libraries were too much up-to-date for Vagrant. The following depressing error message appeared which clearly states that an older version is required.

$ vagrant up
/usr/lib/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'childprocess' (~> 0.3.7) - did find: [childprocess-0.5.2] (Gem::LoadError)
	from /usr/lib/ruby/2.1.0/rubygems/specification.rb:1295:in `block in activate_dependencies'
	from /usr/lib/ruby/2.1.0/rubygems/specification.rb:1284:in `each'
	from /usr/lib/ruby/2.1.0/rubygems/specification.rb:1284:in `activate_dependencies'
	from /usr/lib/ruby/2.1.0/rubygems/specification.rb:1266:in `activate'
	from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:54:in `gem'
	from /usr/bin/vagrant:22:in `<main>'

The expression ~> 0.3.7 means 0.3.7 <= version < 0.4.0 or in words, not older than 0.3.7 but not newer than the next minor version.

According Semantic Versioning 2.0.0 the minor and patch version numbers can always be increased without breaking the backwards compatibility, in theory. Practically this is not (always) true or what should be ~> used for other than preventing a breakage?

As of having mainly trouble with Ruby and Haskell dependencies (and sometimes Python) with Arch Linux these are unpredictable oh no, not now moments which let the milk turn immediately.

Fortunately you can't only install multiple versions of a certain library but you can safely install old versions in your home directory instead of your root file system. To be more precise you don't need to bypass your distribution's package manager in order to fix such kind of issues.

Using gem you install a specific version by appending the -v option.

$ gem install childprocess -v 0.3.7
Fetching: childprocess-0.3.7.gem (100%)
WARNING:  You don't have /home/slopjong/.gem/ruby/2.1.0/bin in your PATH,
	  gem executables will not run.
Successfully installed childprocess-0.3.7
Parsing documentation for childprocess-0.3.7
Installing ri documentation for childprocess-0.3.7
Done installing documentation for childprocess after 1 seconds
1 gem installed

Your new .gem folder has some binaries which are most probably missing in your PATH. Simply add this in your .bashrc or .zshrc.

When running the Ruby application again, in this case Vagrant, the above error message will be gone. Since one problem follows the other ...

$ vagrant up
/usr/lib/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'log4r' (~> 1.1.9) among 29 total gem(s) (Gem::LoadError)
	from /usr/lib/ruby/2.1.0/rubygems/specification.rb:1295:in `block in activate_dependencies'
	from /usr/lib/ruby/2.1.0/rubygems/specification.rb:1284:in `each'
	from /usr/lib/ruby/2.1.0/rubygems/specification.rb:1284:in `activate_dependencies'
	from /usr/lib/ruby/2.1.0/rubygems/specification.rb:1266:in `activate'
	from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:54:in `gem'
	from /usr/bin/vagrant:22:in `<main>'

... we can (hopefully) apply the same fix on (all) up-coming issues.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>