Skip to content

Instantly share code, notes, and snippets.

@rsutphin
Created July 17, 2013 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsutphin/6024046 to your computer and use it in GitHub Desktop.
Save rsutphin/6024046 to your computer and use it in GitHub Desktop.
Bizarre Kernel.exec problem caused by "dropbox" gem
require 'bundler/setup'
Bundler.require :default
Kernel.exec ['/bin/ls', '/bin/ls'], '-al'

bundle install, then:

$ ruby the_problem.rb 
the_problem.rb:4:in `exec': No such file or directory - -al (Errno::ENOENT)
  from the_problem.rb:4:in `<main>'

Without dropbox:

$ ruby -e "Kernel.exec ['/bin/ls', '/bin/ls'], '-al'"
total 112
drwxr-xr-x  9 rsutphin  CB\Domain Users    306 Jul 17 14:57 .
drwxr-xr-x  5 rsutphin  CB\Domain Users    170 Jul 17 14:42 ..
-rw-r--r--  1 rsutphin  CB\Domain Users     45 Jul 17 15:09 Gemfile
-rw-r--r--  1 rsutphin  CB\Domain Users    246 Jul 17 14:58 Gemfile.lock
-rw-r--r--  1 rsutphin  CB\Domain Users     92 Jul 17 15:11 the_problem.rb

(i.e., the output from ls -al.)

The ultimate culprit is this code in dropbox/extensions/array.rb:

class Array # :nodoc:
  # [...]

  def to_hash # :nodoc:
    inject({}) { |hsh, (k,v)| hsh[k] = v  ; hsh }
  end unless method_defined?(:to_hash)
end
source 'https://rubygems.org'
gem 'dropbox'
@rsutphin
Copy link
Author

This is a practical problem because childprocess uses this form of exec call. childprocess is used by selenium-webdriver. So Selenium doesn't work to test a project that also includes this dropbox gem. You get errors like:

No such file or directory - --port=9516 (ChildProcess::LaunchError)

(with chromedriver), or

No such file or directory - -no-remote (ChildProcess::LaunchError)

(with firefox).

@brettporter
Copy link

The 'extlib' gem will cause the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment