安装 snappy_ext gem 时遇到问题

问题描述 投票:0回答:1

我已经使用 snappy_ext gem 多年了,最近在我的 Mac M1 上重新安装 ruby 和 homebrew 后,现在无法安装 gem:

± uname -m
arm64

我尝试过 ruby 3.2.2 和 ruby 2.7.6。 我尝试链接自制软件 [电子邮件受保护] 和 openssl@3。 我已经尝试过 rvm、rbenv、chruby 甚至 frum。 我现在使用 asdf,但没有任何效果。

gem 源代码多年未变:

我是办公室里唯一一个不会安装gem的人。除了我最近重新安装了自制程序这一事实之外,我无法想象可能会发生什么变化,并且可能丢失了一些我没有意识到我需要的重要模块。

这是我尝试手动安装 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天了

ruby rubygems clang apple-m1 snappy
1个回答
0
投票

我解决了问题。

我在 GitHub 上创建了一个问题:https://github.com/willglynn/snappy-ruby/issues/2

我在这里发布了我的解决方法作为评论:https://github.com/willglynn/snappy-ruby/issues/2#issuecomment-1751882457

作为参考,以下是我必须采取的一些步骤:

主要问题是 snappy_ext gem 从不再存在的 google code 存储库中提取 snappy 源代码。

我最近清除了系统上的一些缓存,因此不存在的网址突然成为一个问题。

因此我在旧的 Fedora 源代码服务器上找到了 snappy-1.0.0.tar.gz 二进制文件的副本。是的,我知道这个版本的 snappy 已经过时了,但这是我需要安装 gem 的版本,这样我就可以继续做我的日常工作。

可以在此处找到该文件https://src.fedoraproject.org/repo/pkgs/snappy/snappy-1.0.0.tar.gz/9d83bdcf0c79a8de608fa969c2909204/对于那些想做同样事情的人。

我破解了 gem 以使用这个二进制文件,而不是它无法找到的二进制文件。

我还必须对 gem 源代码进行一些额外的更改,例如将 gcc 版本交换为 gcc-13,这些步骤可能特定于我自己的个人系统设置。

无论如何,宝石安装得很好。

© www.soinside.com 2019 - 2024. All rights reserved.