From 67845b0a91f32f36da222ce5b78ad514d4f2e1fa Mon Sep 17 00:00:00 2001 From: Shane da Silva Date: Thu, 19 Sep 2019 02:01:47 -0700 Subject: [PATCH 1/4] Do not install ffi gem automatically on Windows platforms We originally introduced this logic in #132 without understanding all the implications. Issue #158 raised a challenge with this approach. --- Gemfile | 3 +++ README.md | 2 ++ childprocess.gemspec | 5 ----- ext/mkrf_conf.rb | 24 ------------------------ 4 files changed, 5 insertions(+), 29 deletions(-) delete mode 100644 ext/mkrf_conf.rb diff --git a/Gemfile b/Gemfile index 8d93ebc..ba9393b 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,9 @@ source 'http://rubygems.org' # Specify your gem's dependencies in child_process.gemspec gemspec +# Used for local development/testing only +gem 'rake' + if RUBY_VERSION =~ /^1\./ gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version diff --git a/README.md b/README.md index 952fc00..3875914 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ a standalone library. * Ruby 2.3+, JRuby 9+ +Windows users **must** ensure the `ffi` gem (`>= 1.0.11`) is installed in order to use ChildProcess. + # Usage The object returned from `ChildProcess.build` will implement `ChildProcess::AbstractProcess`. diff --git a/childprocess.gemspec b/childprocess.gemspec index d52c2b1..2825838 100644 --- a/childprocess.gemspec +++ b/childprocess.gemspec @@ -23,9 +23,4 @@ Gem::Specification.new do |s| s.add_development_dependency "rspec", "~> 3.0" s.add_development_dependency "yard", "~> 0.0" s.add_development_dependency 'coveralls', '< 1.0' - - s.add_runtime_dependency 'rake', '< 13.0' - - # Install FFI gem if we're running on Windows - s.extensions = 'ext/mkrf_conf.rb' end diff --git a/ext/mkrf_conf.rb b/ext/mkrf_conf.rb deleted file mode 100644 index 74e2266..0000000 --- a/ext/mkrf_conf.rb +++ /dev/null @@ -1,24 +0,0 @@ -# Based on the example from https://en.wikibooks.org/wiki/Ruby_Programming/RubyGems#How_to_install_different_versions_of_gems_depending_on_which_version_of_ruby_the_installee_is_using -require 'rubygems' -require 'rubygems/command.rb' -require 'rubygems/dependency_installer.rb' - -begin - Gem::Command.build_args = ARGV -rescue NoMethodError # rubocop:disable Lint/HandleExceptions -end - -inst = Gem::DependencyInstaller.new - -begin - if Gem.win_platform? - inst.install 'ffi', Gem::Requirement.new('~> 1.0', '>= 1.0.11') - end -rescue # rubocop:disable Lint/RescueWithoutErrorClass - exit(1) -end - - # create dummy rakefile to indicate success -File.open(File.join(File.dirname(__FILE__), 'Rakefile'), 'w') do |f| - f.write("task :default\n") -end From c0dd089a4e161c1167fafabefb2875f2ba619605 Mon Sep 17 00:00:00 2001 From: Shane da Silva Date: Thu, 19 Sep 2019 02:13:57 -0700 Subject: [PATCH 2/4] Update change log --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31de174..3cf9a0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### dev (unreleased) + +* Remove extension to conditionally install `ffi` gem on Windows platforms +* Remove runtime dependency on `rake` gem +* Remove unused `rubyforge_project` from gemspec + ### Version 2.0.0 / 2019-07-11 * [#148](https://github.com/enkessler/childprocess/pull/148): Drop support for Ruby 2.0, 2.1, and 2.2 From c0cc6f2b6443fbd499f1595d84ead60008bd1048 Mon Sep 17 00:00:00 2001 From: Shane da Silva Date: Thu, 19 Sep 2019 02:50:25 -0700 Subject: [PATCH 3/4] Display friendlier error message when ffi not installed --- lib/childprocess/errors.rb | 4 ++-- lib/childprocess/windows.rb | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/childprocess/errors.rb b/lib/childprocess/errors.rb index d327319..2245ad7 100644 --- a/lib/childprocess/errors.rb +++ b/lib/childprocess/errors.rb @@ -16,8 +16,8 @@ class LaunchError < Error class MissingFFIError < Error def initialize - message = "FFI is a required pre-requisite for posix_spawn, falling back to default implementation. " + - "Please add it to your deployment to unlock this functionality. " + + message = "FFI is a required pre-requisite for Windows or posix_spawn support in the ChildProcess gem. " + + "Ensure the `ffi` gem is installed. " + "If you believe this is an error, please file a bug at http://github.com/enkessler/childprocess/issues" super(message) diff --git a/lib/childprocess/windows.rb b/lib/childprocess/windows.rb index e537372..1470a7a 100644 --- a/lib/childprocess/windows.rb +++ b/lib/childprocess/windows.rb @@ -1,6 +1,11 @@ -require "ffi" require "rbconfig" +begin + require 'ffi' +rescue LoadError + raise ChildProcess::MissingFFIError +end + module ChildProcess module Windows module Lib From f72bccc90c91b28075fa37d1afe40b2c66f9f8fc Mon Sep 17 00:00:00 2001 From: Shane da Silva Date: Thu, 19 Sep 2019 02:15:59 -0700 Subject: [PATCH 4/4] Bump gem version to 3.0.0 Given the removal of the extension logic that conditionally installed the `ffi` gem on Windows platforms, this fundamentally changes the assumptions around what the gem installs and thus its backwards compatibility, hence necessitating a major version upgrade. --- lib/childprocess/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/childprocess/version.rb b/lib/childprocess/version.rb index d6e0262..2a57384 100644 --- a/lib/childprocess/version.rb +++ b/lib/childprocess/version.rb @@ -1,3 +1,3 @@ module ChildProcess - VERSION = '2.0.0' + VERSION = '3.0.0' end