Techioz Blog

snappy_ext gem のインストールに関する問題

概要

私は何年も snappy_ext gem を使用してきましたが、最近 Mac M1 に Ruby と homebrew を再インストールした後、gem をインストールできなくなりました。

± uname -m
arm64

Ruby 3.2.2とRuby 2.7.6を試しました。 homebrew [email protected] と openssl@3 をリンクしてみました。 私はrvm、rbenv、chruby、さらにはfrumでも試してみました。 私は今空自にいますが、何もうまくいきません。

gem のソース コードは何年も変わっていません。

オフィスで gem をインストールできないのは私だけです。そして、最近 homebrew を再インストールしたという事実以外に何が変わったのか思いつきません。おそらく、必要だと気付かなかった重要なモジュールをいくつか失ったでしょう。

gem を手動でインストールしようとしたときに表示される出力は次のとおりです。バンドル インストールしようとすると同じことが起こります。

± gem install snappy_ext
Building native extensions. This could take a while...
ERROR:  Error installing snappy_ext:
    ERROR: Failed to build gem native extension.

    current directory: /Users/smurdoch/.asdf/installs/ruby/3.0.6/lib/ruby/gems/3.0.0/gems/snappy_ext-0.1.2/ext/snappy
/Users/smurdoch/.asdf/installs/ruby/3.0.6/bin/ruby extconf.rb
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /opt/homebrew/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking build system type... arm-apple-darwin22.6.0
checking host system type... arm-apple-darwin22.6.0
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... no
checking for -exported_symbols_list linker flag... yes
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin22.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking dependency style of g++... (cached) gcc3
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fno-common -DPIC
checking if g++ PIC flag -fno-common -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin22.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether byte ordering is bigendian... no
checking for stdint.h... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for mmap... yes
checking for 'gtest-config'... checking for gtest-config... no
no
checking for pkg-config... no
checking for gflags... checking if the compiler supports __builtin_expect... yes
checking if the compiler supports __builtin_ctzll... yes
checking for zlibVersion in -lz... yes
checking for lzo1x_1_15_compress in -llzo2... no
checking for lzf_compress in -llzf... no
checking for fastlz_compress in -lfastlz... no
checking for qlz_compress in -lquicklz... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating snappy-stubs-public.h
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
/Library/Developer/CommandLineTools/usr/bin/make  all-am
/bin/sh ./libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.     -g -O2 -MT snappy.lo -MD -MP -MF .deps/snappy.Tpo -c -o snappy.lo snappy.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -g -O2 -MT snappy.lo -MD -MP -MF .deps/snappy.Tpo -c snappy.cc  -fno-common -DPIC -o .libs/snappy.o
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -g -O2 -MT snappy.lo -MD -MP -MF .deps/snappy.Tpo -c snappy.cc -o snappy.o >/dev/null 2>&1
mv -f .deps/snappy.Tpo .deps/snappy.Plo
/bin/sh ./libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.     -g -O2 -MT snappy-sinksource.lo -MD -MP -MF .deps/snappy-sinksource.Tpo -c -o snappy-sinksource.lo snappy-sinksource.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -g -O2 -MT snappy-sinksource.lo -MD -MP -MF .deps/snappy-sinksource.Tpo -c snappy-sinksource.cc  -fno-common -DPIC -o .libs/snappy-sinksource.o
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -g -O2 -MT snappy-sinksource.lo -MD -MP -MF .deps/snappy-sinksource.Tpo -c snappy-sinksource.cc -o snappy-sinksource.o >/dev/null 2>&1
mv -f .deps/snappy-sinksource.Tpo .deps/snappy-sinksource.Plo
/bin/sh ./libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.     -g -O2 -MT snappy-stubs-internal.lo -MD -MP -MF .deps/snappy-stubs-internal.Tpo -c -o snappy-stubs-internal.lo snappy-stubs-internal.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -g -O2 -MT snappy-stubs-internal.lo -MD -MP -MF .deps/snappy-stubs-internal.Tpo -c snappy-stubs-internal.cc  -fno-common -DPIC -o .libs/snappy-stubs-internal.o
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -g -O2 -MT snappy-stubs-internal.lo -MD -MP -MF .deps/snappy-stubs-internal.Tpo -c snappy-stubs-internal.cc -o snappy-stubs-internal.o >/dev/null 2>&1
mv -f .deps/snappy-stubs-internal.Tpo .deps/snappy-stubs-internal.Plo
/bin/sh ./libtool --tag=CXX   --mode=link g++  -g -O2 -version-info 1:0:0  -o libsnappy.la -rpath /usr/local/lib snappy.lo snappy-sinksource.lo snappy-stubs-internal.lo  -lz
libtool: link: g++ -r -keep_private_externs -nostdlib -o .libs/libsnappy.1.dylib-master.o  .libs/snappy.o .libs/snappy-sinksource.o .libs/snappy-stubs-internal.o
libtool: link: g++ -dynamiclib -Wl,-flat_namespace -Wl,-undefined -Wl,suppress -o .libs/libsnappy.1.dylib .libs/libsnappy.1.dylib-master.o  -lz    -install_name  /usr/local/lib/libsnappy.1.dylib -compatibility_version 2 -current_version 2.0
ld: warning: -undefined suppress is deprecated
libtool: link: dsymutil .libs/libsnappy.1.dylib || :
libtool: link: (cd ".libs" && rm -f "libsnappy.dylib" && ln -s "libsnappy.1.dylib" "libsnappy.dylib")
libtool: link: ar cru .libs/libsnappy.a  snappy.o snappy-sinksource.o snappy-stubs-internal.o
libtool: link: ranlib .libs/libsnappy.a
libtool: link: ( cd ".libs" && rm -f "libsnappy.la" && ln -s "../libsnappy.la" "libsnappy.la" )
g++ -DHAVE_CONFIG_H -I.      -g -O2 -MT snappy_unittest-snappy_unittest.o -MD -MP -MF .deps/snappy_unittest-snappy_unittest.Tpo -c -o snappy_unittest-snappy_unittest.o `test -f 'snappy_unittest.cc' || echo './'`snappy_unittest.cc
snappy_unittest.cc:719:24: warning: implicit conversion from 'int' to 'value_type' (aka 'char') changes value from 128 to -128 [-Wconstant-conversion]
  compressed.push_back(128);
             ~~~~~~~~~ ^~~
