[Rubygems-developers] gem lock

James Tucker jftucker at gmail.com
Wed Sep 29 07:24:20 EDT 2010

On 29 Sep 2010, at 06:12, Trans wrote:

> I recently noticed that `gem` had a `lock` command. I played around
> with it and found it mostly useless. First, one has to provide it the
> name and version of an installed gem. It would be much more useful if
> it could take a gemspec file instead. Also, it does not appear to
> utilize remote gem source(s) to resolve best dependencies, but simply
> uses the versions of gems installed locally. It would be much more
> useful if it recognized the --remote option and acted accordingly.
> Also, it could use an option to include/not-include development
> dependencies.

This is a simple manifest generator that could have been used to solve a small handful of the problems that Isolate and Bundler solve, but rubyists don't seem to like maintaining their own manifests. The other unfortunate thing is that it doesn't actually isolate in any way, still allowing for other gems to be loaded, and so on.

Outputting a gemspec would not be useful unless that could be loaded at runtime, as it's really designed to solve the problem of ensuring a consistent environment at runtime. Gemspecs need only specify the top level dependencies in the dependency heirachy, not an expanded list such as this.

The resolver system used here is actually not fully correct either, I've tried to explain this to some folks on IRC a while back when they were accusing Bundler of bloat, but I was shot down, anyway, here's some output to be considered (spot the rack versions):

raggi at mbk: ~ % gem dep actionpack -v 2.3.5
Gem actionpack-2.3.5
  activesupport (= 2.3.5, runtime)
  rack (~> 1.0.0, runtime)

raggi at mbk: ~ % gem lock thin-1.2.7 rails-2.3.5
require 'rubygems'
gem 'thin', '= 1.2.7'
gem 'rails', '= 2.3.5'
gem 'rack', '= 1.2.1'
gem 'eventmachine', '= 0.12.11'
gem 'daemons', '= 1.1.0'
gem 'rake', '= 0.8.7'
gem 'activesupport', '= 2.3.5'
gem 'activerecord', '= 2.3.5'
gem 'actionpack', '= 2.3.5'
gem 'actionmailer', '= 2.3.5'
gem 'activeresource', '= 2.3.5'

raggi at mbk: ~ % gem lock rails-2.3.5 thin-1.2.7 | ruby
/opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:233:in `activate': can't activate rack (= 1.2.1, runtime) for [], already activated rack-1.0.1 for ["actionpack-2.3.5", "rails-2.3.5"] (Gem::LoadError)
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
	from -:10

I would strongly recommend this feature be deprecated soon.

More information about the Rubygems-developers mailing list