Closed10

CircleCI のドキュメント更新したい

snakasnaka

ローカル環境を構築する

bundle install が失敗した

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/xxx/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/posix-spawn-0.3.15/ext
/Users/xxx/.asdf/installs/ruby/2.7.6/bin/ruby -I /Users/xxx/.asdf/installs/ruby/2.7.6/lib/ruby/2.7.0 -r ./siteconf20240606-77403-14n38cd.rb extconf.rb
creating Makefile



current directory: /Users/xxx/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/posix-spawn-0.3.15/ext
make "DESTDIR=" clean

current directory: /Users/xxx/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/posix-spawn-0.3.15/ext
make "DESTDIR="
compiling posix-spawn.c
posix-spawn.c:226:27: error: incompatible function pointer types passing 'int (VALUE, VALUE, posix_spawn_file_actions_t *)' (aka 'int (unsigned long, unsigned long, void **)') to parameter of type 'int (*)(VALUE, VALUE,
VALUE)' (aka 'int (*)(unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
        rb_hash_foreach(options, posixspawn_file_actions_operations_iter, (VALUE)fops);
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/xxx/.asdf/installs/ruby/2.7.6/include/ruby-2.7.0/ruby/intern.h:558:35: note: passing argument to parameter here
void rb_hash_foreach(VALUE, int (*)(VALUE, VALUE, VALUE), VALUE);
                                  ^
1 error generated.
make: *** [posix-spawn.o] Error 1
snakasnaka

環境

  • CPU: Apple M3 Pro
  • OS: Sonoma 14.5
$ ruby -v
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [arm64-darwin23]
snakasnaka

上記エラーは以下ワークアラウンドで解決した

gem install posix-spawn -- --with-cflags="-Wno-incompatible-function-pointer-types"
snakasnaka

rugged のインストールに失敗した

compiling rugged.c
rugged.c:296:31: error: incompatible function pointer types passing 'VALUE (*)(VALUE, git_oid_shorten *)' (aka 'unsigned long (*)(unsigned long, struct git_oid_shorten *)') to parameter of type 'rb_block_call_func_t' (aka
'unsigned long (*)(unsigned long, unsigned long, int, const unsigned long *, unsigned long)') [-Wincompatible-function-pointer-types]
        rb_iterate(rb_each, rb_enum, &minimize_cb, (VALUE)shrt);
                                     ^~~~~~~~~~~~
/Users/xxx/.asdf/installs/ruby/2.7.6/include/ruby-2.7.0/ruby/ruby.h:1986:60: note: passing argument to parameter here
VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE);
                                                           ^
rugged.c:308:32: error: incompatible function pointer types passing 'VALUE (*)(VALUE, VALUE *)' (aka 'unsigned long (*)(unsigned long, unsigned long *)') to parameter of type 'rb_block_call_func_t' (aka 'unsigned long
(*)(unsigned long, unsigned long, int, const unsigned long *, unsigned long)') [-Wincompatible-function-pointer-types]
                rb_iterate(rb_each, rb_enum, &minimize_yield, (VALUE)yield_data);
                                             ^~~~~~~~~~~~~~~
/Users/xxx/.asdf/installs/ruby/2.7.6/include/ruby-2.7.0/ruby/ruby.h:1986:60: note: passing argument to parameter here
VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE);
                                                           ^
2 errors generated.
make: *** [rugged.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/xxx/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/rugged-1.0.1 for inspection.
Results logged to /Users/xxx/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/extensions/arm64-darwin-23/2.7.0/rugged-1.0.1/gem_make.out

An error occurred while installing rugged (1.0.1), and Bundler cannot continue.
Make sure that `gem install rugged -v '1.0.1' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  pronto was resolved to 0.11.0, which depends on
    rugged

snakasnaka

posix-spawn と同じようなエラーでワークアラウンドも同じ

$ gem install rugged -v '1.0.1' -- --with-cflags="-Wno-incompatible-function-pointer-types"
Building native extensions with: '--with-cflags=-Wno-incompatible-function-pointer-types'
This could take a while...
Successfully installed rugged-1.0.1
Parsing documentation for rugged-1.0.1
Installing ri documentation for rugged-1.0.1
Done installing documentation for rugged after 0 seconds
1 gem installed
snakasnaka

結局、以下の spec の別環境があってそちらでは rugged のインストールは完了していたので、その環境を使うことにした

  • CPU: Apple M2 Pro
  • OS: macOS 13.6.4 Ventura

今回ダメだった環境は以下

  • CPU: Apple M3 Pro
  • OS: macOS 14.5 Sonoma

CPU, OS 両方とも世代が違うため、どちらかが関係してるかは不明...

snakasnaka

かと思ったが... 違った

今 M3 Pro の環境で見てみると普通に開発環境動いているので、当時何が問題だったか思い出せない...

このスクラップは5ヶ月前にクローズされました