Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'bundle install' for a local gem is not resolving dependencies, while 'gem install' does

I have a local gem (enterprise-0.0.1.gem) in a directory '/home/enterprise/pkg'. It has dependency on active_directory gem (v 1.5.5), which was specified in it's enterprise.gemspec file like this :-

gem.add_dependency("active_directory")

In my Application's Gemfile, I add the following line:-

gem 'enterprise', '0.0.1', path => '/home/enterprise/pkg'

When I do

bundle install

from my application's source directory, only the enterprise gem is installed. Hence, I hit runtime errors for the reference to active_directory gem.

But when I do

gem install /home/enterprise/pkg/enterprise-0.0.1.gem

the dependencies are resolved and I can see the active_directory gem in the gem list.

Why is there a discrepancy in the dependency resolution with bundler, and not with rubygems.

Kindly let me know if I need to provide more information about the environment. Ruby: 1.9.2, RubyGems: 1.8.24, Bundler: 1.1.5, rvm: 1.9.2.

My enterprise.gemspec file for reference :-

 # -*- encoding: utf-8 -*-
   require File.expand_path('../lib/enterprise/version', __FILE__)

   Gem::Specification.new do |gem|
      gem.authors       = ["example"]
      gem.email         = ["[email protected]"]
      gem.description   = %q{Enterprise Gem: example}
      gem.summary       = %q{Services: Authentication, Access Control}
      gem.homepage      = "http://example.com"  
      gem.files         = %w[
                       README.md
                       Rakefile
                       Gemfile
                       Gemfile.lock
                       enterprise.gemspec
                       lib/enterprise.rb
                       lib/enterprise/auth_service.rb
                       lib/enterprise/version.rb
                       ]
     gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
     gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
     gem.name          = "enterprise"
     gem.require_paths = ["lib"]
     gem.version       = Enterprise::VERSION
     gem.add_dependency("active_directory")
   end
like image 880
neosab Avatar asked Jul 18 '12 00:07

neosab


People also ask

How do I resolve gem dependencies?

Common Attempts To Resolve Ruby Gem Dependencies Bundler can help to resolve dependencies when working with Ruby gems by allowing you to specify a set of gems in a Gemfile, then issue a single command to install them. Bundler then automatically resolves the dependencies for you.

How do I install bundles to install missing gems?

Select Tools | Bundler | Install from the main menu. Open the Gemfile, place the caret at any highlighted gem missing in the project SDK and press Alt+Enter . Select Install missing gems using 'bundler' and press Enter .

Why bundle install is installing gems in vendor bundle?

In deployment, isolation is a more important default. In addition, the user deploying the application may not have permission to install gems to the system, or the web server may not have permission to read them. As a result, bundle install --deployment installs gems to the vendor/bundle directory in the application.

How do I bundle a gem to a specific version?

The correct way to update the version of a gem to a specific version is to specify the version you want in your Gemfile, then run bundle install .


1 Answers

I had the same problem and ended up deleting the Gemfile.lock to resolve the issue.

like image 169
sailor Avatar answered Oct 04 '22 01:10

sailor