I've been trying to install an api that says to use
bundle install
rails s
But when I do bundle, I get this error:
An error occurred while installing pg (0.18.1), and Bundler cannot
continue. Make sure that `gem install pg -v '0.18.1' --source 'https://rubygems.org/'`succeeds before bundling.
But when I run that gem install command, I get this:
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/pg-0.18.1/ext /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20191018-63874-el2g8s.rb extconf.rb checking for pg_config... yes Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.
And the mkmf.log file says:
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.Internal.sdk/usr/local/libressl/lib'
I'm not really sure where to start, as I've followed a good amount of other guides online and they either don't work or lead me to new errors.
Install brew. This will take care of any dependencies like Xcode's command line tools. Run this command in your terminal to install brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
When brew has successfully installed, install PostgreSQL with:
brew install postgresql
Then retry:
gem install pg -v '0.18.1' --source 'https://rubygems.org/'
Please note that the gem version specified is almost five years out of date.
Related
This question already has answers here:
Error when trying to install app with mysql2 gem
(19 answers)
Closed 4 years ago.
I am trying to install mysql2 (version 0.5.2) on My MacBook running OSX 10.14.1 and using Rails 5.2.2. I have already installed it using gem install mysql2 but it wasn't successful, yet it's in my gem file as:
gem 'mysql2'
When I try installing gem mysql2, I am getting the following error:
Fetching mysql2 0.5.2
Installing mysql2 0.5.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/lawrence/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2- 0.5.2/ext/mysql2
/Users/lawrence/.rbenv/versions/2.5.3/bin/ruby -r ./siteconf20181213-11829- 1fv4si0.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for SSL_MODE_DISABLED in mysql.h... yes
checking for SSL_MODE_PREFERRED in mysql.h... yes
checking for SSL_MODE_REQUIRED in mysql.h... yes
checking for SSL_MODE_VERIFY_CA in mysql.h... yes
checking for SSL_MODE_VERIFY_IDENTITY in mysql.h... yes
checking for MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes
checking for my_bool in mysql.h... no
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql/8.0.12/lib
-----
creating Makefile
current directory: /Users/lawrence/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2- 0.5.2/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/lawrence/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.5.2/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/lawrence/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.5.2 for inspection.
Results logged to /Users/lawrence/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/extensions/x86_64- darwin-18/2.5.0-static/mysql2-0.5.2/gem_make.out
An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile: mysql2
How can I fix this issue?
I have found the Answer
Mojave changed the location of header files necessary for compiling C extensions. You might need to run the following command to install pg, mysql2, nokogiri, or other gems that require C extensions:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Follow the link below and find out more.
https://gorails.com/setup/osx/10.14-mojave
ld: library not found for -lssl is the likely culprit.
Try brew install openssl. Also, check out this post for more information.
EDIT: For future users this worked for me facing a similar issue. Make sure you change the -v to whatever version you need. I am on rails 4.2.x so used 0.4.10, Rails 5.x would use 0.5.x.
gem install mysql2 -v '0.4.10' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
I uninstall version 0.18.1 and now I cannot install any of the versions.
I would like to install 0.18.2
I am running this command:
gem install pg -v '0.18.2'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/liviu-mac/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150901-1693-1wdi2b8.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.
Don't know how to fix the installation?
I used a wrong path, the correct command in my case is:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
I used 9.3 instead of 9.4
Can seem to get around this.
$gem install ffi
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
/remote/part/usern/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for rb_thread_blocking_region()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile
make
libffi.gnu.mk:16: Extraneous text after `else' directive
libffi.gnu.mk:18: *** only one `else' per conditional. Stop.
Gem files will remain installed in /remote/part/usern/.rvm/gems/ruby-1.9.3-p448#myrailsapp/gems/ffi-1.9.0 for inspection.
Results logged to /remote/part/usern/.rvm/gems/ruby-1.9.3-p448#myrailsapp/gems/ffi-1.9.0/ext/ffi_c/gem_make.out
Any ideas?
try this before
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
apt-get install ruby{version}-dev
bundle install ffi
it worked for me
I had to set the gcc to 4.2 and it worked. I also changed the ffi version to 1.0.9 in Gemfile.lock.
export PATH=/opt/gcc-4.2.0/bin/:$PATH
Hi that's related with the GCC compiler i updated mine and also did the trick that Harpreet mentioned (ffi version downgrade) BUT it's not necessary ffi-1.9.3 worked just fine as well :D
in the Gemfile.lock
ffi (1.9.3)
ffi (1.9.3-x86-mingw32)
https://github.com/kennethreitz/osx-gcc-installer
click here github repo with the .pkg installer for all OS (not only MacOSX)
I am getting this error when I try to install RMagick on my machine so I can play with Scruffy graph creator:
sudo gem install rmagick
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/richardjburton/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.
Any help would be awesome! Thanks.
Looks like you installed ImageMagick using a binary distro or something else which didn't include the headers. From your /Users directory you're probably using OSX. Assuming so, install ImageMagick using either Macports or Homebrew.
I'm currently trying to install a ruby gem which fails because extconf says it needs libxml, so when I follow these instructions to install libxml (which includes these instructions for the ruby dev kit installation) I get the following output:
$ gem install libxml-ruby --platform x86-mswin32-60
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing libxml-ruby:
ERROR: Failed to build gem native extension.
c:/Ruby/bin/ruby.exe extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... no
checking for atan() in -lm... yes
checking for inflate() in -lz... no
checking for inflate() in -lzlib... no
checking for inflate() in -lzlib1... yes
checking for iconv_open() in -liconv... no
checking for libiconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
checking for xmlParseDoc() in -lxml2... 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
--8<--
--with-xml2lib
--without-xml2lib
extconf failure: need libxml2.
Install the library or try one of the following options to extconf.rb:
--with-xml2-config=/path/to/xml2-config
--with-xml2-dir=/path/to/libxml2
--with-xml2-lib=/path/to/libxml2/lib
--with-xml2-include=/path/to/libxml2/include
Gem files will remain installed in c:/Ruby/lib/ruby/gems/1.9.1/gems/libxml-ruby-2.2.2 for inspection.
Results logged to c:/Ruby/lib/ruby/gems/1.9.1/gems/libxml-ruby-2.2.2/ext/libxml/gem_make.out
I'm on a Windows 7 x64 install using my minGW32-shell/git to install. The install fails with the same message from the windows ruby-enhanced command promt.
fwiw:
$ ruby -v
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
$ git --version
git version 1.7.6.msysgit.0
$ gem -v
1.8.10
You should try the nokogiri gem instead of using libxml-ruby. It includes the precompiled libxml2 dlls as part of the installation, so you don't have to worry about building it yourself.
Nokogiri's API is different from libxml-ruby's, but I'm sure you'll find the same functionality.
If libxml-ruby is a dependency for another gem or app, you probably can't use nokogiri. What are you trying to do?
I had this as a comment, but was asked to post it as an answer for visibility:
The answer to this question solved my problem: libxml-ruby failed to load at x86_64
Try to run
yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
Than it should work
try first with;
yum install -y libxml2 libxml2-devel
If libxslt needed, then
yum install -y libxslt libxslt-devel