Answer the question
In order to leave comments, you need to log in
How to properly separate gems for different platforms?
Hello. Tell me please. I decided to transfer my project from a Windows server to Linux. And here is one gem, you need to install it like this under Windows:
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git'
gem 'bcrypt'
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', platforms: [:mingw, :x64_mingw]
gem 'bcrypt', platforms: [:mri]
Answer the question
In order to leave comments, you need to log in
In the interpreter, look at the values of the platforms of interest in the RUBY_PLATFORM constant.
if RUBY_PLATFORM =~ /x86_64-linux/
gem 'bcrypt'
else
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git'
end
platforms :mswin do
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git'
end
platforms :ruby do
gem 'bcrypt'
end
install_if -> { RUBY_PLATFORM =~ /linux/ } do
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git'
end
install_if -> { RUBY_PLATFORM =~ /mswin/ }
gem 'bcryptcrypt'
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question