Rails(6) アプリケーションで ovirt-engine-sdk gem を使用しようとしています。私の Mac ARM64 マシンではバンドルのインストールが失敗します。 gem のドキュメントによると、gem は Ruby 3.x バージョンで動作するはずですが、バンドル インストールを行うと次のエラーが発生します。
gem install ovirt-engine-sdk
Building native extensions with: '--with-opt-dir=/opt/homebrew/opt/openssl@3 --with-ldflags=-L/opt/homebrew/opt/zstd/lib --with-cflags=-Wno-error=implicit-function-declaration'
This could take a while...
ERROR: Error installing ovirt-engine-sdk:
ERROR: Failed to build gem native extension.
current directory: /Users/ljehle/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
/Users/ljehle/.rbenv/versions/3.0.0/bin/ruby -I /Users/ljehle/.rbenv/versions/3.0.0/lib/ruby/3.0.0 -r ./siteconf20240416-66199-2y5wag.rb extconf.rb --with-opt-dir\=/opt/homebrew/opt/openssl@3 --with-ldflags\=-L/opt/homebrew/opt/zstd/lib --with-cflags\=-Wno-error\=implicit-function-declaration
checking for xml2-config... yes
checking for curl-config... yes
creating Makefile
current directory: /Users/ljehle/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
make "DESTDIR=" clean
current directory: /Users/ljehle/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/ovirt-engine-sdk-4.6.0/ext/ovirtsdk4c
make "DESTDIR="
compiling ov_error.c
compiling ov_http_client.c
ov_http_client.c:216:29: warning: excess elements in array initializer [-Wexcess-initializers]
.reserved = { NULL, NULL }
^~~~
/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/stddef.h:89:16: note: expanded from macro 'NULL'
# define NULL ((void*)0)
^~~~~~~~~~
ov_http_client.c:501:9: warning: call to undeclared function 'ruby_thread_has_gvl_p'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if (ruby_thread_has_gvl_p()) {
^
ov_http_client.c:853:25: warning: implicit conversion from enumeration type 'CURLMcode' to different enumeration type 'CURLcode' [-Wenum-conversion]
context_ptr->code = curl_multi_wait(context_ptr->handle, NULL, 0, timeout, NULL);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ov_http_client.c:874:25: warning: implicit conversion from enumeration type 'CURLMcode' to different enumeration type 'CURLcode' [-Wenum-conversion]
context_ptr->code = curl_multi_perform(context_ptr->handle, &pending);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ov_http_client.c:1009:47: error: incompatible function pointer types passing 'int (VALUE, VALUE, struct curl_slist **)' (aka 'int (unsigned long, unsigned long, struct curl_slist **)') to parameter of type 'int (*)(VALUE, VALUE, VALUE)' (aka 'int (*)(unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
rb_hash_foreach(request_ptr->headers, ov_http_client_add_header, (VALUE) headers);
^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ljehle/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/internal/intern/hash.h:33:35: note: passing argument to parameter here
void rb_hash_foreach(VALUE, int (*)(VALUE, VALUE, VALUE), VALUE);
^
4 warnings and 1 error generated.
make: *** [ov_http_client.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/ljehle/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/ovirt-engine-sdk-4.6.0 for inspection.
Results logged to /Users/ljehle/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/extensions/arm64-darwin-23/3.0.0/ovirt-engine-sdk-4.6.0/gem_make.out
どうやら、この gem の Ruby 3 サポートはまだ進行中です。次のプル リクエストを参照してください: https://github.com/oVirt/ovirt-engine-sdk-ruby/pull/10。実際、変更内容を確認すると、ruby_thread_has_gvl_p 関数の使用法 (ログに表示される) に関連する C 拡張機能の変更がいくつかあります。
それまでの間、Gemfile でその GitHub ブランチを指定できるため、修正をテストできます。
gem "ovirt-engine-sdk", github: "jhernand/ovirt-engine-sdk-ruby", branch: "update_to_ruby_3"