Skip to content

Commit

Permalink
Remove conditions from gem declarations in Gemfile
Browse files Browse the repository at this point in the history
Both gems 'wdm' and 'rb-kqueue' can be installed on any platform.
They fail when require 'wdm' or 'rb-kqueue' is called.
So the conditions in the Gemfile can be removed and should not be recommended.

Having conditions in the Gemfile is generally bad practice, since this leads to changed Gemfile.lock, whenever the bundler is executed on a different platform.
Also "bundle package --all-platforms" doesn't work properly, when gems are declared conditionally.
  • Loading branch information
larskanis committed Aug 5, 2024
1 parent f186b2f commit da9516e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 14 deletions.
10 changes: 2 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ else
gemspec development_group: :gem_build_tools
end

require 'rbconfig'

case RbConfig::CONFIG['target_os']
when /mswin|mingw|cygwin/i
gem 'wdm', '>= 0.1.0'
when /bsd|dragonfly/i
gem 'rb-kqueue', '>= 0.2'
end
gem 'wdm', '>= 0.1.0'
gem 'rb-kqueue', '>= 0.2'

group :test do
gem 'coveralls'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ If you are on Windows, it's recommended to use the [`wdm`](https://github.com/Ma
Please add the following to your Gemfile:

```ruby
gem 'wdm', '>= 0.1.0', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'wdm', '>= 0.1.0'
```

### On \*BSD
Expand Down
5 changes: 1 addition & 4 deletions lib/listen/adapter/bsd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ class BSD < Base

BUNDLER_DECLARE_GEM = <<-EOS.gsub(/^ {6}/, '')
Please add the following to your Gemfile to avoid polling for changes:
require 'rbconfig'
if RbConfig::CONFIG['target_os'] =~ /#{OS_REGEXP}/
gem 'rb-kqueue', '>= 0.2'
end
gem 'rb-kqueue', '>= 0.2'
EOS

def self.usable?
Expand Down
2 changes: 1 addition & 1 deletion lib/listen/adapter/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Windows < Base

BUNDLER_DECLARE_GEM = <<-EOS.gsub(/^ {6}/, '')
Please add the following to your Gemfile to avoid polling for changes:
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
gem 'wdm', '>= 0.1.0'
EOS

def self.usable?
Expand Down

0 comments on commit da9516e

Please sign in to comment.