Sudo gem install rails - ruby-on-rails

ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.10.1/ext/nokogiri
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -I /Library/Ruby/Site/2.3.0 -r ./siteconf20190304-9093-ehjkih.rb extconf.rb
checking if the C compiler accepts -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/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=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
--help
--clean
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:456:in try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:571:inblock in try_compile'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:522:in with_werror'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:571:intry_compile'
from extconf.rb:138:in nokogiri_try_compile'
from extconf.rb:162:inblock in add_cflags'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:629:in with_cflags'
from extconf.rb:161:inadd_cflags'
from extconf.rb:416:in `'
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-16/2.3.0/nokogiri-1.10.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.10.1 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-16/2.3.0/nokogiri-1.10.1/gem_make.out

first, run this command
sudo apt-get -f install
then, run this command
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
this will install dependencies. gem native extension successfully build.

Related

An error occurred while installing nokogiri (1.10.10), and Bundler cannot continue

Os: Ubuntu 18.04
ruby: 2.7
rails: 6.*
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/.rvm/gems/ruby-2.7.0/gems/nokogiri-1.10.10/ext/nokogiri
/home/.rvm/rubies/ruby-2.7.0/bin/ruby -I
/home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0 -r
./siteconf20210329-30335-1ed7nme.rb extconf.rb
--use-system-libraries checking if the C compiler accepts ... *** 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=/home/.rvm/rubies/ruby-2.7.0/bin/$(RUBY_BASE_NAME) --help
--clean /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:471:in
try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:597:in block in
try_compile' from
/home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:544:in
with_werror' from /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:597:in try_compile' from extconf.rb:138:in nokogiri_try_compile' from extconf.rb:162:in block in add_cflags' from
/home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:655:in
with_cflags' from extconf.rb:161:in add_cflags' from
extconf.rb:416:in `'
To see why this extension failed to compile, please check the mkmf.log
which can be found here:
/home/.rvm/gems/ruby-2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.10.10/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/home/.rvm/gems/ruby-2.7.0/gems/nokogiri-1.10.10 for inspection.
Results logged to
/home/.rvm/gems/ruby-2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.10.10/gem_make.out
An error occurred while installing nokogiri (1.10.10), and Bundler
cannot continue. Make sure that gem install nokogiri -v '1.10.10' --source 'https://rubygems.org/' succeeds before bundling.
First, check your mkmf.log file for more details.
gcc: error: unrecognized command line option '-Wduplicated-cond'
gcc: error: unrecognized command line option '-Wmisleading-indentation'
gcc: error: unrecognized command line option '-Wimplicit-fallthrough=0'
Solution: brew unlink gcc
$ bundle install (will work fine)

gem install rails -v '4.2.4' failed to compile

Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /home/nagaraju/.rvm/gems/ruby-2.2.4#maxmywealth/gems/nokogiri-1.6.7.2/ext/nokogiri
/home/nagaraju/.rvm/rubies/ruby-2.2.4/bin/ruby -r ./siteconf20160226-5567-umlwr8.rb extconf.rb
checking if the C compiler accepts ... *** 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=/home/nagaraju/.rvm/rubies/ruby-2.2.4/bin/$(RUBY_BASE_NAME)
--help
--clean
/home/nagaraju/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/nagaraju/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:571:in `block in try_compile'
from /home/nagaraju/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:522:in `with_werror'
from /home/nagaraju/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:571:in `try_compile'
from extconf.rb:80:in `nokogiri_try_compile'
from extconf.rb:87:in `block in add_cflags'
from /home/nagaraju/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:619:in `with_cflags'
from extconf.rb:86:in `add_cflags'
from extconf.rb:336:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/nagaraju/.rvm/gems/ruby-2.2.4#maxmywealth/extensions/x86_64-linux/2.2.0/nokogiri-1.6.7.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/nagaraju/.rvm/gems/ruby-2.2.4#maxmywealth/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /home/nagaraju/.rvm/gems/ruby-2.2.4#maxmywealth/extensions/x86_64-linux/2.2.0/nokogiri-1.6.7.2/gem_make.out
As mentioned in the comments, you have to install developer tools first. Which is a simple command in the terminal:
xcode-select --install
After the installation is complete. Try installing rails.
Let us know, otherwise.

Rails installation failure.

I am trying to install rails and I keep getting the following error,
I have install developer tools but this didn't fix the problem.
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/stel/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150928- 21021-11g7r42.rb extconf.rb
checking if the C compiler accepts ... *** 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/stel/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
--help
--clean
/Users/stel/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/stel/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:571:in `block in try_compile'
from /Users/stel/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:522:in `with_werror'
from /Users/stel/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:571:in `try_compile'
from extconf.rb:80:in `nokogiri_try_compile'
from extconf.rb:87:in `block in add_cflags'
from /Users/stel/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:619:in `with_cflags'
from extconf.rb:86:in `add_cflags'
from extconf.rb:337:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/stel/.rvm/rubies/ruby- 2.2.1/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/stel/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
Petross-Mini:~ stel$ bundle config build.nokogiri --use-system-libraries
-bash: bundle: command not found
You have to install ruby with rvm or rbenv . Otherwise It will create a problem. Use the following steps.
#Install rvm
\curl -sSL https://get.rvm.io | bash -s stable
#Install ruby version 2.0.0-p451
rvm install ruby-2.0.0-p451

gem install memcached with ruby failed

that is the error message:
/home/alan/.rvm/rubies/ruby-2.0.0-p481/bin/ruby extconf.rb
checking for sasl/sasl.h... no
Please install SASL to continue. The package is called libsasl2-dev on Ubuntu and cyrus-sasl on Gentoo.
*** 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=/home/alan/.rvm/rubies/ruby-2.0.0-p481/bin/ruby
extconf failed, exit code
Thanks for helping me if u have spare time.
It clearly states that some library is missing
Please install SASL to continue. The package is called libsasl2-dev on Ubuntu and cyrus-sasl on Gentoo.
*** extconf.rb failed ***
For Ubuntu you have to install those
sudo apt-get install libsasl2
sudo apt-get install libsasl2-dev
For Gentoo
install
cyrus-sasl
If you read the error logs, it says:
Please install SASL to continue. The package is called libsasl2-dev on
Ubuntu and cyrus-sasl on Gentoo.
Try installing following packages before proceeding (for Ubuntu):
sudo apt-get install libsasl2
sudo apt-get install libsasl2-dev

failed gem install rails on mac ERROR: Failed to build gem native extension

I downloaded xcode, command line tools, home brew, rvm, and ruby, but when I use the command sudo gem install rails I get an error message. Not sure what to do any help would be great, I want to install rails on my new mac.
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/cheatermoves/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/test/test_atomic.rb
marshalls-MacBook-Air:~ cheatermoves$ sudo gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
*** 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/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/
/Users/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from /Users/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
from extconf.rb:26:in `<main>'
You probably don't want to be using sudo with RVM... Try just:
gem install rails
sudo gcc --version
When you have done this accept user agreement from xcode! (this is what fixed it for me.)

Resources