I am trying to do bundle in the large project on Mavericks and some gems are broken or something wrong with my environment in spite of this is fresh install of rbenv.
$ gem install debugger -v '1.5.0'
Building native extensions. This could take a while...
ERROR: Error installing debugger:
ERROR: Failed to build gem native extension.
/Users/samat/.rbenv/versions/1.9.3-p448/bin/ruby extconf.rb
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
Makefile creation failed
**************************************************************************
No source for ruby-1.9.3-p448 provided with debugger-ruby_core_source gem.
**************************************************************************
*** 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.
...
Have no idea of what configuration options do I need
In mkmf I see things like
"gcc -I/Users/samat/.rbenv/versions/1.9.3-p448/include/ruby-1.9.1/x86_64-darwin13.0.0 -I/Users/samat/.rbenv/versions/1.9.3-p448/include/ruby-1.9.1/ruby/backward -I/Users/samat/.rbenv/versions/1.9.3-p448/include/ruby-1.9.1 -I. -I/Users/samat/.rbenv/versions/1.9.3-p448/include/ruby-1.9.1/ruby-1.9.3-p448 -I'/Users/samat/.rbenv/versions/1.9.3-p448/include' -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I'/Users/samat/.rbenv/versions/1.9.3-p448/include' -O3 -Wno-error=shorten-64-to-32 -pipe -c conftest.c"
conftest.c:3:10: fatal error: 'method.h' file not found
#include <method.h>
^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <method.h>
...
I use rbenv,
$ rbenv version
1.9.3-p448 (set by /Users/samat/Documents/bm-git/.ruby-version)
From the debugger page it says that if the ruby source can't be found, it will try to install debugger-ruby_core_source, which is actually what fails for me. I use rbenv, so I according to the debugger gem instructions, I pointed it to the rbenv source.
gem install debugger -- --with-ruby-include=~/.rbenv/versions/1.9.3-p484/include
You better to use latest version of debugger, bc issue with your Ruby version was solved.
There are a lot of issues with Ruby gems and Mavericks. What I have found is that the best bet is to use the apple-gcc42 compiler from homebrew
brew tap homebrew/versions
brew install apple-gcc42
Then force that compiler family to be used when building gems. I put symlinks in my a bin folder in my home directory
cd $HOME/bin
ln -s /usr/local/bin/c++-4.2 c++
ln -s /usr/local/bin/g++-4.2 g++
ln -s /usr/local/bin/gcc-4.2 cc
ln -s /usr/local/bin/gcc-4.2 gcc
You'll need to have your local bin folder on your path.
export PATH=$HOME/bin:$PATH
Then you should be good to go.
may be this will help you gem install debugger-linecache -v '1.1.2' -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p286/
Sometimes this issue is related with missing package. Most of the time these files (for instance method.h) belongs to package named libXXX-dev.
It's difficult for us to know what the package contains file. I've recently bumped into a utility to deal with this annoying problem (for those who works with apt-get package manager). The tool is apt-file and you can use it as follow:
Installation: sudo apt-get install apt-file
Updating apt-file db: sudo apt-file update
Looking at file: sudo apt-file search 'method.h'
The result might be:
...
libcxxtools-dev: /usr/include/cxxtools/constmethod.h
libcxxtools-dev: /usr/include/cxxtools/method.h
libcxxtools-dev: /usr/include/cxxtools/unit/testmethod.h
libgcj12-dev: /usr/include/c++/4.6/gcj/method.h
libgcj13-dev: /usr/include/c++/4.7/gcj/method.h
...
In the particular case of debuggergem the missing package is `libcxxtools-dev``
I'm on Debian 3.2.54-2 x86_64 GNU/Linux
For me it was an issue of permission.
I was able to solve this issue with
sudo gem install debugger
If this doesn't help you may have to get involved in a dependency rabbit hole.
Related
I am using cloud9.
I want to use gem 'rmagick', but using bundle, following error message occurs...
please help...
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/usr/local/rvm/gems/ruby-2.4.0/gems/rmagick-2.16.0/ext/RMagick
/usr/local/rvm/rubies/ruby-2.4.0/bin/ruby -r
./siteconf20180204-XXXXXX-oyXXpq.rb extconf.rb checking for gcc... yes
checking for Magick-config... no checking for pkg-config... yes
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc' to the
PKG_CONFIG_PATH environment variable No package 'MagickCore' found
checking for outdated ImageMagick version (<= 6.4.9)... * 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 just spun up a Cloud9 VM and tried it.
My Cloud9 VM I tried used yum as a package manager. Meaning I installed ImageMagick via sudo yum install ImageMagick-devel... when I did that my gem install rmagick worked.
Didn't try it with Bundler, but if gem install works then it should work in Bundler also.
Using the command prompt install/update imagemagick via
sudo apt-get update
Then
sudo apt-get install imagemagick
See more
Hope it helps
I cannot get a number of ruby gems to install on my machine, they all fail with something related to compiling the native part, and I can't get any of the solutions to work.
I'm looking forward to the famed ruby productivity, but after a whole day of battling with these install issues I really need some help to get a database gem working so I can get started on RoR.
It first happened with mysql gem, but also happens with sqlite3, and even trying to reinstall ruby-debug gem.
OS: Mac OS X 10.9.2 (Mavericks).
ruby -v =>
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]
rvm list =>
> rvm rubies
> =* ruby-2.1.1 [ x86_64 ]
> # => - current
> # =* - current && default
> # * - default
rvm -v =>
rvm 1.25.24 (master) by Wayne E. Seguin ,
Michal Papis [https://rvm.io/]
gem -v =>
2.2.2
I have an up to date Xcode 5.1
xcode-select -v => xcode-select version 2333.
I have installed again the command line tools using:
xcode-select --install
I have then tried a number of XCode commands from other responses including:
sudo xcode-select -s /Library/Developer/CommandLineTools/
I have tried multiple answers related to gcc and linking gcc4.2 to gcc using symlinks.
/usr/bin/gcc-4.2 -v =>
Using built-in specs. Target: i686-apple-darwin11 Configured with:
/Volumes/Media/Builds/gcc-5666.3/build/obj/src/configure
--disable-checking --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++,fortran --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
An example failure is this one:
gem install mysql2
Building native extensions. This could take a while... ERROR: Error
installing mysql2: ERROR: Failed to build gem native extension.
/Users/andrew/.rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb checking for ruby/thread.h... yes checking for rb_thread_call_without_gvl() in
ruby/thread.h... yes checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes checking for
rb_hash_dup()... yes checking for rb_intern3()... yes
----- Using mysql_config at /usr/local/mysql/bin/mysql_config
----- checking for mysql.h... yes checking for errmsg.h... yes checking for mysqld_error.h... yes
----- Setting rpath to /usr/local/mysql/lib
----- creating Makefile
make "DESTDIR=" clean
make "DESTDIR=" compiling client.c compiling infile.c compiling
mysql2_ext.c compiling result.c linking shared-object
mysql2/mysql2.bundle ld: warning: directory not found for option
'-L/Users/travis/.sm/pkg/active/lib'
make "DESTDIR=" install ./install -m 0755 mysql2.bundle
./.gem.20140427-52262-1rr56ob/mysql2 make: ./install: No such file or
directory make: * [install-so] Error 1
make install failed, exit code 2
Gem files will remain installed in
/Users/andrew/.rvm/gems/ruby-2.1.1/gems/mysql2-0.3.15 for inspection.
Results logged to
/Users/andrew/.rvm/gems/ruby-2.1.1/extensions/x86_64-darwin-12/2.1.0-static/mysql2-0.3.15/gem_make.out
Any ideas anyone?
One post I saw hinted at problems mixing some 64bit and 32bit components of Ruby, Gems, etc. But I didn't see a fix, or how I should go about re-installing a 32bit-only set of components.
P.S. It looks like a certain "Travis" should try to avoid putting references to his own directories into the code:
linking shared-object sqlite3/sqlite3_native.bundle ld: warning:
directory not found for option '-L/Users/travis/.sm/pkg/active/lib'
UPDATE 1
echo $PATH
/Users/andrew/.rvm/gems/ruby-2.1.1/bin:/Users/andrew/.rvm/gems/ruby-2.1.1#global/bin:/Users/andrew/.rvm/rubies/ruby-2.1.1/bin:/Users/andrew/.rvm/bin:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin:.:/usr/lib/tuenti_tools/bin:/Users/andrew/bin:/Users/andrew/apache-maven-3.0.4/bin:/Users/andrew/android-sdk-macosx/platform-tools:/Users/andrew/android-sdk-macosx/tools:/Users/andrew/android-sdk-macosx/build_tools/17.0.0/:/Users/andrew/neo4j-community-2.0.0-M06/bin:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin:.:/usr/lib/tuenti_tools/bin:/Users/andrew/bin:/Users/andrew/apache-maven-3.0.4/bin:/Users/andrew/android-sdk-macosx/platform-tools:/Users/andrew/android-sdk-macosx/tools:/Users/andrew/android-sdk-macosx/build_tools/17.0.0/:/Users/andrew/neo4j-community-2.0.0-M06/bin:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/mysql/bin
Generally you'll get errors from exten.conf when dependencies and/or paths are out of wack. First make sure that your paths are working as you'd expect and that ruby in the command line is from rvm:
# this should output the path to the ruby in the .rvm dir
which ruby
Before you try anything else, make sure your homebrew is up-to-date and healthy:
# cd to the homebrew dir, typically here:
cd /usr/local/Cellar
git fetch origin
git reset --hard origin/master
brew update
Before you start installing stuff, make sure your PATHs are loading right. First, you want to load the homebrew bins first. In your .bash_profile or .bashrc file(s) you may or may not have a setting for the PATH, but make sure you have a line that fixes the order to something like this:
export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:$PATH
You just want to make sure that you're loading /usr/local/bin first. Also make sure that you have the RVM function loading correctly in your .bash_profile or .bashrc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
Make sure all brew dependencies are aligned, and fix anything it may say:
brew missing
You’ll also want to check on the health of your brews, and fix anything it suggests (I know you've done this already, but there may be new issues after refreshing your local repo and cleaning up from the previous command):
brew doctor
Not sure how you "patched" the gcc issue, but homebrew is great for that:
brew install apple-gcc42
After all that, I can rest assured it's not an issue with your local homebrew setup. I'd recommend using homebrew wherever you can for any native extensions (including mysql/postgres/etc). If you've done so already, uninstall the brew and re-install it:
brew uninstall mysql
brew install mysql
If after all that you still get errors, try cleaning up rvm:
rvm cleanup
rvm repair
Then uninstall/install the failing gem:
gem uninstall mysql2
gem install mysql2
Good luck!
I looked everywhere I can find but can't seem to find a solution to this.
I'm using Xcode 4.5.1 on Lion 10.8.2, and am trying to run bundle for a Rails project and it keeps jamming up on this. I'm using the Thin gem for Heroku.
Bolanos#Jeremys-Mac-mini ⦿-1.9.3 fishfarm $ sudo gem install eventmachine
Password:
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/Users/Bolanos/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for rb_thread_check_ints()... yes
checking for rb_time_new()... yes
checking for sys/event.h... yes
checking for sys/queue.h... yes
creating Makefile
make
compiling binder.cpp
make: g++-4.2: No such file or directory
make: *** [binder.o] Error 1
Gem files will remain installed in /Users/Bolanos/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0 for inspection.
Results logged to /Users/Bolanos/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/ext/gem_make.out
For now I'm having to do without Thin. Does anyone have a solution?
Also check for a symlink:
$ sudo ln -s /usr/bin/g++ /usr/bin/g++-4.2
You have to install the Command Line Tools package from developer.apple.com.
Also I was having troubles with the MacOSX10.6.sdk because some headers were missing there, so I installed the MacOSX10.5.sdk and all worked fine.
I had the exact error, and creating a new symlink for the missing resource /usr/bin/g++-4.2 worked for me.
In my setup I pointed at the location in Cellar:
/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
If none of the above work for you, I did
sudo ln -s /usr/bin/llvm-g++-4.2 /usr/bin/g++-4.2
and it worked like a charm. Running OS X 10.8.2.
You should have both:
Xcode command line tool: Detailed instructions for installation are in "How to install Xcode Command Line Tools".
Apple-gcc* compiler: I should mention that compiling with gcc48 and gcc49 fails. Therefore, installing apple-gcc42 (if you don't have) and choosing the compiler via MacPorts will solve the problem. You can see the installed gcc versions using:
port select --list gcc
You should see something like this where "mp-" stands for MacPorts own port:
Available versions for gcc:
apple-gcc42 (active)
current_saved
mp-gcc48
mp-gcc49
If you don't have "apple-gcc*" you may install it via:
port install apple-gcc42
after that chose the compiler:
port select --set gcc apple-gcc42
Now you may run:
gem install eventmachine
This should solve the problem of errors which arise during building gem native extensions on OSX.
sudo gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/sajeev86/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for libxml/parser.h... no
-----
libxml2 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.
I can't get Nokogiri to install. This has been taxing me for a while now. I've installed the dependencies via MacPorts and Homebrew as well.
I've got a feeling the right directories are not pointed to each other? But haven't a clue how to fix.
In Mavericks, installing the libraries with Homebrew and setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 before installing the gem did the trick for me.
Summarising:
If previously installed, uninstall the gem:
$ gem uninstall nokogiri
Use Homebrew to install libxml2, libxslt and libiconv:
$ brew install libxml2 libxslt libiconv
Install the gem specifying the paths to the libraries to be linked against:
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
Absolutely none of the other answers here worked for me.
On the latest version of Mavericks, the only method that succeeded for me was the following:
$ brew install libxml2 libxslt libiconv
$ sudo gem install nokogiri -v '1.6.5' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
Same issue happened to me on Lion. Took hours of reading posts, trying homebrew, macports, etc. When I found this post and read the contents of .rvm/gems/ruby-1.8.7-p358/gems/nokogiri-1.4.4/ext/nokogiri/mkmf.log, I saw:
find_header: checking for libxml/parser.h... -------------------- no
"/usr/bin/gcc-4.2 -E -I. -I/Users/me/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/i686-darwin10.8.0 -I. -I-I-I/opt/local/include -I-I-I/usr/local/include -I-I-I/Users/me/.rvm/rubies/ruby-1.8.7-p358/include -I-I-I/usr/include -I-I-I/usr/include/libxml2 -I/opt/local/include/libxml2 -I/usr/local/include/libxml2 -I/Users/me/.rvm/rubies/ruby-1.8.7-p358/include/libxml2 -I-I/opt/local/include -I-I/usr/local/include -I-I/Users/me/.rvm/rubies/ruby-1.8.7-p358/include -I-I/usr/include -I-I/usr/include/libxml2 -I/opt/local/include -I/usr/local/include -I/Users/me/.rvm/rubies/ruby-1.8.7-p358/include -I/usr/include -I/usr/include/libxml2 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -g -O2 -fno-common -pipe -fno-common -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <libxml/parser.h>
/* end */
However, gcc-4.2 didn't exist:
$ ls /usr/bin/gcc*
/usr/bin/gcc
Hence, I was able to solve the issue and get nokogiri to install by making a gcc-4.2 a symlink to gcc.
sudo ln -s gcc gcc-4.2
I ran into same issue for Mavrick and solution was the
xcode-select --install
However that was not working as apple download page does not have that installer available publically.
So if you want to have the command-line tools for Mavricks you need to have a paid account then only you will be able to install it.
Once you install it you will not face this issue of Nokogiri.
Checking the url given in the error message (http://nokogiri.org/tutorials/installing_nokogiri.html) I think the question is what version of Homebrew are you using?
brew -v
I'd update to 0.8+
brew update
brew upgrade
and then try the installation again:
brew install libxml2 libxslt
brew link libxml2 libxslt
gem install nokogiri
As for me, it helps:
brew install libxml2 libxslt
if permission denied sudo chown -R $USER /Library/Caches/Homebrew
sudo env ARCHFLAGS="-arch x86_64"
export NOKOGIRI_USE_SYSTEM_LIBRARIES=1
NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri
brew install libxml2 libxslt
gem install nokogiri -v '1.6.5' -- --use-system-libraries
Late to the party, but in case anyone is still having this issue while using MacPorts:
Add the /include dir to your PATH in your .profile file so nokogiri knows where to find it.
e.g.
MacPorts writes to your .profile file and adds the following line by default:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
First, add the /include path like so:
export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/include/:$PATH
Then, run this from the same terminal window:
source ~/.profile
(this tells your terminal to recheck the .profile file for any changes)
Finally, try installing the gem from the same terminal window.
sudo gem install nokogiri
On Yosemite I used:
brew install libxml2 libxslt
sudo gem install nokogiri -v '1.6.5' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
Very close to some of the above commands but without the libconv
For my somewhat outdated system encountering the issues above, specifically:
FENG-SHUI:demo Eric$ brew install libxml2
==> Downloading ftp://xmlsoft.org/libxml2/libxml2-2.9.0.tar.gz
######################################################################## 100.0%
==> Downloading patches
######################################################################## 100.0%
######################################################################## 100.0%
==> Patching patching file threads.c patching file xpath.c
==> ./configure --prefix=/usr/local/Cellar/libxml2/2.9.0 --without-python
==> make
==> make install
==> Caveats This formula is keg-only: so it was not symlinked into /usr/local.
Mac OS X already provides this software and installing another version in parallel can cause all kinds of trouble.
Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables:
LDFLAGS: -L/usr/local/opt/libxml2/lib
CPPFLAGS: -I/usr/local/opt/libxml2/include
Error: Failed to create: /usr/local/opt/libxml2
Things that depend on libxml2 will probably not build.
==> Summary /usr/local/Cellar/libxml2/2.9.0: 273 files, 11M, built in 2.0 minutes
FENG-SHUI:demo Eric$ brew install libxml2 libxslt
Error: libxml2-2.9.0 already installed
Error: /usr/local/opt/libxml2 not present or broken Please reinstall libxml2. Sorry :(
This was the magic formula for getting libxml2 and libxslt happily running:
# latest version 2.9.0
brew install libxml2
# installing libxslt from source code
# get latest libxslt from ftp://xmlsoft.org/libxml2/libxslt-git-snapshot.tar.gz..
# then
./configure --prefix=/usr/local/Cellar/libxslt/1.1.28 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.9.0
make
sudo make install
# installing nokogiri with this new compiled libs
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
Thanks to this guy: https://gist.github.com/fabioyamate/443160
Hope this helps someone!
Try adding --with-xml2-include=/opt/local/include/libxml2 --with-xml2-lib=/opt/local/lib to your command, assuming that's where MacPorts libxml2.
I struggled with this for hours until I found this blogpost: http://www.markhneedham.com/blog/2010/07/08/installing-ruby-1-9-2-with-rvm-on-snow-leopard
Running the command
file /usr/local/lib/libxml2.2.dylib
in the terminal returned
/usr/local/lib/libxml2.2.dylib: Mach-O dynamically linked shared library i386
which means my libxml2.2 was compiled for a 32 bit system, so I had to recompile libxml2 for 64 bit OS (Lion)
First I downloaded LATEST_LIBXML2 from ftp://xmlsoft.org/libxml2 and ran the following commands:
tar xzvf LATEST_LIBXML2
cd libxml2-2.8.0
./configure --with-python=/System/Library/Frameworks/Python.framework/Versions/2.3/
make
Then I downloaded LATEST_LIBXSLT from the same site and ran these commands:
tar xzvf LATEST_LIBXSLT
cd libxslt-1.1.26
./configure
make
sudo make install
Running
file /usr/local/lib/libxml2.2.dylib
again returned
/usr/local/lib/libxml2.2.dylib: Mach-O 64-bit dynamically linked shared library x86_64
And I could finally install nokogiri!
This worked for me on OSX - the same as #remeberer's answer, but with a full path.
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
I had to use this command for it to work :
sudo gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries
(source : http://www.virtlab.cx/ruby-fix-error-install-nokogiri-yosemite/ , many thanks to the author)
ran into a similar install issue on mountain lion except the make command was looking for gcc-4.2 in /usr/local/opt/apple-gcc42/bin
this resolved the issue for me; no need to brew install libxml2 or libxslt or add a --with option:
mkdir -p /usr/local/opt/apple-gcc42/bin
ln -s /usr/bin/gcc /usr/local/opt/apple-gcc42/bin/gcc-4.2
If you're installing an older version of Nokogiri, i.e. pre 1.6, this may help:
In the Nokogiri installation guide, they mention:
Because Nokogiri needs to be compiled and dynamically linked against
both libxml2 and libxslt, it has gained a reputation for being
complicated to install.
As of Nokogiri 1.6, libxml2 and libxslt source code is bundled with
Nokogiri, and compiled at gem-install-time. This document should work
for all versions 1.6.4 and later.
(If you need support for installing earlier versions of Nokogiri, you
may want to take a look at the git history for this document.)
Indeed, it is difficult to install, but there is a way. I went digging through the history of the readme, and decided on this one, with the well-written commit message:
"Homebrew, I straight hate you."
From that message and from the other answers here, I gleaned that I needed to be very specific about libxml2's lib, dir and include directories when installing Nokogiri. The following worked for me, but please update to match your version of the libxml2 software (mine was 2.9.2 and I was installing Nokogiri 1.5.0):
NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -v '1.5.0' --
--use-system-libraries
--with-xml2-lib=/usr/local/Cellar/libxml2/2.9.2/lib
--with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config"
--with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
--with-xml2-dir=/usr/local/Cellar/libxml2/2.9.2/
--with-xml2-include=/usr/local/Cellar/libxml2/2.9.2/include/libxml2
For me, I simply did the following
xcode-select --install
gem install nokogiri
For more in-depth troubleshooting, checkout Installing Nokogiri
I am getting the following error on my console
root#comp09:~# gem install eventmachine
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... yes
checking for rb_thread_blocking_region()... no
checking for inotify_init() in sys/inotify.h... yes
checking for writev() in sys/uio.h... yes
checking for rb_thread_check_ints()... no
checking for rb_time_new()... yes
checking for sys/event.h... no
checking for epoll_create() in sys/epoll.h... yes
creating Makefile
make
I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DBUILD_FOR_RUBY -DHAVE_RB_TRAP_IMMEDIATE -DHAVE_RBTRAP -DHAVE_INOTIFY_INIT -DHAVE_INOTIFY -DHAVE_WRITEV -DHAVE_WRITEV -DHAVE_RB_TIME_NEW -DOS_UNIX -DHAVE_EPOLL_CREATE -DHAVE_EPOLL -DWITH_SSL -fPIC -O2 -g -Wall -Wno-parentheses -Wno-long-long -o rubymain.o -c rubymain.cpp
make: I.: Command not found
make: [rubymain.o] Error 127 (ignored)
I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DBUILD_FOR_RUBY -DHAVE_RB_TRAP_IMMEDIATE -DHAVE_RBTRAP -DHAVE_INOTIFY_INIT -DHAVE_INOTIFY -DHAVE_WRITEV -DHAVE_WRITEV -DHAVE_RB_TIME_NEW -DOS_UNIX -DHAVE_EPOLL_CREATE -DHAVE_EPOLL -DWITH_SSL -fPIC -O2 -g -Wall -Wno-parentheses -Wno-long-long -o em.o -c em.cpp
make: I.: Command not found
For any help and suggestion it would be greatly appreciated.
I had a similar issue on Ubuntu 11.10 installing eventmachine.
The difference being (near the end of the logs)
make: g++: Command not found
instead of
make: I.: Command not found
This issue is related with C++ on GCC and resolved by installing build-essential
sudo apt-get install build-essential
You may also be missing the ruby dev packages. Depending on what version of ruby you are using, this could be ruby-dev, ruby1.8-dev, ruby1.9-dev, or ruby1.9.1-dev. I had the same problem, and installed ruby1.9-dev and ruby1.9.1-dev and that solved my issue.
This is the site that led me to try this approach: http://ruby.about.com/od/faqs/qt/Extconf-Rb-1-In-Require-No-Such-File-To-Load-Mkmf-Loaderror.htm
I had the same issue, this is how resolved it [NOTE: I am using ubuntu, so at "g++" you have to use "gcc" if you are using any other OS]:
At first I cloned the repository to my local machine, and did some changes, have a look at the procedure below:
git clone git://github.com/eventmachine/eventmachine.git
cd eventmachine
gem install rake-compiler
rake-compiler cross-ruby VERSION=x.x.x-px
At the place of x.x.x-px you have to use your ruby version. see the list of available version of ruby which are compatible with rake-compiler here
Then go and put this: CONFIG['CXX'] = "g++" in /eventmachine/ext/extconf.rb and /eventmachine/ext/fastfilereader/extconf.rb files, right below require 'mkmf' line.
then do: rake gem and after that: rake gem:install
It worked for me, hope it works for you too.
I'm using Ubuntu 16.10 sudo apt-get install ruby-dev build-essential then sudo gem install eventmachine. That solved it for me.
from docs .
EventMachine may require the following
dependencies, depending on your
specific usage:
* OpenSSL
* libstd++ (some systems, such as debian, may require an explicit
install in order for the compiler to
support this)
Try to install it , if you are using debian
sudo apt-get install libstdc++6
Remember to run rvm requirements and follow the instructions in Additional Dependencies.
For all users running openSUSE you'll need to execute this command :
zypper in -t pattern devel_C_C++
For simplicity we can say that this is the equivalent of this command under Ubuntu :
sudo apt-get install build-essential