Skip to content

playwright-ruby-clientとplaywrightのバージョン不一致でNameErrorが発生する #120

@KengoTODA

Description

@KengoTODA

GitHub Actionsでは vvakame/review コンテナ内でPDFのビルドを行っていますが、このときplaywright-ruby-clientとplaywrightのバージョン不一致でNameErrorが発生することがあります。

ℹ INFO    calling Playwright       
#<Thread:0x00007fab506ff1f0 /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/transport.rb:56 run> terminated with exception (report_on_exception is true):
/var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/connection.rb:273:in `rescue in create_remote_object': Missing type Selectors (RuntimeError)
	from /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/connection.rb:265:in `create_remote_object'
	from /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/connection.rb:181:in `dispatch'
	from /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/connection.rb:11:in `block in initialize'
	from /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/transport.rb:86:in `handle_stdout'
	from /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/transport.rb:56:in `block in async_run'
/var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/connection.rb:266:in `const_get': uninitialized constant Playwright::ChannelOwners::Selectors (NameError)

          ChannelOwners.const_get(type).new(
                       ^^^^^^^^^^
Did you mean?  Playwright::SelectorsImpl
	from /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/connection.rb:266:in `create_remote_object'
	from /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/connection.rb:181:in `dispatch'
	from /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/connection.rb:11:in `block in initialize'
	from /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/transport.rb:86:in `handle_stdout'
	from /var/lib/gems/3.1.0/gems/playwright-ruby-client-1.57.0/lib/playwright/transport.rb:56:in `block in async_run'

手元では ReVIEW-build-artifact-action をforkして vvakame/review:5.9 を使いビルドしていましたが(forkするしないに関わらずエラーは発生します)、 playwright のバージョンが 1.44.0 だったため Gemfilegem 'playwright-ruby-client', '= 1.44.0' を追記して対応しました。

diff --git a/Gemfile b/Gemfile
index 5575fdf..07b2e78 100644
--- a/Gemfile
+++ b/Gemfile
@@ -4,6 +4,7 @@ source "https://rubygems.org"
 gem 'review', '5.10.0'
 gem 'pandoc2review'
 gem 'playwright-runner'
+gem 'playwright-ruby-client', '= 1.44.0'
 gem 'rake'
 # gem 'review-peg', '0.2.2'
diff --git a/package.json b/package.json
index d8ccbc6..63b4789 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
   "scripts": {
     "global-bundler": "gem install bundler",
     "global": "npm run global-bundler",
+    "postinstall": "npx playwright install",
     "pdf": "grunt pdf",
     "md": "grunt markdown",
     "html": "grunt html",

postinstall を追加したのは Gemfile の更新だけだとブラウザが見つからないとのエラーが発生したためです:

/var/lib/gems/3.1.0/gems/concurrent-ruby-1.3.6/lib/concurrent-ruby/concurrent/promises.rb:1268:in `raise': Executable doesn't exist at /github/home/.cache/ms-playwright/chromium-1117/chrome-linux/chrome (Playwright::Error)
╔════════════════════════════════════════════════════════════╗
║ Looks like Playwright was just installed or updated.       ║
║ Please run the following command to download new browsers: ║
║                                                            ║
║     playwright install                                     ║
║                                                            ║
║ <3 Playwright Team                                         ║
╚════════════════════════════════════════════════════════════╝

あまりきれいな解決ではないと思いますが、他のユーザの参考になれば幸いです。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions