Skip to content

Commit

Permalink
Display friendlier error message when ffi not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
sds committed Sep 19, 2019
1 parent c0dd089 commit e819417
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/childprocess.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def jruby?
end

def windows?
begin
require 'ffi'
rescue LoadError
raise ChildProcess::MissingFFIError
end

os == :windows
end

Expand Down
4 changes: 2 additions & 2 deletions lib/childprocess/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 supporting 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)
Expand Down

0 comments on commit e819417

Please sign in to comment.