OK, I’m at the end of my tether with this. There are a few similar questions but they all refer to therubyracer 0.10, and they mostly conclude that the problem can be fixed by upgrading to 0.12.
I’m having similar problems, but when I use 0.12.
Similar questions
Installing libv8 gem on Mavericks
How to fix libv8 error from Gemfile on Mavericks?
I’m having problems using ‘standard’ (xcode?) gcc, and both apple-gcc42 and gcc from homebrew. I’ve tried both --with-system-v8 and --without-system-v8, and again, no dice.
Here’s some logs:
Starting from scratch…
$ cd ~/Documents/code/website
$ rvm gemset empty
$ ruby -v
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin10.8.0]
$ grep rubyracer Gemfile
gem 'therubyracer', '~> 0.12.0'
$ brew list | grep v8
$ cat ~/.bundle/config
$ cat .bundle/config
BUNDLE_BIN: bin
$ $CXX
$ $CPP
$ $CC
$ which gcc
/usr/bin/gcc
$ which g++
/usr/bin/g++
$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-
gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
Try a bundle install
Installing libv8 (3.16.14.3)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.5
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Using compiler: g++
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
^
1 error generated.
make[1]: *** [/Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o] Error 1
make: *** [x64.release] Error 2
/Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
from /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `each'
from /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `verify_installation!'
from /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in `install!'
from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
build/gyp/gyp --generator-output="out" build/all.gyp \
-Ibuild/standalone.gypi --depth=. \
-Dv8_target_arch=x64 \
-S.x64 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o
Gem files will remain installed in /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3 for inspection.
Results logged to /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/ext/libv8/gem_make.out
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
Bad times.
Error message advises that gcc 4.4+ is recommended. We can do that.
$ export CXX=/usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8
$ export CPP=/usr/local/Cellar/gcc48/4.8.2/bin/cpp-4.8
$ export CC=/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8
$ which $CXX
/usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8
$ which $CPP
/usr/local/Cellar/gcc48/4.8.2/bin/cpp-4.8
$ which $CC
/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8
$ bundle install
…
Installing libv8 (3.16.14.3)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.5
Using compiler: /usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8
g++-4.8: error: unrecognized command line option '-Wnewline-eof'
make[1]: *** [/Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o] Error 1
make: *** [x64.release] Error 2
/Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
from /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `each'
from /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `verify_installation!'
from /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in `install!'
from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
build/gyp/gyp --generator-output="out" build/all.gyp \
-Ibuild/standalone.gypi --depth=. \
-Dv8_target_arch=x64 \
-S.x64 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3
CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
Gem files will remain installed in /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3 for inspection.
Results logged to /Users/chris/.rvm/gems/ruby-1.9.3-p448#website/gems/libv8-3.16.14.3/ext/libv8/gem_make.out
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.
Worse times!
OK. So to fix the issues with therubyracer 0.10, some people recommend brew installing v8, then telling rubygems to use system v8. Let’s see what happens!
$ brew install v8
==> Downloading https://github.com/v8/v8/archive/3.21.17.tar.gz
Already downloaded: /Library/Caches/Homebrew/v8-3.21.17.tar.gz
==> Checking out http://gyp.googlecode.com/svn/trunk
==> make native -j4 library=shared snapshot=on console=readline i18nsupport=off
🍺 /usr/local/Cellar/v8/3.21.17: 21 files, 27M, built in 3.4 minutes
$ cat ~/.bundle/config
---
BUNDLE_BUILD__LIBV8: --with-system-v8
$ bundle install
…
Installing therubyracer (0.12.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
checking for v8.h... yes
creating Makefile
make
compiling accessor.cc
clang: warning: argument unused during compilation: '-rdynamic'
In file included from accessor.cc:1:
./rr.h:463:14: error: no type named 'AccessorGetter' in namespace 'v8'
inline v8::AccessorGetter accessorGetter() {return &AccessorGetter;}
~~~~^
./rr.h:464:14: error: no type named 'AccessorSetter' in namespace 'v8'
inline v8::AccessorSetter accessorSetter() {return RTEST(set) ? &AccessorSetter : 0;}
~~~~^
./rr.h:466:14: error: no type named 'NamedPropertyGetter' in namespace 'v8'
inline v8::NamedPropertyGetter namedPropertyGetter() {return &NamedPropertyGetter;}
~~~~^
./rr.h:467:14: error: no type named 'NamedPropertySetter' in namespace 'v8'
inline v8::NamedPropertySetter namedPropertySetter() {return RTEST(set) ? &NamedPropertySetter : 0;}
~~~~^
./rr.h:468:14: error: no type named 'NamedPropertyQuery' in namespace 'v8'
inline v8::NamedPropertyQuery namedPropertyQuery() {return RTEST(query) ? &NamedPropertyQuery : 0;}
~~~~^
./rr.h:469:14: error: no type named 'NamedPropertyDeleter' in namespace 'v8'
inline v8::NamedPropertyDeleter namedPropertyDeleter() {return RTEST(deleter) ? &NamedPropertyDeleter : 0;}
~~~~^
./rr.h:470:14: error: no type named 'NamedPropertyEnumerator' in namespace 'v8'
inline v8::NamedPropertyEnumerator namedPropertyEnumerator() {return RTEST(enumerator) ? &NamedPropertyEnumerator : 0;}
~~~~^
./rr.h:472:14: error: no type named 'IndexedPropertyGetter' in namespace 'v8'
inline v8::IndexedPropertyGetter indexedPropertyGetter() {return &IndexedPropertyGetter;}
~~~~^
./rr.h:473:14: error: no type named 'IndexedPropertySetter' in namespace 'v8'
inline v8::IndexedPropertySetter indexedPropertySetter() {return RTEST(set) ? &IndexedPropertySetter : 0;}
~~~~^
./rr.h:474:14: error: no type named 'IndexedPropertyQuery' in namespace 'v8'
inline v8::IndexedPropertyQuery indexedPropertyQuery() {return RTEST(query) ? &IndexedPropertyQuery : 0;}
~~~~^
./rr.h:475:14: error: no type named 'IndexedPropertyDeleter' in namespace 'v8'
inline v8::IndexedPropertyDeleter indexedPropertyDeleter() {return RTEST(deleter) ? &IndexedPropertyDeleter : 0;}
~~~~^
./rr.h:476:14: error: no type named 'IndexedPropertyEnumerator' in namespace 'v8'
inline v8::IndexedPropertyEnumerator indexedPropertyEnumerator() {return RTEST(enumerator) ? &IndexedPropertyEnumerator : 0;}
~~~~^
./rr.h:482:16: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
Info(const v8::AccessorInfo& info);
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor {
^
./rr.h:488:18: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
inline const v8::AccessorInfo* operator->() {return this->info;}
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor {
^
./rr.h:502:11: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
const v8::AccessorInfo* info;
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor {
^
./rr.h:506:85: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
static v8::Handle<v8::Value> AccessorGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor {
^
./rr.h:507:96: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
static void AccessorSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor {
^
./rr.h:509:90: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
static v8::Handle<v8::Value> NamedPropertyGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor {
^
./rr.h:510:118: error: no type named 'AccessorInfo' in namespace 'v8'; did you mean 'Accessor'?
static v8::Handle<v8::Value> NamedPropertySetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
^~~~~~~~~~~~~~~~
Accessor
./rr.h:456:7: note: 'Accessor' declared here
class Accessor {
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [accessor.o] Error 1
Gem files will remain installed in /Users/chris/.rvm/gems/ruby-1.9.3-p448/gems/therubyracer-0.12.1 for inspection.
Results logged to /Users/chris/.rvm/gems/ruby-1.9.3-p448/gems/therubyracer-0.12.1/ext/v8/gem_make.out
An error occurred while installing therubyracer (0.12.1), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.12.1'` succeeds before bundling.
Completely scratching my head, and already wasted hours on this. If you can spot what’s going wrong and help me fix it, you’ll be my hero(ine) forever.
I was able to proceed with ruby racer after rm Gemfile.lock Perhaps try this, which is easier than the RVM nuke option.
beforehand:
I installed v8 via brew install v8, and then did gem install libv8 -v '3.16.14.3' -- --with-system-v8
and I am running 10.10 Yosemite
I was able to get things going again by running gem install libv8 -v '3.16.14.3' -- --with-system-v8.
Reference: https://github.com/cowboyd/libv8/issues/120
OK, so this is now sorted.
For future people with the same problem, I was suffering from having ruby built against a previous installation of OS X.
Fixed by completely nuking rvm and starting from scratch, though I imagine you could just uninstall/reinstall the offending ruby.
More details on how the problem was solved here:
https://github.com/cowboyd/libv8/issues/120
Same issue with OSX 10.9.3, ruby 2.1.3 and every version of therubyracer.
Now i'm letting execjs (uglifier gem dependencie) take care of it.
ExecJS lets you run JavaScript code from Ruby. It automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Ruby object.
OSX users
"Apple JavaScriptCore" comes as default for JS runtime on OSX. Just installing execjs will solve the problem.
Linux users
Install node.js. Execjs gem will automatically choose node.js as js runtime.
sudo apt-get install nodejs
More information on github:
https://github.com/sstephenson/execjs
It could be that rubygems is fetching the wrong binaries for your system.
Diagnosis:
Compare the output of gem env platform to 'Kernel Version' under > About This Mac > System Report > Software
If those don't match (e.g. Kernel Version: 14.4.0 and x86_64-darwin-12) then RubyGems is grabbing the wrong version of therubyracer and libv8 for your system
Fix:
short-term: bundle update therubyracer --platform=x86_64-darwin-14
This issue no longer exists in the latest version of therubyracer (0.12.3).
bundle update therubyracer
I had this same problem when I upgraded from OSX Mountain Lion to OSX Mavericks.
The patch level of ruby 1.8.7 apparently matters.
Upgrading from ruby-1.8.7-p354 to ruby-1.8.7-375 did the trick for me.
libv8 (3.16.14.3-x86_64-darwin-13) and the therubyracer (0.12.0) gems installed without problem.
assuming you use rbenv:
rbenv versions
system
* 1.8.7-p354
2.0.0-rc2
rbenv uninstall 1.8.7-p354
rbenv install 1.8.7-p375
rbenv versions
system
* 1.8.7-p375
2.0.0-rc2
bundle install
Related
I am trying to update our Ruby version from 2.7.4 to 3.0.2. If I bundle locally on my machine, I get this error:
rmimage.c:12960:1: error: implicit declaration of function 'C__Bool_to_R__Bool' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
DEF_ATTR_ACCESSOR(Image, start_loop, bool)
^
./rmagick.h:460:5: note: expanded from macro 'DEF_ATTR_ACCESSOR'
DEF_ATTR_READER(class, attr, type)\
^
./rmagick.h:417:16: note: expanded from macro 'DEF_ATTR_READER'
return C_##type##_to_R_##type(ptr->attr);\
^
If use Docker, I manage to build an image using ruby:3.0.2-alpine3.12, however I get this error if I try to load the project inside a container:
LoadError:
Error relocating /app/vendor/bundle/ruby/3.0.0/gems/rmagick-3.2.0/lib/RMagick2.so: R__Bool_to_C__Bool: symbol not found - /app/vendor/bundle/ruby/3.0.0/gems/rmagick-3.2.0/lib/RMagick2.so
I have no clue what's wrong and how to proceed, so any help would be highly appreciated!
If you use rmagick < 3, macOS and Homebrew, Try with the following command:
CFLAGS=‘-Wno-implicit-function-declaration’ gem i rmagick -v 2.16.0 -- --with-opt-dir=$(brew --prefix imagemagick#6)
The latest version of rmagick is resolved this issue. I recommend to update rmagick and ruby version.
Describe the bug
I have tried to do a gem install puma and gem install thin and get an error.
I have a brand new Mac that I am setting up: MacOS Catalina 10.15.6 (19G73)
I have worked out that any version <= 4.2.1 works fine on my computer
I am using asdf version manager
Works: gem install puma -v '4.2.1'
Fails: gem install puma -v '4.3.0' or gem install pumad
Error for Puma
I have tried each of these commands to get this to work
gem install puma
gem install puma -v '4.3.0' -- --with-ldflags=-L/usr/local/opt/openssl#1.1/lib --with-cppflags=-I/usr/local/opt/openssl#1.1/include
gem install puma -v '4.3.0' -- --with-ldflags=-L/usr/local/opt/openssl#1.1/lib --with-cppflags=-I/usr/local/opt/openssl#1.1/include --with-opt-dir=/usr/local/opt/openssl#1.1
Building native extensions. This could take a while...
ERROR: Error installing puma:
ERROR: Failed to build gem native extension.
current directory: /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5/ext/puma_http11
/Users/myname/.asdf/installs/ruby/2.7.1/bin/ruby -I /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/site_ruby/2.7.0 -r ./siteconf20200806-17963-1cqtelz.rb extconf.rb
checking for BIO_read() in -lcrypto... yes
checking for SSL_CTX_new() in -lssl... yes
checking for openssl/bio.h... yes
checking for DTLS_method() in openssl/ssl.h... yes
checking for TLS_server_method() in openssl/ssl.h... yes
checking for SSL_CTX_set_min_proto_version in openssl/ssl.h... yes
creating Makefile
current directory: /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5/ext/puma_http11
make "DESTDIR=" clean
current directory: /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5/ext/puma_http11
make "DESTDIR="
compiling http11_parser.c
ext/puma_http11/http11_parser.c:44:18: warning: unused variable 'puma_parser_en_main' [-Wunused-const-variable]
static const int puma_parser_en_main = 1;
^
1 warning generated.
compiling io_buffer.c
compiling mini_ssl.c
mini_ssl.c:145:7: warning: unused variable 'min' [-Wunused-variable]
int min, ssl_options;
^
mini_ssl.c:299:40: warning: function 'raise_error' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
void raise_error(SSL* ssl, int result) {
^
2 warnings generated.
compiling puma_http11.c
puma_http11.c:203:22: error: implicitly declaring library function 'isspace' with type 'int (int)' [-Werror,-Wimplicit-function-declaration]
while (vlen > 0 && isspace(value[vlen - 1])) vlen--;
^
puma_http11.c:203:22: note: include the header <ctype.h> or explicitly provide a declaration for 'isspace'
1 error generated.
make: *** [puma_http11.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5 for inspection.
Results logged to /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/puma-4.3.5/gem_make.out
I saw on this thread that you need OpenSSL 1.1
OpenSSL#1.1
I reinstalled openssl
brew reinstall openssl#1.1
==> Downloading https://homebrew.bintray.com/bottles/openssl%401.1-1.1.1g.catalina.bottle.tar.gz
Already downloaded: /Users/myname/Library/Caches/Homebrew/downloads/d6b7a6d80c588c89e79f350ce3e05c95d31d804291cc120efcbb6c9478607a41--openssl#1.1-1.1.1g.catalina.bottle.tar.gz
==> Reinstalling openssl#1.1
==> Pouring openssl#1.1-1.1.1g.catalina.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/openssl#1.1/certs
and run
/usr/local/opt/openssl#1.1/bin/c_rehash
openssl#1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.
If you need to have openssl#1.1 first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl#1.1/bin:$PATH"' >> ~/.zshrc
For compilers to find openssl#1.1 you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl#1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl#1.1/include"
For pkg-config to find openssl#1.1 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl#1.1/lib/pkgconfig"
I tested with these lines in .zshrc
export PATH="/usr/local/opt/openssl#1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl#1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl#1.1/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl#1.1/lib/pkgconfig"
Install for Thin
gem install thin
Building native extensions. This could take a while...
ERROR: Error installing thin:
ERROR: Failed to build gem native extension.
current directory: /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/thin-1.7.2/ext/thin_parser
/Users/myname/.asdf/installs/ruby/2.7.1/bin/ruby -I /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/site_ruby/2.7.0 -r ./siteconf20200806-18426-1lt7u04.rb extconf.rb
checking for main() in -lc... yes
creating Makefile
current directory: /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/thin-1.7.2/ext/thin_parser
make "DESTDIR=" clean
current directory: /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/thin-1.7.2/ext/thin_parser
make "DESTDIR="
compiling parser.c
parser.c:31:18: warning: unused variable 'http_parser_en_main' [-Wunused-const-variable]
static const int http_parser_en_main = 1;
^
1 warning generated.
compiling thin.c
thin.c:242:3: error: implicit declaration of function 'thin_http_parser_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
thin_http_parser_init(hp);
^
thin.c:242:3: note: did you mean 'http_parser_init'?
./parser.h:41:5: note: 'http_parser_init' declared here
int http_parser_init(http_parser *parser);
^
thin.c:260:3: error: implicit declaration of function 'thin_http_parser_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
thin_http_parser_init(http);
^
thin.c:277:3: error: implicit declaration of function 'thin_http_parser_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
thin_http_parser_init(http);
^
thin.c:294:3: error: implicit declaration of function 'thin_http_parser_finish' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
thin_http_parser_finish(http);
^
thin.c:294:3: note: did you mean 'Thin_HttpParser_finish'?
thin.c:290:7: note: 'Thin_HttpParser_finish' declared here
VALUE Thin_HttpParser_finish(VALUE self)
^
thin.c:296:10: error: implicit declaration of function 'thin_http_parser_is_finished' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return thin_http_parser_is_finished(http) ? Qtrue : Qfalse;
^
thin.c:334:5: error: implicit declaration of function 'thin_http_parser_execute' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
thin_http_parser_execute(http, dptr, dlen, from);
^
thin.c:334:5: note: did you mean 'Thin_HttpParser_execute'?
thin.c:317:7: note: 'Thin_HttpParser_execute' declared here
VALUE Thin_HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE start)
^
thin.c:338:8: error: implicit declaration of function 'thin_http_parser_has_error' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if(thin_http_parser_has_error(http)) {
^
thin.c:338:8: note: did you mean 'http_parser_has_error'?
./parser.h:44:5: note: 'http_parser_has_error' declared here
int http_parser_has_error(http_parser *parser);
^
thin.c:359:10: error: implicit declaration of function 'thin_http_parser_has_error' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return thin_http_parser_has_error(http) ? Qtrue : Qfalse;
^
thin.c:374:10: error: implicit declaration of function 'thin_http_parser_is_finished' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return thin_http_parser_is_finished(http) ? Qtrue : Qfalse;
^
9 errors generated.
make: *** [thin.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/thin-1.7.2 for inspection.
Results logged to /Users/myname/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/thin-1.7.2/gem_make.out
The Puma team pointed me to a temporary solution for compiling puma.
gem install puma:4.3.5 -- --with-cflags="-Wno-error=implicit-function-declaration"
I used this variant for the latest version
gem install puma -- --with-cflags="-Wno-error=implicit-function-declaration"
I was also able to use this same technique to with thin, but I have not tested whether the gem works.
gem install thin -- --with-cflags="-Wno-error=implicit-function-declaration"
bundle config build.thin --with-cflags="-Wno-error=implicit-function-declaration"
opened https://github.com/macournoyer/thin/issues/370 to get it fixed or documented in thin
This question already has answers here:
puma gem - Failed to build gem native extension
(13 answers)
Closed 2 years ago.
fail to bundle install puma 4.3.5 or gem puma with ruby-2.6.6 on macos-10.15.6
try to bundle dependencies for my project, but puma 4.3.5 occured an error.
someone know about this?
xxxxxxxxxxxx
here is the error content:
fetching puma 4.3.5
Installing puma 4.3.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/lxj/.rvm/gems/ruby-2.6.6/gems/puma-4.3.5/ext/puma_http11
/Users/lxj/.rvm/rubies/ruby-2.6.6/bin/ruby -I /Users/lxj/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0 -r ./siteconf20200731-28585-1eobsvu.rb extconf.rb
checking for BIO_read() in -lcrypto... yes
checking for SSL_CTX_new() in -lssl... yes
checking for openssl/bio.h... yes
checking for DTLS_method() in openssl/ssl.h... yes
checking for TLS_server_method() in openssl/ssl.h... yes
checking for SSL_CTX_set_min_proto_version in openssl/ssl.h... yes
creating Makefile
current directory: /Users/lxj/.rvm/gems/ruby-2.6.6/gems/puma-4.3.5/ext/puma_http11
make "DESTDIR=" clean
current directory: /Users/lxj/.rvm/gems/ruby-2.6.6/gems/puma-4.3.5/ext/puma_http11
make "DESTDIR="
compiling http11_parser.c
ext/puma_http11/http11_parser.c:44:18: warning: unused variable 'puma_parser_en_main' [-Wunused-const-variable]
static const int puma_parser_en_main = 1;
^
1 warning generated.
compiling io_buffer.c
compiling mini_ssl.c
mini_ssl.c:145:7: warning: unused variable 'min' [-Wunused-variable]
int min, ssl_options;
^
mini_ssl.c:299:40: warning: function 'raise_error' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
void raise_error(SSL* ssl, int result) {
^
2 warnings generated.
compiling puma_http11.c
puma_http11.c:203:22: error: implicitly declaring library function 'isspace' with type 'int (int)' [-Werror,-Wimplicit-function-declaration]
while (vlen > 0 && isspace(value[vlen - 1])) vlen--;
^
puma_http11.c:203:22: note: include the header <ctype.h> or explicitly provide a declaration for 'isspace'
1 error generated.
make: *** [puma_http11.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/lxj/.rvm/gems/ruby-2.6.6/gems/puma-4.3.5 for inspection.
Results logged to /Users/lxj/.rvm/gems/ruby-2.6.6/extensions/x86_64-darwin-19/2.6.0/puma-4.3.5/gem_make.out
An error occurred while installing puma (4.3.5), and Bundler cannot continue.
Make sure that `gem install puma -v '4.3.5'` succeeds before bundling.
In Gemfile:
puma
Locked. Comments on this answer have been disabled, but it is still accepting other interactions. Learn more.
It seems that the latest version of XCode tools (12 Beta 3) installs a version of Clang (the C compiler used by default on MacOS) that throws an error on implicit functions used on the native extension code of Puma.
The workaround as pointed out here is to tell Clang not to treat this behavior as an error.
Try running:
bundle config build.puma --with-cflags="-Wno-error=implicit-function-declaration"
bundle install
and it should work.
noob here, I'm trying to install octopress but when i run rbenv exec bundle install i got this error.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/home/idiot/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/yajl-ruby-1.2.1/ext/yajl
/home/idiot/.rbenv/versions/2.4.0/bin/ruby -r ./siteconf20170227-4161-uizrqn.rb extconf.rb
creating Makefile
current directory:
/home/idiot/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/yajl-ruby-1.2.1/ext/yajl
make "DESTDIR=" clean
current directory:
/home/idiot/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/yajl-ruby-1.2.1/ext/yajl
make "DESTDIR="
compiling yajl.c
compiling yajl_alloc.c
compiling yajl_buf.c
compiling yajl_encode.c
compiling yajl_ext.c
yajl_ext.c: In function ‘rb_yajl_parser_parse’:
yajl_ext.c:471:17: warning: variable ‘stat’ set but not used [Wunused-but-set-variable]
yajl_status stat;
^~~~
yajl_ext.c: In function ‘rb_yajl_encoder_enable_json_gem_ext’:
yajl_ext.c:881:22: error: ‘rb_cFixnum’ undeclared (first use in this function)
rb_define_method(rb_cFixnum, "to_json", rb_yajl_json_ext_fixnum_to_json, -1);
^~~~~~~~~~
yajl_ext.c:881:22: note: each undeclared identifier is reported only once for each
function it appears in
yajl_ext.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
make: *** [Makefile:242: yajl_ext.o] Error 1
make failed, exit code 2
Gem files will remain installed in
/home/idiot/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/yajl-ruby1.2.1 for inspection.
Results logged to
/home/idiot/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/yajl-ruby-1.2.1/gem_make.out
An error occurred while installing yajl-ruby (1.2.1), and Bundler cannot
continue.
Make sure that `gem install yajl-ruby -v '1.2.1'` succeeds before bundling.
I've tried to googling but still have not found a solution to this problem, anyone answer my question, I am very grateful.
The native extension has not been updated for Ruby 2.4 yet. The breaking change is that Fixnum and Bignum (rb_cFixnum and rb_cBignum in the C API) have been unified in Integer (rb_cInteger).
Check the yajl-ruby repository for an issue/pull request fixing Ruby 2.4 compatibility or use Ruby 2.3.3 for the time being.
I've been trying to run bundle install. What follows is a series of commands I entered and the relevant snippets of the error messages.
bundle update
An error occurred while installing linecache (0.46), and Bundler cannot continue.
Make sure that gem install linecache -v '0.46' succeeds before bundling.
gem install linecache -v '0.46'
Can't handle 1.9.x yet
gem install linecache19
checking for vm_core.h... no
and finally:
gem install linecache19 -- --with-ruby-include=/opt/t/rvm/src/ruby-1.9.3-p194
ERROR: Error installing linecache19:
ERROR: Failed to build gem native extension.
/opt/t/rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb --with-ruby-include=/opt/t/rvm/src/ruby-1.9.3-p194
checking for vm_core.h... yes
checking for version.h... yes
creating Makefile
make
compiling trace_nums.c
In file included from trace_nums.c:21:
/opt/t/rvm/src/ruby-1.9.3-p194/vm_core.h:311:5: error: unknown type name 'rb_event_hook_t'; did you mean 'rb_event_flag_t'?
rb_event_hook_t *event_hooks;
^~~~~~~~~~~~~~~
rb_event_flag_t
/opt/t/rvm/rubies/ruby-2.0.0-p0/include/ruby-2.0.0/ruby/ruby.h:1602:23: note: 'rb_event_flag_t' declared here
typedef unsigned long rb_event_flag_t;
^
In file included from trace_nums.c:21:
/opt/t/rvm/src/ruby-1.9.3-p194/vm_core.h:477:5: error: unknown type name 'rb_event_hook_t'; did you mean 'rb_event_flag_t'?
rb_event_hook_t *event_hooks;
^~~~~~~~~~~~~~~
rb_event_flag_t
/opt/t/rvm/rubies/ruby-2.0.0-p0/include/ruby-2.0.0/ruby/ruby.h:1602:23: note: 'rb_event_flag_t' declared here
typedef unsigned long rb_event_flag_t;
^
trace_nums.c:61:25: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = strlen(token) - 1;
~ ~~~~~~~~~~~~~~^~~
1 warning and 2 errors generated.
make: *** [trace_nums.o] Error 1
Gem files will remain installed in /opt/t/rvm/gems/ruby-2.0.0-p0/gems/linecache19-0.5.12 for inspection.
Results logged to /opt/t/rvm/gems/ruby-2.0.0-p0/gems/linecache19-0.5.12/ext/trace_nums/gem_make.out
force the Gemfile to use these version
gem 'linecache19', '0.5.13', :path => "~/.rvm/gems/ruby-1.9.3-p0/gems/linecache19-0.5.13/"
and then bundle install