Cannot upgrade Rails from 4.0.0 to 4.2.0 - ruby-on-rails

I'm trying to upgrade ruby on rails on my Mac, but somehow ERROR: Failed to build gem native extension. always pops up.
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/local/opt/ruby/bin/ruby -r ./siteconf20150422-3384-60m3u9.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
-----
The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.
To install Command Line Tools, try running `xcode-select --install` on
terminal and follow the instructions. If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.
-----
*** 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
--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/Cellar/ruby/2.2.2/bin/$(RUBY_BASE_NAME)
--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
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0/nokogiri-1.6.6.2/gem_make.out

Try installing xcode like the error message says
xcode-select --install

Related

El Capitan: Can't install capybara-webkit

I couldn't bundle since there was an error occurred while installing capybara-webkit (1.11.1).
So I tried gem install capybara-webkit -v '1.11.1', but it returned en error: Failed to build gem native extension. I'm not even sure what does it mean.
The entire output would be:
Building native extensions. This could take a while...
ERROR: Error installing capybara-webkit:
ERROR: Failed to build gem native extension.
current directory: ...
*** 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=...
--with-gl-dir
--without-gl-dir
--with-gl-include
--without-gl-include=${gl-dir}/include
--with-gl-lib
--without-gl-lib=${gl-dir}/lib
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
Command ' ' not available
extconf failed, exit code 1
Gem files will remain installed in .../capybara-webkit-1.11.1 for inspection.
Results logged to .../capybara-webkit-1.11.1/gem_make.out
Does anyone know how to handle this issue?
Thank you in advance!
The answer posted by #raghu will work with Qt5.5 which is the last version officially supported by the developers of capybara-webkit. Another option is to make homebrew install qt-webkit with the current version of qt and then build capybara-webkit against that. Start by uninstalling qt from homebrew if you've already installed it (brew uninstall qt), then
brew install qt --with-qtwebkit
and go do something else for a while as it compiles from source. Once it's finished try installing the capybara-webkit gem again.
Try this:
brew install qt#5.5
brew link --force qt#5.5
gem install capybara-webkit
You can further check here: https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit#macos-sierra-1012-el-capitan-1011-and-yosemite-1010

Error when installing rails, failed to build gem native extension

I'm following this Go Rails tutorial and I'm running into trouble when I reach the step to install rails. I'm calling
sudo gem install rails -v 5.0.1
in the terminal and getting this error:
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/nokogiri-1.7.0.1/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -r ./siteconf20170302-50105-1af2foa.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for iconv.h... yes
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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
--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/Cellar/ruby/2.4.0/bin/$(RUBY_BASE_NAME)
--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
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/nokogiri-1.7.0.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/2.4.0/gems/nokogiri-1.7.0.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/nokogiri-1.7.0.1/gem_make.out
I'm not really sure what to make of this. I've tried reinstalling uninstalling and reinstalling zlib but it didn't seem to change anything. I'm on OS X Sierra version 10.12.3 by the way.
Solved by this thread using
sudo gem install rails -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/

Can't install rails on OSX El Capitan?

Using installrails.com to install rails and everything works fine until I get to the first step:
gem install rails --no-ri --no-rdoc
After typing this, the terminal outputs:
users-MacBook:~ user$ gem install rails --no-ri --no-rdoc
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/user/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20151102- 1332-1uwdkth.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line- argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
-----
The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.
To install Command Line Tools, try running `xcode-select --install` on
terminal and follow the instructions. If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.
-----
*** 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/user/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
--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
extconf failed, exit code 1
Gem files will remain installed in /Users/user/.rvm/gems/ruby- 2.2.1/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
users-MacBook:~ user$
After some research I found I may be able to fix it by installing the Xcode command line tools, but I need further help.
The error message tells you exactly what went wrong:
The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.
And how to fix the problem:
To install Command Line Tools, try running xcode-select --install on
terminal and follow the instructions. If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.
Please check:
Do you have Xcode installed?
Do you have the Xcode Command Line Tools installed?
Did you open Xcode at least once (and again after every update) and did you accept the licence?

How can I get permission to write to the gem directory in Ubuntu?

I'm trying to build my first application in Ruby on Rails, but when I run bundle install I get this message:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 -r ./siteconf20150921-23095-eac5m6.rb extconf.rb checking if the C compiler accepts ... yes Building nokogiri using
packaged libraries. checking for gzdopen() in -lz... no zlib is
missing; necessary for building libxml2
*** 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/bin/ruby2.1
--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
extconf failed, exit code 1
Gem files will remain installed in
/tmp/bundler20150921-23095-1bpxdrp/nokogiri-1.6.6.2/gems/nokogiri-1.6.6.2
for inspection. Results logged to
/tmp/bundler20150921-23095-1bpxdrp/nokogiri-1.6.6.2/extensions/x86_64-linux/2.1.0/nokogiri-1.6.6.2/gem_make.out
An error occurred while installing nokogiri (1.6.6.2), and Bundler
cannot continue. Make sure that `gem install nokogiri -v '1.6.6.2'`
succeeds before bundling.
I tried to install Nokogiri using:
gem install nokogiri -v 1.6.6.2
but got this message:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.1.0 directory.
I also tried to run:
sudo gem install nokogiri -v 1.6.6.2
but got this message:
Building native extensions. This could take a while... ERROR: Error
installing nokogiri: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 -r ./siteconf20150921-24140-1odizm6.rb extconf.rb checking if the C compiler accepts ... yes Building nokogiri using
packaged libraries. checking for gzdopen() in -lz... no zlib is
missing; necessary for building libxml2
*** 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/bin/ruby2.1
--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
extconf failed, exit code 1
Gem files will remain installed in
/var/lib/gems/2.1.0/gems/nokogiri-1.6.6.2 for inspection. Results
logged to
/var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.6.6.2/gem_make.out
I'm new to Ubuntu and Ruby on Rails. How can I solve these problems?
It looks like you're missing prerequisites.
Nokogiri's "Troubleshooting Ubuntu/Debian Installation" documentation says:
Here’s what you should do if you should find yourself in this situation:
1 sudo apt-get install ruby-dev zlib1g-dev
Please report it as a bug if this doesn’t work for you (see Getting Help for details).
Because you're using Ubuntu and doing a normal install, you'll need sudo to do any gem installs.
I'd strongly recommend using rbenv or RVM to manage your Ruby installation(s) as they'll make your life a lot easier. If you use those, you won't need to use sudo again, except for any system-wide prerequisite libraries.

Error installing Ruby in Rails in Maverick

I've tried multiple solutions offered on similar question posted here but nothing seems to work. I can't install Rails. Error message is below. Also, Wwen I try to install Xcode by using xcode-select --install, it give me an installation o network cannot download due to network Please advise. I'm very new to Ruby so any assistance would be greatly appreciated. Cheers.
nmacaule-mn1:~ nmacaule$ gem install rails --no-ri --no-rdoc
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/nmacaule/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20150209-56320-1m9byas.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
-----
The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.
To install Command Line Tools, try running `xcode-select --install` on
terminal and follow the instructions. If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.
-----
*** 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
--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/nmacaule/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)
--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
extconf failed, exit code 1
Gem files will remain installed in /Users/nmacaule/.rvm/gems/ruby-2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/nmacaule/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-13/2.2.0/nokogiri-1.6.6.2/gem_make.out
Run this command:
xcode-select --install

Resources