I'm trying to install Ruby (3.2.0) (and Rails [7.0.4]) on an Intel Mac (OS 12.6). I'm running into issues with sqlite3 — no surprise. My current error message is this:
package configuration for /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ports/x86_64-apple-darwin21.6.0/sqlite3/3.40.0/lib/pkgconfig/sqlite3.pc is not found
When I enter gem install sqlite3 I get the following ugly error message:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ext/sqlite3
/usr/local/opt/ruby/bin/ruby -I /usr/local/lib/ruby/site_ruby/3.2.0 extconf.rb
Building sqlite3-ruby using packaged sqlite3.
Extracting sqlite-autoconf-3400000.tar.gz into tmp/x86_64-apple-darwin21.6.0/ports/sqlite3/3.40.0... OK
Running 'configure' for sqlite3 3.40.0... OK
Running 'compile' for sqlite3 3.40.0... OK
Running 'install' for sqlite3 3.40.0... OK
Activating sqlite3 3.40.0 (from /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ports/x86_64-apple-darwin21.6.0/sqlite3/3.40.0)...
Could not configure the build properly (pkg_config). Please install either the `pkg-config` utility or the `pkg-config` rubygem.
*** 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:
[insert long list of options...]
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-darwin-21/3.2.0/sqlite3-1.5.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4 for inspection.
Results logged to /usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-darwin-21/3.2.0/sqlite3-1.5.4/gem_make.out
I've been through many iterations of solutions found across the interwebs (changing permissions, installing pkg-config per the error message, changing $PATH in .zshrc, installing sqlite binary packages, modifying the Gemfile, total uninstalls of both, and restarts) to no avail.
The Homebrew-installed sqlite3 is working properly. which sqlite3 produces
/usr/local/opt/sqlite3/bin/sqlite3
Happy to provide any more relevant information that's helpful. Any guidance appreciated!
If you do not have pkg-config installed, you should install to proceed
You can check it using:
$ which pkg-config
If not found, install it:
$ curl https://pkg-config.freedesktop.org/releases/pkg-config-0.28.tar.gz -o pkgconfig.tgz
$ tar -zxf pkgconfig.tgz && cd pkg-config-0.28
$ ./configure && make install
I'm just following this page
I am on El Capitan 10.11.6 and using bash.
ruby 2.3.0
rails 5.0.0
I have been learning ruby/rails and would like to push an app up to heroku. I have followed the steps outlined by the heroku documentation and Postgres.app documentation.
I downloaded Postgres.app and moved it to the Applications directory.
I placed this in my ~/.bash_profile
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin
Yet when I type in $ which psql I get no info at all. Also, $ psql -h loclhost does nothing. I can however, "start" Postgres.app by double clicking on the icon, and I get the elephant in the menu bar.
Furthermore, I can not install gem 'pg'. I get the error:
Installing pg 0.18.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/jesselawson/.rvm/gems/ruby-2.3.0/gems/pg- 0.18.4/ext
/Users/jesselawson/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160821-1410-1o4aen1.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. Check the mkmf.log file for more details. You may
need configuration options.
and
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that gem install pg -v '0.18.4' succeeds before bundling.
As stated in your error message, you should try to install the gem first, without the use of bundler.
Try the following command in your console:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config
In case you still have troube, try the following resources:
Cannot install pg gem in Mavericks with Postgres.app
An error occurred while installing pg (0.17.1), and Bundler cannot continue
Ok so shortly after I posted the question, I found the answer. Because I downloaded and am using the Postgres.app, I have to have to app running by double clicking the icon. Then in the terminal I can access the cli. Interacting with the pg database can not be done unless the app is running. To have access without the app running I would have to install via homebrew. In which case it would prob. make sense to remove the Postgres.app due to user_name issues, and to minimize spooky action, and my general confusion. (stick with one or the other) Once I started the Postgres.app I could then also run bundle install and gem 'pg' installed just fine. Thank you all for all the help! :)
I'm attempting to install charlock_holmes on my Mac (10.7.5, ruby-1.9.3-p392), and I'm encountering the following error:
$gem install charlock_holmes -v '0.6.9.4'
Building native extensions.
This could take a while...
ERROR: Error installing charlock_holmes:
ERROR: Failed to build gem native extension.
/Users/mthompson/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
checking for main() in -licui18n... no
checking for main() in -licui18n... no
***************************************************************************************
*********** icu required (brew install icu4c or apt-get install libicu-dev) ***********
***************************************************************************************
*** 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.
I've installed icu via macports, so my icu directories are /opt/local/lib/icu and /opt/local/share/icu. I've tried installing with the directories specified:
$ gem install charlock_holmes -v '0.6.9.4' -- --with-icu-dir=/opt/local/lib/icu --with-opt-include=/usr/local/include/ --with-opt-lib=/usr/local/lib/
..but I hit the same error. Any ideas would be welcome.
I was able to install this gem using the version of ICU installed with macports and pointing --with-opt-include and --with-opt-lib to subdirectories of /opt.
The gem successfully installed by running:
gem install charlock_holmes -v '0.6.9.4' -- --with-icu-dir=/opt/local/lib/icu --with-opt-include=/opt/local/include/ --with-opt-lib=/opt/local/lib/
I ran into this issue today. I realize that the original issue was resolved by switching to Homebrew. That wasn't an acceptable solution to me, so I kept digging. The solution was actually quite simple.
After installing icu via Macports, simply install charlock_holmes by running:
gem install charlock_holmes -- --with-icu-dir=/opt/local
Hopefully this helps others that encounter this issue and are not willing to abandon Macports in order to solve it.
I ended up switching from MacPorts to Homebrew and reinstalling my rubies and packages.
I've been trying to install Nokogiri on Mac OS 10.9.3 and whatever I try, the install fails in the end with the following error message:
$ sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Building native extensions with: '--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib'
This could take a while...
Building nokogiri using packaged libraries.
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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.0/usr/bin/ruby
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out
After following a lot of help found around the web including building and installing libxml2 and libxslt using brew and building libiconv from the sources (as described in "Installing Nokogiri"), the error remains the same.
When trying to run the installation for Nokogiri, libxml2 and libxslt seem to be found fine, but not libiconv.
Anyone with a better knowledge of these things know how to get Nokogiri installed?
I had the same issue. Unfortunately the "Installing Nokogiri" doesn't cover Iconv issues. Here's how I resolved the issue.
First install homebrew, it'll make your life easier. If you already have it installed, be sure to grab the latest formulae by updating like so:
brew update
Note: In OSX 10.9+ you may need to install xCode command tools to allow you to install libiconv.
xcode-select --install
then install a newer version of libiconv
brew install libiconv
then install your gem
gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14
Try using the system libraries. OSX comes with libiconv in newer versions, but the defaults install script seems to have a problem
gem install nokogiri -- --use-system-libraries
Edit: If using bundler, as mentioned by Geoff you can do:
bundle config build.nokogiri --use-system-libraries
#Cory's solution contains the correct answer, but the solution on Mavericks is actually much simpler than the top solution so I'm reposting with only the necessary steps.
On Mavericks (OSX 10.9+):
Install Xcode Command Line Tools:
xcode-select --install
then install your gem:
gem install nokogiri
I was finally able to solve this problem. None of the above solutions completely fixed it for me.
I was getting this error when trying to gem install nokogiri on OSX Lion 10.7.2. First of all, this error masks the real problem by saying libiconv is missing, because you will get the same error even if nokogiri can't find libxslt or libxml2, which in my case, it couldn't.
So I followed the instructions on http://nokogiri.org/tutorials/installing_nokogiri.html under the Homebrew section (slightly modified to account for a more current version of libxml2):
brew install libxml2
brew link libxml2
# install libxslt from source
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar -zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.8
make
sudo make install
At this point I followed the directions on the nokogiri site and tried
gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
However, this still failed because when building libxslt from source, it installs the /include folder in a funky place. So you need to specify the lib and include folders separately like so:
gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt
This still didn't work (same libiconv error), so I tried to specify all three required libraries (libxslt, libxml2 and libiconv):
gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt --with-iconv-dir=/usr/local/Cellar/libiconv/1.14 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8
Now I got a different error! It was still an error but at least it was different. The make process failed with:
in /opt/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64
Uhh, what? After a lot of googling, I came across this miracle post: http://www.refresherate.com/2010/01/08/fixing-ld-warning-in-usrlocalliblibz-dylib-file-is-not-of-required-architecture/
Apparently OSX Lion ships with some bad versions of the libz library (libz.dylib, libz.1.dylib, libz.1.2.4.dylib) and and they need to be replaced with the latest versions from the Xcode SDK. The article explains it better than I can so read the above link for specific instructions.
Once these were replaced, I ran
gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt --with-iconv-dir=/usr/local/Cellar/libiconv/1.14 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8
again and all was well. I hope this helps someone else.
Just adding my voice to the crowd, but mkmf.log said something about not being able to find symbols for x86_64 architecture. I stumbled across this solution:
sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri -- --use-system-libraries
May not solve anything for the original asker, but this may help someone.
Side Note: nokogiri has been my highest barrier to using ruby applications. Every time someone depends on a different version I have to figure out how to build it. And my problem is different every time.
gem install nokogiri -v '1.6.6.2' -- --use-system-libraries --with-xml2-include=$(brew --prefix libxml2)/include/libxml2
this worked for me on macos.
It works also with version 1.6.6.4
I'm using..
OS X 10.9.4
Homebrew 0.9.4
Here is my summery from this thread to successfully install nokogiri, fixing missing libiconv.
Install Homebrew http://brew.sh/
Or update to latest using command below
brew update
Install libxml2 libxslt
brew install libxml2 libxslt
Link both libxml2 libxslt
brew link libxml2 libxslt
If you get warning to use --force, just use command below
brew link --force libxml2 libxslt
Install xCode command tools to enable you to install libiconv
xcode-select --install
Install libiconv
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install
Final step, install nokogiri!
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.8.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.8.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
I solved this on Yosemite running Ruby 2.1.4 by
ensure you have xCode 6.1 installed, then
xcode-select --install, then
In the AppStore click on updates and install the most recent version of the command-line tools (which apparently xcode-select --install does't do - sigh)
then bundle install worked as normal.
I also did a brew install libiconv too but I am not convinced that step was needed.
I tried many things but nothing worked for me. Then I finally found the iconv documentation and it saved my day!
Looking in the mkmf file, it apear that nokogiri (or gem, I don't know) try to find dependencies in /op/local/. For me it's not the right path to search them for.
Forcing nokogiri to find the libs at the right place (I use homebrew) did the trick for me :
$ gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/
Maybe there is something to fix in nokogiri...
HTH,
libiconv was removed from Homebrew 0.9 Now it's recommended to compile libiconv from source, then reference the install when you install the nokogiri gem. See the Nokogiri install instructions under the Homebrew 0.9 section on the Nokogiri install page
Look in the mkmf.log file in the gem's build directory (e.g. /Library/Ruby/Gems/1.8/gems/nokogiri-1.4.4/ext/nokogiri/mkmf.log). That has a lot more info. In my case when I hit this it was that Nokogiri specifically adds /opt/local/lib to the library search path and GNU Backgammon had installed an incompatible libiconv there.
Assuming you installed libxml2 and libxslt with MacPorts, then you might still be getting this error due to a mismatch of the order of include paths and link paths used by the call to have_func('iconv_open', 'iconv.h')
Simple (patch) solution: delete libiconv.* in /usr/local/lib
$ gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/
same as above, this is the solution for homebrew and using gem install (apply changes depends on your version)
however, if you use Gemfile and bundle install, you should apply the bundle config before you install, here the code
$ bundle config build.nokogiri --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/ --with-iconv-dir=/usr/local/Cellar/libiconv/1.14
again, apply changes depends on your version
hope this will help you.
credit: https://gist.github.com/1344331
I had similar trouble on Mountain Lion. Turns out I had installed libiconv via rvm package previously and this is no longer necessary for ruby 1.9.3/Mountain Lion/nokogiri.
Following the advice of https://rvm.io/packages/, I deleted my $rvm_path/usr directory and rebuilt ruby 1.9.3. Thereafter installing nokogiri was a simple gem install. No messing with brew/macports/manual source installs!
You could also do this on Mavericks:
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
Just make sure you have xcode installed
I was fighting with Nokogiri for a while today on OS X 10.10 Yosemite
My environment was messed up for some reason.
which bundle and which gem were giving me /usr/bin/bundle and /usr/bin/gem instead of ~/.rbenv/shims/gem
What helped correct it for me was sudo rm -i /usr/bin/gem /usr/bin/bundle
After that I:
1. switched back to my project directory
2. uninstalled the dependent
3. (re)-installed the dependent libs: did a brew install libxml2 libiconv libxslt
4. installed my ruby version fresh (with rbenv)
5. did gem install bundler
6. and bundle install ran without any problems.
Nokogiri was fine after that.
For reference:
╰─% cat .bundle/config
---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
BUNDLE_JOBS: 4
╰─% which ruby bundle gem
~/.rbenv/shims/ruby
~/.rbenv/shims/bundle
~/.rbenv/shims/gem
This one worked for me
sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri:1.6.6.2 -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/2.9.3/ --with-iconv-dir=/usr/local/Cellar/libiconv/1.14
You need to upgrade your homebrew to 0.9
then follow these steps
brew install libxml2 libxslt
brew link libxml2 libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
You should double check the folder library version.
HOMEBREW USERS
Correct solution to fix this problem if you are using homebrew:
xcode-select --install
Choose "Get Xcode" from the dialog box.
brew unlink libiconv
gem install nokogiri
The xcode-select step fixes your Xcode installation and Xcode Command Line Utils installation. I found that I didn't have /usr/include/iconv.h due to some kind of problem with O/S upgrades or restores from backups. If you don't have that header file and /usr/lib/libconv.dylib after running xcode-select then you most likely need to drag Xcode from the Application folder to the trash and reinstall and then manually download the Command Line Tools for Xcode from https://developer.apple.com/downloads/index.action and install that.
Then you need to unlink the libiconv from homebrew. You don't need this. And clang will actually pick up /usr/local/include/iconv.h over /usr/include/iconv.h and will #define iconv_open to libiconv_open but then link against /usr/lib/libiconv.dylib which does not have libiconv_open which is what causes the mkmf failures to find libiconv. What you need to do is remove the linking in of iconv.h so that nokogiri will not find it.
Then just build nokogiri normally.
For new users, all you should need to do is install xcode with xcode-select and install nokogiri, but if you've found this question then presumably you've got a botched installation and not a fresh install of Mavericks.
Some of the other answers here are definitely incorrect. Most of them attempt to use libiconv out of homebrew which is entirely unnecessary. The answers that brew link libiconv are actually causing the problem where clang becomes confused and tries to read a homebrew header file and link against the system libraries. The answers which suggest --use-system-libraries are poor because nokogiri needs to be linked against its bundled libxml2 and libxslt libraries because other versions of those libraries are incompatible with it. The answers which want you to compile from sources are just hopelessly overly complicated.
TL;DR:
Upgrade and/or repair your Xcode installation
Unlink your homebrew libiconv since trying to use that only causes problems
Build nokogiri normally
RVM USERS
Old RVM installations may have a libiconv hiding in your rvm directories somewhere which are conflicting with your system libraries. See https://stackoverflow.com/a/11809261/506908 for more information.
MacPorts USERS
If you have /opt/local/lib/libiconv.dylib then nokogiri adds that path to the list of directories that it searches for and it will find the MacPorts installation similar to how it picks up the homebrew libiconv and conflicts with the system libraries. You can try:
sudo port uninstall libiconv
If that fails due to dependencies then you can try linking against the MacPorts version directly (untested):
gem install nokogiri -- --with-iconv-dir=/opt/local
I ran into this, this morning... after an upgrade to Mavericks. We did many things. However if anyone is having this issue here are some things to try.
I ran 'xcode-select --install' then got the command line tools installed (surprised this didn't update on the OS ugrade).
I ran 'rvm implode' (I will build it back up later).
We pieced together two error output files:
~/.vagrant.d/gems/gems/nokogiri-1.6.3.1/ext/nokogiri/gem_make.out
~/.vagrant.d/gems/gems/nokogiri-1.6.3.1/ext/nokogiri/tmp/x86_64-apple-darwin12.5.0/ports/libxml2/2.8.0/configure.log
Which seemed to indicate that the c compiler was using a surprising setting.
I ran 'env'
Output contained:
...
CXX=/usr/local/opt/apple-gcc42/bin/g++-4.2
...
CC=/usr/local/opt/apple-gcc42/bin/gcc-4.2
...
These files didn't exist on the file system...
After all of these changes moving to a new terminal windows (so everything was fresh). Installation of vagrant-berkshelf (which in turn installs nokogiri) worked fine.
NOTE: when running 'env' in the fresh window there was no longer a setting for CC or CXX...
Unsure on the key part of this, or if order matters, but tried to recreate the parts that seemed to play a role in getting this to work.
According to the documentation, as of OSX 10.9 and Homebrew 9.5+, you are probably missing the development tools.
Nokogiri installation
Troubleshooting
If you have problems mentioning libiconv missing that looks something like this:
Installing nokogiri (1.6.2.1) Building nokogiri using packaged libraries.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Then you are probably missing the right developer tools. This is a really easy fix:
brew unlink gcc-4.2 # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri
This is verified working on OSX 10.9 w/ xcode’s clang compiler.
I got this issue when I upgraded my Mac OS to Yosemite. I was able to solve this issue by doing:
xcode-select --install
brew uninstall libiconv
brew install libiconv
gem install nokogiri
I had a similar issue and the accepted answer used to work for me. Now, however I have been seeing a new error message where a gmkdir command is missing as in this question:
gem install nokogiri -v '1.5.11' failed due to make: /usr/local/bin/gmkdir: No such file or directory
What worked for me was first a little cleanup:
brew uninstall libiconv
brew uninstall libxml2
brew uninstall libxslt
And then brew unlink libiconv and whatever else you need to unlink (check with brew doctor). Then, the magic two lines (copied from the linked answer):
brew install coreutils
gem install nokogiri
Simple steps to follow before you start uninstalling and installing anything.
Check if you have CLT (command line tools installed):
brew config
see the CLT version here if its installed no need for reinstallation.
This means the issue is with permission you have reinstall only bundler gem make its not sudo.
Uninstall bundler with
gem uninstall bundler
reinstall gem bundler
gem install bundler
Most important point here is the permission under which bundler gem is installed it should never be sudoed.
First of all make sure you follow the installation guide on nokogiri: http://nokogiri.org/tutorials/installing_nokogiri.html
After having followed the guide I still had this issue. This is how I solved it:
First of all I installed iconv using homebrew:
brew install iconv
Then I uninstalled ruby, luckily this is very easy with rvm:
rvm uninstall 1.9.2
Then I had to reinstall ruby with the following options:
CC=gcc-4.2 rvm install 1.9.2-p290 --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1
Then I create a gemset with the new ruby version:
rvm use 1.9.2#coolproject
Then I can finally install nokogiri like this:
gem install nokogiri -v=1.4.4 -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
In my case, (as with scotchi) the build failed because of an incompatible iconv library in /opt/local/lib.
By default, theNokogiri build process looks at /opt/local first.
To force it to use a different install directory, /usr/local for example, do:
gem install nokogiri -- --with-xml2-lib=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2 --with-xslt-lib=/usr/local/lib --with-xslt-include=/usr/local/include
This blog post proposes to install libiconv manually.
Subsequently, nokogiri can be installed with a number of switches telling it where to find libiconv (see the blog post).
As a side note: After installing nokogiri, I managed to install gollum (installation of which also failed because it could not find iconv). Now I am still facing problems though, because when I start up gollum, Python crashes.
$ gem install iconv # works but it is missing an iconv.so file in ruby 2.0.0-p247
$ ls -1 2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/*/*/*.so
2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so*
2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/lib/iconv/iconv.so*
$ ls -1 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/*/*/*.so
2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so*
NOTE THE MISSING /lib/iconv/iconv.so file in 2.0.0-p247 that is present in 2.0.0-p0 gems installation.
$ rbenv version
2.0.0-p247 (set by /home/XXX/tmp/.ruby-version)
$ rbenv which gem
/home/XXX/.rbenv/versions/2.0.0-p247/bin/gem
$ gem --version
1.8.25
$ rbenv which pry
/home/XXX/.rbenv/versions/2.0.0-p247/bin/pry
$ pry
[1] pry(main)> require 'iconv'
LoadError: cannot load such file -- iconv/iconv.so
from /home/XXX/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require'
Copy the file over
$ pushd ~/.rbenv/versions/
$ cp 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/lib/iconv/
NOW IT WORKS!
$ pry
[1] pry(main)> require 'iconv'
=> true
I had to install gcc first before running ./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
sudo env ARCHFLAGS="-arch x86_64" gem install do_sqlite3
Building native extensions. This could take a while...
ERROR: Error installing do_sqlite3:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_open() in -lsqlite3... 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.
I have sqlite3-ruby installed as well as the header files, but for some reason it fails when checking for sqlite3_open()
I am having the same issue:
sudo env ARCHFLAGS="-arch x86_64" gem install do_sqlite3
Building native extensions. This could take a while...
ERROR: Error installing do_sqlite3:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/do_sqlite3-0.10.1.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/do_sqlite3-0.10.1.1/ext/do_sqlite3/gem_make.out
I am running Snow Leopard. I'm not sure about previous installations of sqlite3 but I did try this:
port search sqlite
And it returned the following (among others):
...
sqlite3 #3.6.17 (databases)
an embedded SQL database engine
To be honest I'm not sure what all this means. What would anyone suggest for getting do_sqlite3 installed for use in Rails 3 with DataMapper? (Also, running it without the 'env ARCHFLAGS="-arch x86_64"' gives the same errors.)
Ok, first question is why are you passing the ARCHFLAGS? That should not be necessary, if it also doesn't work without passing them, what is the output you get then?
Next question is what version of sqlite3 is it picking up? Do you have sqlite3 installed through Macports for example? Did you upgrade to Snow Leopard recently and still have an sqlite3 install from before upgrading?