From: Uwe Kubosch Date: 2011-01-30T20:06:38+09:00 Subject: Re: how to build gem whose dependencies depend of the platform? --Boundary_(ID_KZJSOBRK6KX0M3FA4xh+rA) Content-type: text/plain; CHARSET=US-ASCII Content-transfer-encoding: 7BIT On 2011-01-29, at 18:55, Luis Lavena wrote: >>>>> I need to build a gem whose dependencies are dependent of the platform >>>>> itself. For example when `gem install my_gem` is issued under Windows, >>>>> then in gemspec i have to have spec.add_dependency("gemX"), but if the >>>>> command is executed under linux then i need to have >>>>> spec.add_dependency("gemY"). >> >> I have solved this by making the gem depend on the "bundler" gem, and then put the gem dependecies into a Gemfile, and run the equivalent of "bundle install" as a post-install script. This takes care of everything. The only thing I am missing is that the dependencies are visible when inspecting the gem. > > RubyGems post_install is not scripts, perhaps you're using extension > compilation to make that happen, which is intrusive to the user. You are right, I use the extension compilation to run the extra install step. How is this intrusive? > You're also bringing Bundler when the user might not want it into the > mix and slowing down the gem loading process. I would rather add Bundler than not have the gem install all its dependencies. The user experience is what matters, and this way all dependencies install correctly and the gem is ready for use regardless of the users platform. > Bundler is awesome for development, but is awful for runtime > dependency. You should not be imposing bundler to the user and even > less for runtime execution. Why not? Bundler is awesome for runtime dependencies as well. It is the default mechanism for Ruby On Rails runtime dependencies. > Also bundler do not handle properly all the platforms, using a > different concept of "platform" of what RubyGems understand and is > widely known. The platform concept of Bundler is different from RubyGems platform, but Bundler handles all platforms properly and the platform concept of Bundler is as well known and as intuitive as RubyGems. If RubyGems alone would allow developers to solve the problem of dependencies varying with the user's platform, that is what I would use. As long as RubyGems falls short to solve the problem, we need to solve it some other way. Using Bundler solves the problem, and does it nicely. -- With kind regards Uwe Kubosch Kubosch Consulting uwe@kubosch.no http://kubosch.no/ --Boundary_(ID_KZJSOBRK6KX0M3FA4xh+rA)--