Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Can't specify platforms if force_ruby_platform is true #6233

Closed
ahorek opened this issue Dec 28, 2017 · 3 comments
Closed

Can't specify platforms if force_ruby_platform is true #6233

ahorek opened this issue Dec 28, 2017 · 3 comments

Comments

@ahorek
Copy link

ahorek commented Dec 28, 2017

I want to specify a gem only for specific platforms.

gem "nokogiri", platforms: [:mri, :mingw, :x64_mingw]

this works fine. My problem is that for example nokogiri doesn't have a binary version for Ruby 2.5 yet, but it can be compiled for it.

Fetching nokogiri 1.8.1 (x64-mingw32)
Installing nokogiri 1.8.1 (x64-mingw32)
Gem::RuntimeRequirementNotMetError: nokogiri requires Ruby version < 2.5, >=
2.2. The current ruby version is 2.5.0.
An error occurred while installing nokogiri (1.8.1), and Bundler cannot
continue.

so I did it

gem install nokogiri --platform=ruby

however bundle update still wants x64-mingw32 platform

I tried

bundle lock --add-platform ruby
bundle config force_ruby_platform true

source 'https://rubygems.org'

gem "nokogiri"

now bundler recognises ruby platform.

Resolving dependencies...
Using bundler 1.16.1
Using mini_portile2 2.3.0
Using nokogiri 1.8.1
Bundle updated!

but if I specify the ruby platform in my Gemfile

gem "nokogiri", platforms: [:ruby]
Resolving dependencies...
Using bundler 1.16.1
Bundle updated!

nokogiri is gone.

desired behaviour
In my opinion the best way would be to use a compiled version automatically if a binary version isn't available, but it was rejected.

according to #5337 the platform can be forced only for a whole Gemfile, but there's a problem

bundle lock --add-platform ruby
bundle config force_ruby_platform true

Gemfile
gem 'nokogiri'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby, :ruby]

=> both gems should be installed

actual behaviour

'tzinfo-data' is ignored unless I remove all platforms specifications.

I want to have a single platform independent Gemfile that works for all 3 cases:
Linux
Windows with binary gems
Windows with force_ruby_platform

Am I missing something? Any suggestions?

Environment

Bundler       1.16.1
  Platforms   ruby, x64-mingw32
Ruby          2.5.0p0 (2017-12-25 revision 61468) [x64-mingw32]
  Full Path   C:/Ruby25-x64/bin/ruby.exe
  Config Dir  C:/ProgramData
RubyGems      2.7.3
  Gem Home    C:/Ruby25-x64/lib/ruby/gems/2.5.0
  Gem Path    C:/Users/pdaho/.gem/ruby/2.5.0;C:/Ruby25-x64/lib/ruby/gems/2.5.0
  User Path   C:/Users/pdaho/.gem/ruby/2.5.0
  Bin Dir     C:/Ruby25-x64/bin
Tools
  Git         2.15.1.windows.2
  RVM         not installed
  rbenv       not installed
  chruby      not installed

Bundler Build Metadata

Built At          2017-12-21
Git SHA           0034ef341
Released Version  true

Bundler settings

build.nokogiri
  Set for the current user (C:/Users/pdaho/.bundle/config): "--use-system-libraries"
force_ruby_platform
  Set for the current user (C:/Users/pdaho/.bundle/config): true

Gemfile

Gemfile

source 'https://rubygems.org'

gem "nokogiri", platforms: [:ruby]

Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    mini_portile2 (2.3.0)
    nokogiri (1.8.1)
      mini_portile2 (~> 2.3.0)

PLATFORMS
  ruby

DEPENDENCIES
  nokogiri

BUNDLED WITH
   1.16.1
@segiddins
Copy link
Member

When you set force_ruby_platform, you're telling bundler to treat your machine entirely as if it is 'just ruby', and ignore whether it is actually jruby, on windows, etc

@ahorek
Copy link
Author

ahorek commented Dec 30, 2017

is there a way to define it in platforms for this case? because this doesn't work (force ruby platform is true)

gem "nokogiri", platforms: [:ruby]

if I remove platforms entirely, the gem is installed, but I always have to modify the Gemfile

gem "nokogiri"

I want to have a general Gemfile, that will allow me to use native extensions or even better choose automaticaly the best gem available (prebuild or compiled)

There probably aren't many users on Windows or other platforms that could benefit from such feature. It's just an idea, so feel free to close the ticket.

@lybtongji
Copy link

The same problem with Ruby 2.6.5. I want to know is there a way to force bundle install with platform Ruby in command line? like bundle install --force-platform ruby.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants