I have been using snappy_ext gem for years, and I am now unable to install the gem after recently reinstalling ruby and homebrew on my Mac M1:
± uname -m
arm64
I've tried ruby 3.2.2, and ruby 2.7.6. I've tried linking homebrew [email protected], and openssl@3. I've tried it with rvm, rbenv, chruby and even frum. I'm now on asdf, and nothing is working.
The gem source code has not changed in years:
I am the only one in the office who can not install the gem. And I can't think what might have changed besides the fact that I recently reinstalled homebrew, and probably lost some vital module that I didn't realise I needed.
Here is the output I see when I try to install the gem manually, the same thing happens when I try to bundle install:
± 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
Any ideas? I'm thinking of trying docker next. And then system ruby. It's been 3 days of this.
I fixed the problem.
I created an issue on GitHub here: https://github.com/willglynn/snappy-ruby/issues/2
And I posted my workaround as a comment here: https://github.com/willglynn/snappy-ruby/issues/2#issuecomment-1751882457
For reference, here are some of the steps I had to take:
I have recently cleared some of the caches on my system, so the non-existent url has suddenly become an issue.
So I tracked down a copy of the snappy-1.0.0.tar.gz binary on an old fedora source code server. Yes I know this version of snappy is way out of date, but it's the one I need to get the gem to install, so that I can get back to doing my day job.
The file can be found here https://src.fedoraproject.org/repo/pkgs/snappy/snappy-1.0.0.tar.gz/9d83bdcf0c79a8de608fa969c2909204/ for those who want to do the same.
I hacked the gem up to use this binary instead of the one it was having trouble finding.
I also had to make a few extra changes to the gem source code, like swapping the gcc version to gcc-13, steps which are probably specific to my own personal system setup.
Anyway, the gem installed fine after all that.