conditional inclusion is ignored for nested dependencies #1281

Closed
ivar opened this Issue Jul 1, 2011 · 4 comments

Comments

Projects
None yet
3 participants

ivar commented Jul 1, 2011

We have a project (SampleProject) with a Gemfile with:

gem sample_gem
gem sample_gem2 if  RUBY_VERSION =~ /^1.8/ 

Sample Gem has a Gemfile with

gem system_timer if  RUBY_VERSION =~ /^1.8/ 

When running bundle install in the SampleProject root using ruby 1.9.2, bundler correctly ignores sample_gem2 but does try to install the system_timer gem.

This is inconvenient to say the least, but is this a bug or a considered design decision ?

Contributor

raggi commented Jul 1, 2011

see the platforms documentation. you probably want something like:

gem 'system_timer', :platform => :mri_18

If i remember the non-standard names correctly.

Owner

indirect commented Jul 3, 2011

Definitely use platforms instead of conditionals. Furthermore, the Gemfile for sample_gem cannot and will not effect the Gemfile for SampleProject. If you need a gem that works on multiple platforms, change the gem's gemspec and/or build the gem correctly so it has support for multiple platforms. Thanks!

@indirect indirect closed this Jul 3, 2011

ivar commented Jul 3, 2011

As a followup, I've scoured the rubygem docs and as far as I can tell, this is not supported by gem.

Also, I found someone else fighting gem with a similar predicament asking about it at stackoverflow.

(p.s. thanks for the help & pointers guys)

Owner

indirect commented Jul 4, 2011

You aren't supposed to have conditional requires in your gemspec, you're supposed to have versions of your gem for each platform you support, and gems for different platforms can depend on different gems. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment