Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to start chrome on Mac because the filename contains spaces #139

Closed
dwt opened this issue Jun 18, 2019 · 8 comments · Fixed by #138
Closed

Fails to start chrome on Mac because the filename contains spaces #139

dwt opened this issue Jun 18, 2019 · 8 comments · Fixed by #138
Assignees
Labels

Comments

@dwt
Copy link

dwt commented Jun 18, 2019

Summary

When starting chrome through WebDrivers, WebDrivers asks the chrome binary for its version. This triggers an error as the google chrome binary contains spaces in its path on the Mac.

e.g. this will fail:

 `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --version`

To my understanding the problem is the in system.rb:150 or in chrome_finder.rb:71 as it does not handle spaces in the path.

Debug Info

Please provide the following information for bug reports:

  • Operating system / CI Environment: Mac OS 10.14.5
  • Browser and version: Chrome Version 75.0.3770.90 (Offizieller Build) (64-Bit)

Expected Behavior

Space support in paths is required on Mac.

Actual Behavior

An error like

*** Errno::ENOENT Exception: No such file or directory - /Users/dwt/Applications/Network/Browser/Google is raised

@dwt
Copy link
Author

dwt commented Jun 18, 2019

My workaround was modifying the local file chrome_finder like this:

      def mac_version(location)
        require 'shellwords'
        System.call("#{location.shellescape} --version")&.strip
      end

@kapoorlakshya
Copy link
Collaborator

Hi @dwt, I am unable to reproduce this in v4.0.1. I ran the specs on macOS 10.13.3 (w/ Ruby 2.4.6 and 2.6.3) with log level as :debug and I am seeing the path with spaces escaped:

2019-06-18 15:48:10 DEBUG Webdrivers making System call: //Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version
2019-06-18 15:48:10 DEBUG Webdrivers Browser version: Google Chrome 75.0.3770.100

You can view the log here: https://travis-ci.org/kapoorlakshya/webdrivers/jobs/547300790#L242

@twalpole
Copy link
Collaborator

@dwt Are you manually specifying your Chrome location? What version of webdrivers are you using?

@kapoorlakshya kapoorlakshya self-assigned this Jun 18, 2019
@kapoorlakshya
Copy link
Collaborator

kapoorlakshya commented Jun 18, 2019

I introduced this bug in v4.0.1 (#131). It's not escaping the user given path.

Will fix it under #138.

@dwt
Copy link
Author

dwt commented Jun 19, 2019

Ah, sorry, I removed that from the bug report because I thought it was irrelevant. Yes, I am manually specifying the location, and I also tried shell-escaping that location, but that doesn't work because then Selenium-WebDriver refuses to start chrome.

@dwt
Copy link
Author

dwt commented Jun 19, 2019

Out of interest, and because I'm not a ruby programmer by trade: I was wondering why you are using backticks to call out to the shell (thus to my understanding actually using a shell to execute those external commands). It seems to me that using a non-shell subprocess call like IO:popen would be a much safer way to call external tools - also not requiring any escaping of spaces in paths.

kapoorlakshya added a commit that referenced this issue Jun 20, 2019
* Rake tasks now rely on the core code to handle the ENV vars.

* Fix bug where values from the ENV vars had precedence over user defined configs in the project.

* Support WD_CHROME_PATH environment variable and use IO.popen to properly escape file paths.
@kapoorlakshya
Copy link
Collaborator

@dwt Thanks for the suggestion. The gem now uses IO.popen to handle the system calls. Can you please load this gem from the master branch and confirm the fix works for you? Thanks!

# In Gemfile

gem 'webdrivers', git: 'https://github.com/titusfortner/webdrivers.git', branch: 'master'

@dwt
Copy link
Author

dwt commented Jun 25, 2019 via email

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

Successfully merging a pull request may close this issue.

3 participants