snappy_unittest.cc:720:24: warning: implicit conversion from 'int' to 'value_type' (aka 'char') changes value from 128 to -128 [-Wconstant-conversion]
  compressed.push_back(128);
             ~~~~~~~~~ ^~~
snappy_unittest.cc:721:24: warning: implicit conversion from 'int' to 'value_type' (aka 'char') changes value from 128 to -128 [-Wconstant-conversion]
  compressed.push_back(128);
             ~~~~~~~~~ ^~~
snappy_unittest.cc:722:24: warning: implicit conversion from 'int' to 'value_type' (aka 'char') changes value from 128 to -128 [-Wconstant-conversion]
  compressed.push_back(128);
             ~~~~~~~~~ ^~~
snappy_unittest.cc:723:24: warning: implicit conversion from 'int' to 'value_type' (aka 'char') changes value from 128 to -128 [-Wconstant-conversion]
  compressed.push_back(128);
             ~~~~~~~~~ ^~~
5 warnings generated.
mv -f .deps/snappy_unittest-snappy_unittest.Tpo .deps/snappy_unittest-snappy_unittest.Po
g++ -DHAVE_CONFIG_H -I.      -g -O2 -MT snappy_unittest-snappy-test.o -MD -MP -MF .deps/snappy_unittest-snappy-test.Tpo -c -o snappy_unittest-snappy-test.o `test -f 'snappy-test.cc' || echo './'`snappy-test.cc
mv -f .deps/snappy_unittest-snappy-test.Tpo .deps/snappy_unittest-snappy-test.Po
/bin/sh ./libtool --tag=CXX   --mode=link g++  -g -O2   -o snappy_unittest snappy_unittest-snappy_unittest.o snappy_unittest-snappy-test.o libsnappy.la   -lz
libtool: link: g++ -g -O2 -o .libs/snappy_unittest snappy_unittest-snappy_unittest.o snappy_unittest-snappy-test.o -Wl,-bind_at_load  ./.libs/libsnappy.dylib -lz
ld: warning: -bind_at_load is deprecated on macOS
checking for ruby/st.h... yes
checking for -lstdc++... no
creating Makefile

ld: 45 duplicate symbols
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [snappy_ext.bundle] Error 1

make failed, exit code 2

何か案は?次はdockerを試してみようと思います。そしてシステムルビー。これで3日が経ちました。

解決策

問題を解決しました。

ここで GitHub に問題を作成しました: https://github.com/willglynn/snappy-ruby/issues/2

そして、私はここにコメントとして回避策を投稿しました: https://github.com/willglynn/snappy-ruby/issues/2#issuecomment-1751882457

参考までに、私が実行する必要があった手順の一部を次に示します。

最近、システム上のキャッシュの一部をクリアしたため、存在しない URL が突然問題になりました。

そこで私は、古い Fedora ソース コード サーバー上にある snappy-1.0.0.tar.gz バイナリのコピーを追跡しました。はい、このバージョンの snappy がかなり古いことは知っていますが、日常の仕事に戻るために、gem をインストールする必要があるのはこのバージョンです。

同じことをしたい人のために、このファイルは https://src.fedoraproject.org/repo/pkgs/snappy/snappy-1.0.0.tar.gz/9d83bdcf0c79a8de608fa969c2909204/ にあります。

私は gem をハックして、見つけるのに苦労していたバイナリの代わりにこのバイナリを使用しました。

また、gcc バージョンを gcc-13 に交換するなど、gem ソース コードにいくつかの追加の変更を加える必要がありました。これはおそらく私自身の個人的なシステム設定に特有の手順です。

とにかく、その後、gem は正常にインストールされました。