# Build a ruby gem and conditionally specify dependencies

**URL:** <https://www.ruby-forum.com/t/build-a-ruby-gem-and-conditionally-specify-dependencies/215953>\
**Category:** Rails\
**Created:** [January 20, 2012, 11:58am UTC](https://www.ruby-forum.com/t/build-a-ruby-gem-and-conditionally-specify-dependencies/215953 "2012-01-20T11:58:25Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![resident\_moron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5daacb/32.png) [@resident\_moron](https://www.ruby-forum.com/u/resident_moron)\
**Post date:** [January 20, 2012, 3:27pm UTC](https://www.ruby-forum.com/t/build-a-ruby-gem-and-conditionally-specify-dependencies/215953/3 "2012-01-20T15:27:47Z")

</div>

On Fri, Jan 20, 2012 at 3:10 PM, Luis L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On Jan 20, 7:56 am, “rails.impaired” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:\>

…

> > If anyone has a solution other than building multiple .gemspec files  
> > for each target OS… I’m all ears!!
> 
> Above example has been used in different projects, most of the time by  
> #dup the gemspec and building it for each platform.

We face a related problem in the Gemfile of a local Rails project (not a  
gem).

Currently, the Gemfile contains:

group :test do  
…

# on Mac os X

gem ‘rb-fsevent’ if RUBY\_PLATFORM.include?(“x86\_64-darwin”)  
gem ‘ruby\_gntp’ if RUBY\_PLATFORM.include?(“x86\_64-darwin”)

# on Linux

gem ‘rb-inotify’ unless RUBY\_PLATFORM.include?(“x86\_64-darwin”)  
gem ‘libnotify’ unless RUBY\_PLATFORM.include?(“x86\_64-darwin”)  
end

This works (although it is ugly) for developing on Mac and Linux  
systems.

But, we stopped checking in the Gemfile.lock since it changes every time  
a developer with a different platform checks in the code.

So, a solution for multi-platform Gemfiles should also solve the  
problem for Gemfile.lock.

Or is there a solution that we overlooked?

Thanks,

Peter

---

_[View the full topic](https://www.ruby-forum.com/t/build-a-ruby-gem-and-conditionally-specify-dependencies/215953)._
