@ledsun blog

無味の味は佳境に入らざればすなわち知れず

WSLgでrabbitを動かす

Rubyで作られたプレゼンテーションツールにRabbitがあります。 GUI部分がGTKを使って作られています。 Windowsで動かすのはすこし面倒な印象があり避けていました。 いまならWSLgがあるため、WSL上で動くGUI付きのアプリケーションを無設定で動かせます。 ということはRabbitも簡単に動かせるはずです。

環境

インストール

gem install rabbit

インストールの途中でsudoパスワードを求められます。 GTK関連のインストールのようです。

GUIが上手く表示されるか確認するために、rabbit-slideコマンドを実行してみます。

rabbit-slideコマンドの実行に成功したスクリーンショット

上手く行きました。 調子に乗って、そのまま適当な値を入力して、空のスライドを作成します。 作成されたスライドディレクトリに移動してから、rabbitコマンドでスライドを表示します。

rabbitコマンドの実行に成功して表示されたスライドのスクリーンショット

上手く行きました。 さらに、調子にのってdRubyで接続してみます。 irb -r drbirbを起動します。

rabbit = DRbObject.new_with_uri 'druby://localhost:10101'

を実行すると一見成功します。 しかし、つづけてrabbit.titleなどのメソッドを呼び出そうとするとエラーがおきます。

irb(main):003> rabbit.title
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:744:in `rescue in block in open': druby://localhost:10101 - #<Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 10101> (DRb::DRbConnError)
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:738:in `block in open'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:737:in `each'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:737:in `open'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1319:in `initialize'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1302:in `new'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1302:in `open'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1143:in `block in method_missing'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1162:in `with_friend'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1142:in `method_missing'
        from (irb):3:in `<main>'
        from <internal:kernel>:187:in `loop'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/irb-1.14.0/exe/irb:9:in `<top (required)>'
        from /home/ledsun/.rbenv/versions/3.3.5/bin/irb:25:in `load'
        from /home/ledsun/.rbenv/versions/3.3.5/bin/irb:25:in `<main>'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:840:in `initialize': Connection refused - connect(2) for "localhost" port 10101 (Errno::ECONNREFUSED)
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:840:in `open'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:840:in `open'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:739:in `block in open'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:737:in `each'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:737:in `open'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1319:in `initialize'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1302:in `new'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1302:in `open'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1143:in `block in method_missing'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1162:in `with_friend'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/3.3.0/drb/drb.rb:1142:in `method_missing'
        from (irb):3:in `<main>'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/irb-1.14.0/lib/irb/workspace.rb:121:in `eval'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/irb-1.14.0/lib/irb/workspace.rb:121:in `evaluate'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/irb-1.14.0/lib/irb/context.rb:633:in `evaluate_expression'
        from /home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/irb-1.14.0/lib/irb/context.rb:601:in `evaluate'
        ... 14 levels...

rabbitコマンドを実行したターミナルをよく見るとエラーが起きています。

rabbit 
Gdk-Message: 11:59:06.573: Unable to load pencil from the cursor theme
[ERROR]
RuntimeError: failed to initialize
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:715:in `invoke'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:715:in `invoke'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:366:in `block (2 levels) in initialize'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:365:in `catch'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:365:in `block in initialize'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:364:in `each'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:364:in `initialize'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gdk3-4.2.3/lib/gdk3/cursor.rb:44:in `initialize'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gdk3-4.2.3/lib/gdk3/cursor.rb:25:in `new'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gdk3-4.2.3/lib/gdk3/cursor.rb:25:in `new'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/cursor-manager.rb:25:in `cursors'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/cursor-manager.rb:60:in `type_to_cursor'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/cursor-manager.rb:52:in `update'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/renderer/display/cursor.rb:28:in `update_cursor'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/renderer/display/drawing-area-primitive.rb:86:in `post_parse'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/renderer/display/info.rb:29:in `post_parse'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/renderer/display/drawing-area-base.rb:79:in `post_parse'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/canvas.rb:371:in `block in parse'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/canvas.rb:795:in `keep_index'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/canvas.rb:357:in `parse'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/frame.rb:62:in `parse'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/command/rabbit.rb:699:in `parse'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/command/rabbit.rb:861:in `do_display'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/command/rabbit.rb:61:in `block (2 levels) in run'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/command/rabbit.rb:59:in `catch'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/command/rabbit.rb:59:in `block in run'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:715:in `invoke'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:715:in `invoke'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:583:in `activate'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/command/rabbit.rb:54:in `block in run'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:715:in `invoke'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:715:in `invoke'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/gobject-introspection-4.2.3/lib/gobject-introspection/loader.rb:583:in `run'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/command/rabbit.rb:67:in `run'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/lib/rabbit/command/rabbit.rb:29:in `run'
/home/ledsun/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rabbit-3.0.3/bin/rabbit:22:in `<top (required)>'
/home/ledsun/.rbenv/versions/3.3.5/bin/rabbit:25:in `load'
/home/ledsun/.rbenv/versions/3.3.5/bin/rabbit:25:in `<main>'

Gdk-Message: 11:59:06.573: Unable to load pencil from the cursor theme

で、検索してみます。 Cursors cannot be loaded · Issue #757 · microsoft/wslg · GitHubが見つかります。 コメントを見ていくと、さらにRunning Linux App on WSL2 is very unreliable · Issue #7750 · microsoft/WSL · GitHubが見つかります。 どうやらadwaita-icon-theme-fullパッケージをインストールすると良さそうです。 sudo apt install adwaita-icon-theme-fullを実行します。 改めてrabbitコマンドを実行すると、エラーが消えました。

irb(main):002> rabbit.title
=> "TITLE"

dRubyからの操作も成功しました。

参考