ruby on rails - Conditions on gem requirement -
i prevent updating of gem on windows (rmagick
), sticks 2.12.0 mswin32
. still, coworker needs have gem on darwin install...
so, tried in gemfile
:
if ruby_platform =~ /darwin/i gem 'rmagick', '~> 2.12.0' else gem 'rmagick', '=2.12.0.mswin32' end
but bundle install
complaints.
what right way of handling properly?
you can't utilize conditionals on gemspec because gemspec serialized yaml, doesn't contain executable code.
i faced related problem in gemfile
of local rails project (not gem).
currently, gemfile contains:
group :test ... # 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 ugly) developing on mac , linux systems.
but, stopped checking in gemfile.lock
since changes every time developer different platform checks in code.
so, solution multi-platform gemfiles should solve problem gemfile.lock
.
the other solutions building multiple .gemspec files each target os , alter both platform , dependencies each platform:
gemspec = gem::specification.new |s| s.platform = gem::platform::ruby end # here build normal gem # linux: gemspec.platform = "linux" gemspec.add_dependency ... # build newer gemspec ...
ruby-on-rails gemfile
No comments:
Post a Comment