titusfortner / webdrivers

Keep your Selenium WebDrivers updated automatically
MIT License
593 stars 111 forks source link

wslpath: not found when running selenium in a docker container under WSLv2 #201

Closed bigxiang closed 3 years ago

bigxiang commented 3 years ago

Summary

I want to setup an RSpec acceptance test environment on a windows laptop. I am using WSLv2 and have Ubuntu 20.04 installed, but I am not running tests in Ubuntu directly, instead a Docker container is running in Ubuntu which runs my tests. I installed Headless Chrome in the Docker container and expect it to be run by Webdrivers, but Webdrivers was looking for wslpath instead.

Debug Info

Please provide the following information for bug reports:

Expected Behavior

I tried to run RAILS_ENV=test bundle exec rake webdrivers:chromedriver:update in Docker, Chrome driver was supposed to be installed successfully.

Actual Behavior

I saw an error message saying that wslpath cannot be found. Per my understanding, a Docker environment should be isolated, why does Webdrivers seek wslpath here?

app@f8eeadc9187a:/app$ RAILS_ENV=test bundle exec rake webdrivers:chromedriver:update --trace
** Invoke webdrivers:chromedriver:update (first_time)
** Execute webdrivers:chromedriver:update
sh: 1: wslpath: not found
rake aborted!
Failed to make system call: wslpath -u ':\Users\\AppData\Local\Google\Chrome\Application\chrome.exe'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/system.rb:180:in `call'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/system.rb:167:in `to_wsl_path'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chrome_finder.rb:67:in `block (2 levels) in wsl_location'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chrome_finder.rb:66:in `each'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chrome_finder.rb:66:in `block in wsl_location'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chrome_finder.rb:65:in `each'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chrome_finder.rb:65:in `wsl_location'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chrome_finder.rb:91:in `linux_location'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chrome_finder.rb:18:in `location'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chrome_finder.rb:10:in `version'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chromedriver.rb:51:in `browser_version'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chromedriver.rb:123:in `browser_build_version'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/chromedriver.rb:32:in `latest_version'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/common.rb:135:in `correct_binary?'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/common.rb:91:in `update'
/bundle/gems/webdrivers-4.4.2/lib/webdrivers/tasks/chromedriver.rake:23:in `block (3 levels) in <main>'
/bundle/gems/rake-12.3.3/lib/rake/task.rb:273:in `block in execute'
/bundle/gems/rake-12.3.3/lib/rake/task.rb:273:in `each'
/bundle/gems/rake-12.3.3/lib/rake/task.rb:273:in `execute'
/bundle/gems/rake-12.3.3/lib/rake/task.rb:214:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/bundle/gems/rake-12.3.3/lib/rake/task.rb:194:in `invoke_with_call_chain'
/bundle/gems/rake-12.3.3/lib/rake/task.rb:183:in `invoke'
/bundle/gems/rake-12.3.3/lib/rake/application.rb:160:in `invoke_task'
/bundle/gems/rake-12.3.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/bundle/gems/rake-12.3.3/lib/rake/application.rb:116:in `each'
/bundle/gems/rake-12.3.3/lib/rake/application.rb:116:in `block in top_level'
/bundle/gems/rake-12.3.3/lib/rake/application.rb:125:in `run_with_threads'
/bundle/gems/rake-12.3.3/lib/rake/application.rb:110:in `top_level'
/bundle/gems/rake-12.3.3/lib/rake/application.rb:83:in `block in run'
/bundle/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/bundle/gems/rake-12.3.3/lib/rake/application.rb:80:in `run'
/bundle/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
/bundle/bin/rake:23:in `load'
/bundle/bin/rake:23:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/cli/exec.rb:74:in `load'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/cli/exec.rb:74:in `kernel_load'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/cli.rb:463:in `exec'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/cli.rb:27:in `dispatch'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/cli.rb:18:in `start'
/usr/local/bin/bundle:30:in `block in <main>'
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/usr/local/bin/bundle:22:in `<main>'
Tasks: TOP => webdrivers:chromedriver:update
app@f8eeadc9187a:/app$

Here is my Chromium installation in the Docker container:

app@f8eeadc9187a:/app$ which chromium
/usr/bin/chromium

I have a same Docker container installed on my Mac, it looks good. I guess there are something fishy in WSLv2, but I really have few knowledge about that.

Thank you for your help!

kapoorlakshya commented 3 years ago

I believe #196 fixes this on WSL2. Can you load this gem from the master branch and see if the issue gets fixed?

bigxiang commented 3 years ago

Wow, that works well! Thank you so much @kapoorlakshya !

kapoorlakshya commented 3 years ago

Great! I'm working to release this in v4.5 very soon.