So I am following this tutorial: https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-macos-for-development/15772 but when I use bundle install it gives me this error:
An error occurred while installing openssl (2.2.0), and Bundler cannot
continue.
Make sure that `gem install openssl -v '2.2.0' --source 'https://rubygems.org/'`
succeeds before bundling.
along with
Installing openssl 2.2.0 with native extensions
Installing cppjieba_rb 0.3.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension
but why do I get this?
Running gem install openssl -v '2.2.0' --source 'https://rubygems.org/' gives me...
Building native...
ERROR: Error installing openssl:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/openssl-2.2.0/ext/openssl
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210225-70291-10x2bpm.rb extconf.rb
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for openssl/ssl.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
--with-openssl-dir
--with-openssl-include
--without-openssl-include=${openssl-dir}/include
--with-openssl-lib
--without-openssl-lib=${openssl-dir}/lib
--with-kerberos-dir
--without-kerberos-dir
--with-kerberos-include
--without-kerberos-include=${kerberos-dir}/include
--with-kerberos-lib
--without-kerberos-lib=${kerberos-dir}/lib
--with-debug
--without-debug
--enable-debug
--disable-debug
--with-nsllib
--without-nsllib
--with-socketlib
--without-socketlib
--with-openssl-config
--without-openssl-config
--with-pkg-config
--without-pkg-config
extconf.rb:99:in `<main>': OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed. (RuntimeError)
To see why this extension failed to compile,
/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/openssl-2.2.0/mkmf.log
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/openssl-2.2.0 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/openssl-2.2.0/gem_make.out
Again, why does this happen? Please help!
openssl gem is basically a set of wrappers around openssl library. And bundler cannot find the library in your system during Building native extensions step. Thus the gem fails to install.
This is weird as the script you linked explicitly installs openssl long before bundling gems
log_info "Upgrading and linking OpenSSL ..."
brew install openssl
brew link openssl --force
Check the script's output for errors (and check if it has reached this step at all). You will probably find the reason for missing openssl library there (or simply try to install openssl manually more using the commands above).
After you install the openssl library check its version using command
openssl version -a
If you have a custom openssl library installation it might help to follow the advice from the error message and install openssl gem manually while specifying the path to openssl library
Related
This error happened to me before with nio4r gem when I upgraded to Catalina and #dmitry barskov answered it. A similar issue is happening now after big sur upgrade with json, oj and therubyracer (tried using the solution from nio4r, but no luck). When I run gem list I see the gems installed but bundle install fails. So I tried bundle update json oj therubyracer. it works for json and oj but for therubyracer, it throws errors.
therubyracer error -->
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/me/.gem/gems/therubyracer-0.12.2/ext/v8
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20210106-9670-edtaxk.rb extconf.rb --with-v8-dir\=/usr/local/opt/v8
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
--with-pthreadlib
--without-pthreadlib
--with-objclib
--without-objclib
--enable-debug
--disable-debug
--with-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/lib
/Users/me/.gem/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version
(Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.
However, your system version of v8 could not be located.
Please make sure your system version of v8 that is compatible
with 3.16.14.19 installed.
json error -->
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20210106-29155-126itgi.rb extconf.rb
creating Makefile
current directory: /Users/me/.gem/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /Users/me/.gem/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
generator.c:861:25: error: use of undeclared identifier 'rb_cFixnum'
} else if (klass == rb_cFixnum) {
^
generator.c:863:25: error: use of undeclared identifier 'rb_cBignum'
} else if (klass == rb_cBignum) {
^
2 errors generated.
make: *** [generator.o] Error 1
make failed, exit code 2
*** LOCAL GEMS ***
bigdecimal (1.2.8)
bundler (1.17.3)
json (1.8.3)
libv8 (3.16.14.17)
oj (2.15.0)
rake (10.4.2)
ref (2.0.0)
therubyracer (0.12.3)
checking for v8.h... no I understand that this maybe an issue, so here's what I've tried to fix it, unsuccessfully ->
brew install v8-315
gem uninstall -a libv8
bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8#3.15)
gem install libv8 -v '3.16.14.17' — —with-system-v8
gem uninstall -a therubyracer
bundle config build.libv8 --with-system-v8
gem install therubyracer -v '0.12.2' -- --with-v8-dir=$(brew --prefix v8#3.15)
When I do bundle update, it gets stuck in resolving dependencies.... I kept it running for 12 hours before I gave up.
When I delete my gemfile.lock, and run bundle install, it gets stuck in resolving dependencies... again.
I'm using ruby v 2.3.1
bundler version 1.17.3
One thing I noticed was the path /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby shows 2.6.0 but I'm using 2.3.1 (confirmed by running rbenv local and ruby -v)
If any other information is needed, please tell me. Any help will be much appreciated.
I ended up deleting the project folder and clone a new one. Removed all gems, reinstalled rbenv like #taylorthurlow pointed out.
Things worked, bundle install was green.
I'm trying to install the OpenSSL gem as follows:
sudo gem install openssl -- --with-openssl-dir=/usr/local/opt/openssl
However, I get the following error
Building native extensions with: '-with-openssl-dir=/usr/local/opt/openssl'
This could take a while...
ERROR: Error installing openssl:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/openssl-2.1.0/ext/openssl
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180501-55786-16tbndt.rb extconf.rb -with-openssl-dir=/usr/local/opt/openssl
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for openssl/ssl.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
--with-openssl-dir
--without-openssl-dir
--with-openssl-include
--without-openssl-include=${openssl-dir}/include
--with-openssl-lib
--without-openssl-lib=${openssl-dir}/lib
--with-kerberos-dir
--without-kerberos-dir
--with-kerberos-include
--without-kerberos-include=${kerberos-dir}/include
--with-kerberos-lib
--without-kerberos-lib=${kerberos-dir}/lib
--with-debug
--without-debug
--enable-debug
--disable-debug
--with-nsllib
--without-nsllib
--with-socketlib
--without-socketlib
--with-openssl-config
--without-openssl-config
--with-pkg-config
--without-pkg-config
extconf.rb:94:in `<main>': OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed. (RuntimeError)
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/openssl-2.1.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/openssl-2.1.0 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/openssl-2.1.0/gem_make.out
It says that it couldn't find OpenSSL. However, I specified it as a parameter, yet it is still not picking this up. Does anyone have any suggestions?
Notably, the error is:
OpenSSL library could not be found. You might want to use --with-openssl-dir= option to
specify the prefix where OpenSSL is installed.
Please, can you send the output of ls -l /usr/local/opt/openssl ?
Have you tried installing the latest version of openssl with brew: brew install openssl ?
i tried for a few weeks to install mysql2 for ruby so i can use it with dashing. But the only thing i get is:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="/usr/include/mysql"'
Building native extensions with: '--with-mysql-dir="/usr/include/mysql"'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.2.4/bin/ruby -r ./siteconf20160203-7890-abpifj.rb extconf.rb --with-mysql-dir="/usr/include/mysql"
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Cannot find include dir(s) /usr/include/mysql/include
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-2.2.4/bin/$(RUBY_BASE_NAME)
--with-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.2.4/gems/mysql2-0.4.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.2.4/extensions/armv7l-linux/2.2.0/mysql2-0.4.2/gem_make.out
it is a Raspberry Pi 2 with Ruby 2.2.4 via RVM installed.
libmysqlclient-dev is installed.
mkmf.log tells me:
have_func: checking for rb_thread_blocking_region()... -------------------- no
"gcc -o conftest -I/usr/local/rvm/rubies/ruby-2.2.4/include/ruby-2.2.0/armv7l-linux-eabihf -I/usr/local/rvm/rubies/ruby-2.2.4/include/ruby-2.2.0/ruby/backward -I/usr/local/rvm/rubies/ruby-2.2.4/include/ruby-2.2.0 -I. -D_FILE_OFFSET_BITS=64$
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘rb_thread_blocking_region’ undeclared (first use in this function)
conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:13:32: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
It looks like there is a bug in the mysql2 gem you're trying to install.
Try install the previous stable version, 0.3.X
gem install mysql2 --platform=ruby -v '~> 0.3.0'
If that doesn't work, try update your Ruby version.
sudo apt-get install ruby2.2
Or, if you can, upgrade
sudo apt-get install ruby2.3
Install the raspbian specific package, before trying to get the gem this worked for me.
apt-get install ruby-mysql2
ruby new projectname -dmysql
I finally got around this error with the following:
apt-get install libmysql++-dev
you should
apt-get install libmariadbclient-dev
I am a Windows 8 user. I installed lib v8 with:
gem install libv8 -v '3.16.14.3' -- --with-system-v8
Now I am facing trouble with installing therubyracer. Following is the error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
checking for main() in -lpthread... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby
--with-pthreadlib
--without-pthreadlib
--enable-debug
--disable-debug
--with-v8-dir
--without-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/
/usr/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in `configure': You have chosen to use the version of V8 found on your system (Libv8::Location::System::NotFoundError)
and *not* the one that is bundle with the libv8 rubygem. However,
it could not be located. please make sure you have a version of
v8 that is compatible with 3.16.14.3 installed. You may
need to special --with-v8-dir options if it is in a non-standard
location
thanks,
The Mgmt
from /usr/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/lib/libv8.rb:7:in `configure_makefile'
from extconf.rb:32:in `<main>'
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/therubyracer-0.12.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/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.
I tried following other stackoverflow links but nothing seem to help
Because therubyracer-0.12.1 relys on libv8-3.16.14.7, you install libv8-3.16.14.3 rather than libv8-3.16.14.7 firstly, so there is a conflict.
It works for me:
$ gem uninstall libv8
$ gem install therubyracer -v '0.12.1'
$ gem install libv8 -v '3.16.14.3' -- --with-system-v8
I have a problem installing my bundle.
These were my last steps:
git clone http:...
git checkout -b daniel
bundle install
The error I got was:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.
/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/ruby extconf.rb checking for main() in -lpthread... yes checking for main() in
-lobjc... yes
*** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check
the mkmf.log file for more details. You may need configuration
options.
Provided configuration options: --with-opt-dir --without-opt-dir
--with-opt-include --without-opt-include=${opt-dir}/include
--with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog
--without-make-prog --srcdir=. --curdir
--ruby=/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
--with-pthreadlib --without-pthreadlib --with-objclib
--without-objclib --enable-debug --disable-debug
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0/ext/v8/build.rb:50:in
`build_with_rubygem_libv8': undefined local variable or method
`libv8_include_flags' for main:Object (NameError) from
extconf.rb:20:in `<main>'
Gem files will remain installed in
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0 for
inspection. Results logged to
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0/ext/v8/gem_make.out
An error occurred while installing therubyracer (0.11.0), and Bundler
cannot continue. Make sure that `gem install therubyracer -v '0.11.0'`
succeeds before bundling.
When I tried to run gem install therubyracer -v '0.11.0' I got:
Building native extensions. This could take a while... ERROR: Error
installing therubyracer: ERROR: Failed to build gem native extension.
/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/ruby extconf.rb checking for main() in -lpthread... yes checking for main() in
-lobjc... yes
*** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check
the mkmf.log file for more details. You may need configuration
options.
Provided configuration options: --with-opt-dir --without-opt-dir
--with-opt-include --without-opt-include=${opt-dir}/include
--with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog
--without-make-prog --srcdir=. --curdir
--ruby=/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
--with-pthreadlib --without-pthreadlib --with-objclib
--without-objclib --enable-debug --disable-debug
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0/ext/v8/build.rb:50:in
`build_with_rubygem_libv8': undefined local variable or method
`libv8_include_flags' for main:Object (NameError) from
extconf.rb:20:in `<main>'
Gem files will remain installed in
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0 for
inspection. Results logged to
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0/ext/v8/gem_make.out
I am working on Mac OS 10.7.5. Xcode and its command line tools and Rails are up to date.
SQLite 3 is also installed.
Can anyone help me?
EDIT:
I also tried to delete the repository and to clone it again, with the same errors.
EDIT:
Is the installation path of Rails and Sqlite3 correct?
daniel:~
daniel$ sudo gem update --system Latest version currently
installed. Aborting.
daniel:~
daniel$ sudo gem install rails
Fetching:
rails-3.2.11.gem (100%) Successfully installed
rails-3.2.11 1 gem installed
Installing ri documentation for rails-3.2.11...
Installing RDoc documentation for rails-3.2.11...
daniel:~
daniel$ sudo gem install sqlite3
Fetching: sqlite3-1.3.7.gem (100%)
Building native extensions. This could take a while...
Successfully installed sqlite3-1.3.7 1 gem installed
Installing ri documentation for sqlite3-1.3.7...
Installing RDoc documentation for sqlite3-1.3.7...
daniel:~
daniel$ which ruby irb gem rake
/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/irb
/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/gem
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/bin/rake
At least one problem is that you are running RVM, but used sudo to install gems on your system.
Read "RVM and RubyGems", especially the part that says:
"DO NOT use sudo..."
RVM creates a sandbox for you, the user, in your own user-space on a machine, that allows you to manage it without needing to be the system administrator. In other words, that means you don't have to use sudo for any RVM or gems management.
If you do use sudo, you temporarily cease being you, the user, and become the administrator, with administrator privileges and the administrator's environment, which does NOT include the RVM sandbox in your /Users/daniel/.rvm/rubies/ruby-1.9.3-p286 path. Knowledge of the sandbox is carried by the PATH in your environment, which the root on your machine doesn't use. Gems installed inside that sudo sub-shell get installed into the location that the administrator account knows about, which is inside the System Ruby installation, which is why your RVM sandboxed Ruby doesn't see them: There is no crossover between the System's Ruby and your RVM-controlled RUby. That's the whole idea of a sandbox: separation of the elements and resources to avoid contamination.
You could have figured this all out by looking at the output of:
which ruby irb gem rake
The path for all of them is pointing to your sandbox:
/Users/daniel/.rvm/rubies
On a Mac OS system, that command should have reported:
/usr/bin/ruby
/usr/bin/irb
/usr/bin/gem
/usr/bin/rake
Reinstall Rails and the SQLite gem using:
gem install rails sqlite3
and see how your bundle behaves.
And, by the way, do NOT use sudo to deliberately try to manage/delete the System installed Ruby. That was installed by Apple for their own purposes, to enable software they installed. It's OK to take advantage of its existence, but it's there for their use. Use a RVM-managed Ruby for your own purposes.