Reputation: 117
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
Upvotes: 6
Views: 3350
Reputation: 5993
Use gem.add_runtime_dependency
in your gemspec
-- not add_dependency
and that ought to require the gem whether you add it to your Gemfile
or not.
Upvotes: 0
Reputation: 8044
I had the same problem and ended up deleting the Gemfile.lock to resolve the issue.
Upvotes: 2
Reputation: 20624
Does your gem, have a Gemfile with the following contents?
source 'https://rubygems.org'
# Specify your gem's dependencies in enterprise.gemspec
gemspec
Try adding a require in your application gemspec
gem 'enterprise', '0.0.1', path => '/home/enterprise/pkg', :require => "active_directory"
Upvotes: 0