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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃悰 Bug]: `spawn': no implicit conversion of nil into String (TypeError) #11815

Closed
pgundlupetvenkatesh opened this issue Mar 24, 2023 · 9 comments

Comments

@pgundlupetvenkatesh
Copy link

pgundlupetvenkatesh commented Mar 24, 2023

What happened?

Throws no implicit conversion of nil into String (TypeError) error when trying to launch a browser.

Gem versions -
Watir v7.1.0
webdriver v5.2.0

How can we reproduce the issue?

require 'watir'

Watir::Browser.new(:edge)

Happens for Chrome too. Type :chrome to use.



### Relevant log output

```shell
<dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/child_process.rb:57:in `spawn': no implicit conversion of nil into String (TypeError)

        @pid = Process.spawn(*@command, options)
                             ^^^^^^^^^^^^^^^^^^
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/child_process.rb:57:in `start'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/service_manager.rb:102:in `start_process'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/service_manager.rb:56:in `block in start'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/socket_lock.rb:42:in `locked'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/service_manager.rb:54:in `start'
        from <internal:kernel>:90:in `tap'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/service.rb:83:in `launch'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/driver.rb:334:in `service_url'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/local_driver.rb:28:in `initialize_local_driver'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/edge/driver.rb:34:in `initialize'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/driver.rb:55:in `new'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver/common/driver.rb:55:in `for'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.8.2/lib/selenium/webdriver.rb:88:in `for'
        from <dir_path>/lib/ruby/gems/3.2.0/gems/watir-7.1.0/lib/watir/browser.rb:46:in `initialize'
        from (irb):5:in `new'
        from (irb):5:in `<main>'
        ... 3 levels...

Operating System

Windows 10 Enterprise

Selenium version

selenium-webdriver v4.8.2, Ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x64-mingw-ucrt]

What are the browser(s) and version(s) where you see this issue?

Edge v111.0.1661.51, Chrome v111.0.5563.65

What are the browser driver(s) and version(s) where you see this issue?

chromedriver v111.0.5563.64, msedgedriver v111.0.1661.51

Are you using Selenium Grid?

No

@github-actions
Copy link

@pgundlupetvenkatesh, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@titusfortner
Copy link
Member

Can you add this before your code and provide the stdout: Selenium::WebDriver.logger.level = :debug

@Judahmeek
Copy link

@titusfortner I'm getting this in Github Actions at: https://github.com/shakacode/react_on_rails/actions/runs/4521103178/jobs/7962660421?pr=1533#step:20:157
...which you probably can view since it's a public open-source repository.

Looks like the error is that *@command is nil : DEBUG Selenium Executing Process [nil, "--port=9515"]

The odd thing is that I can't reproduce this locally on my intel mac (Ventura 13.2.1).
Our Github Actions workflow, on the other hand, is using Ubuntu 22.04.2

Please let me know if there's any more information I can provide to expedite this.

@titusfortner
Copy link
Member

titusfortner commented Mar 25, 2023

So Windows & Linux, but not Mac. 馃槮
You are both using webdrivers gem. The big change in 4.8.2 was to create a DriverFinder class to better support the new SeleniumManager features. This should replace the need for webdrivers gem, so first, can you remove require webdrivers and see what happens?

Still need to figure out what is going on.

@command is coming from this line in ServiceManager:

build_process(@executable_path, "--port=#{@port}", *@extra_args)

So it is @executable_path that is nil for some reason.

ServiceManager only has that set in its constructor from Service class.

So somehow the executable_path= in Service is getting sent nil without an exception getting raised.

Webdrivers gem works by managing the driver location and setting it in on the browser class with driver_path=, which gets picked up in the new DriverFinder"
https://github.com/SeleniumHQ/selenium/blob/trunk/rb/lib/selenium/webdriver/common/driver_finder.rb#L24

Oh, I see exactly what's going on. I added a deprecation, but didn't handle setting the Service Path.
You're hitting this line:
https://github.com/SeleniumHQ/selenium/blob/trunk/rb/lib/selenium/webdriver/common/local_driver.rb#L41

So DriverFinder isn't getting called. Which it can't be because that class can only handle Options instances and capabilities could be other things as well, but it still needs to be because we aren't processing driver_path outside of it...

Ok. I can fix.

@titusfortner
Copy link
Member

titusfortner commented Mar 25, 2023

Thanks for reporting this. Here are the options:

  1. Try removing webdrivers gem dependency, the new Selenium Manager functionality should work
  2. Update off of deprecated capabilities to use options (though this is probably Capybara & Watir's fault not yours)
  3. I added the fix 45fcc05 which will be available on the next release
  4. In about an hour tomorrow you should be able to use the nightly version: https://github.com/SeleniumHQ/selenium/pkgs/rubygems/selenium-webdriver

Please let me know if you try option 4 and it doesn't work.

Edit: My initial fix missed something so tonight's nightly gem won't work.

tvdeyen added a commit to tvdeyen/solidus_dev_support that referenced this issue Mar 26, 2023
4.8.2 introduced a bug SeleniumHQ/selenium#11815

Let's stay below until it's fixed.
@pgundlupetvenkatesh
Copy link
Author

pgundlupetvenkatesh commented Mar 26, 2023

Thanks for reporting this. Here are the options:

  1. Try removing webdrivers gem dependency, the new Selenium Manager functionality should work
  2. Update off of deprecated capabilities to use options (though this is probably Capybara & Watir's fault not yours)
  3. I added the fix 45fcc05 which will be available on the next release
  4. In about an hour tomorrow you should be able to use the nightly version: https://github.com/SeleniumHQ/selenium/pkgs/rubygems/selenium-webdriver

Please let me know if you try option 4 and it doesn't work.

Edit: My initial fix missed something so tonight's nightly gem won't work.

Just tried to install from the link you mentioned in option 4 and I got below error.

$ gem install selenium-webdriver --version "4.8.2.nightly.20230326"
ERROR:  Could not find a valid gem 'selenium-webdriver' (= 4.8.2.nightly.20230326) in any repository
ERROR:  Possible alternatives: bbc-selenium-webdriver, rainux-selenium-webdriver, selenium-webdriver, selenium-webdriver-element-decorators, selenium-webdriver-element-extend_click_again, selenium-webdriver-full-screenshot, selenium-webdriver-rails-support-via-monkeypatch, selenium-webdriver-rails-support-via-monkeypatch.gemspec, selenium-webdriver-viewers, selenium_webdriver_helper

I couldn't install it from the Gemfile as my workplace security layers blocked it when it prompted for Github's username and password.

Option 1, tried removing webdrivers dependency gem from my project but that didn't work too... was getting the same original selenium-webdriver error.

Option 2, I have been using options: parameters Watir::Browser.new(:edge, options: options) from the start... If I got you correct.

@titusfortner
Copy link
Member

Ah yeah you'd also need to remove drivers from PATH in addition to removing webdrivers gem.

I'll take a look the Watir code soon. I thought I'd already updated it, but apparently not.

For now, stick to Selenium 4.8.1

@pgundlupetvenkatesh
Copy link
Author

pgundlupetvenkatesh commented Mar 31, 2023

Updated selenium-weddriver to v4.8.6 and it works fine now. Thank you.

Copy link

github-actions bot commented Dec 9, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants