Ubuntu instaled ruby-dev but still can not install gem nokogiri - ruby-on-rails

I'm trying to install gem nokogiri by:
sudo gem install nokogiri
But I get this error:
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/nokogiri-1.8.4/ext/nokogiri
/usr/bin/ruby2.5 -r ./siteconf20181003-5678-1ub6p51.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
I search on google and they said it because there are no ruby-dev. So I install ruby-dev by:
~$ sudo apt-get install ruby-dev
~$ dpkg -l | grep ruby-dev
ii ruby-dev:amd64 2:2.3.0+1bbox1~xenial1
amd64 Header files for compiling extension modules for Ruby (default version)
And it install ruby-dev successfully but still get error before.

Thats the problem you dont have rails installed and also gem bundler.
Can you please install it:
Run in terminal:
gem install bundler
and after that:
gem install rails

install specific version of ruby
sudo apt-get install ruby2.5-dev
gem install nokogiri -v 1.8.4 -- --use-system-libraries

Related

Install rails error:Failed to build gem native extension

I am install rail on CentOS 7.2,this is my install command:
gem install rails -v=4.2
This is the error log output:
[root#localhost ~]# gem install rails -v=4.2
gem install rails -v=4.2Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h
Gem files will remain installed in /usr/local/share/gems/gems/nokogiri-1.6.8.1 for inspection.
Results logged to /usr/local/share/gems/gems/nokogiri-1.6.8.1/ext/nokogiri/gem_make.out
CentOS: 7.2
Ruby: ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
gem: 2.0.14
Just update your system by using following command
gem update --system 2.0.3
Install dependency:
yum -y install libyaml-devel zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel gcc ruby-devel gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA

RPi dashing.io ERROR: failed to build gem native extension

I'm trying to set up dashing.io on my raspberry pi using this guide: https://github.com/mivok/squirrelpouch/wiki/dashing-pi
I install ruby-dev using sudo apt-get install ruby ruby-dev and than dashing using echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc
sudo gem install bundler dashing
During the installastion of dashing I get the following error:
ERROR: Error installing dashing:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
Gem files will remain installed in /var/lib/gems/1.9.1/gems/eventmachine-1.0.3 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/eventmachine-1.0.3/ext/gem_make.out`
I've found several similar posts about this error, but every solution to those is to install ruby-dev, which I have done already. I have also tried to run sudo apt-get install ruby1.9.1-dev. This command tells me that this version of ruby-dev is already installed. I've also tried to run rails -v, but get -bash: rails: command not found
What else can I do to fix this?
Thanks!

Error while installing Ruby on Rails

I am trying to install Ruby on Rails on my local machine for development purposes, but I have hit upon an error. I can't quite tell, but it seems like it might be a gem error. Though, this is my first time trying to use all three, Ruby, Gem and Rails, so I'm not sure.
Running the command "sudo gem install rails -V" these are the last few lines printed after the error is hit:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:13:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/atomic-1.1.14 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/atomic-1.1.14/ext/gem_make.out
The version of Ruby installed is:
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
The version of gem is:
1.8.23
Install the gem as a normal user, not sudo:
gem install rails
Or install the ruby dev package. There are a lot of similar answers in SO:
Failed to build gem native extension — Rails install
Unable to install gem - Failed to build gem native extension - cannot load such file -- mkmf (LoadError)
Failed to build gem native extension (mkmf (LoadError)) - Ubuntu 12.04
From the atomic gem README.
As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use the new atomic
Please install Java, then re-run the gem install process.
What Linux do you have?
On Mint, i did:
sudo apt-get install git
sudo apt-get install curl
curl -L https://get.rvm.io | bash -s stable --ruby
sudo apt-get install git-core
source ~/.rvm/scripts/rvm
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
rvm autolibs enable
rvm reload
rvm requirements
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
rvm install ruby-2.0
curl -L https://get.rvm.io | bash -s stable --rails
and it works fine. This will (currently) install Ruby 2.0 and rails 4.0 however.

ERROR: Error installing capybara-webkit:

Any suggestions on how to fix?
gem install capybara-webkit -v '0.11.0'
Building native extensions. This could take a while...
ERROR: Error installing capybara-webkit:
ERROR: Failed to build gem native extension.
/home/durrantm/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
sh: qmake: not found
Gem files will remain installed in /home/durrantm/.rvm/gems/ruby-1.9.3-p194/gems/capybara-webkit-0.11.0 for inspection.
Results logged to /home/durrantm/.rvm/gems/ruby-1.9.3-p194/gems/capybara-webkit-0.11.0/./gem_make.out
If you are in Ubuntu do
sudo apt-get install qt4-dev-tools libqt4-dev libqt4-core libqt4-gui
If you are on Mac
brew install qt
and then
gem install capybara-webkit -v '0.11.0'
For Ubuntu 16.04
sudo apt-get install qt-sdk
Followed by
gem install capybara-webkit -v '1.11.0'
or replace with whatever version you want to install.
You are probably missing the qt libraries. See the capybara-webkit wiki for instructions on installing them for your platform.
brew install qt will only install (as of August 4, 2015) 4.8.6, which gives you this message.
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.6.
Instead, if you do
brew install qt5
brew link --force qt5
you won't get that error.
On El Capitan or Yosemite, you may need to do
brew install qt55
according to the doc here.
For Ubuntu 20.04 you can install qt5-default package
sudo apt-get install g++ qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
Then install the gem with the required version:
gem install capybara-webkit -v '1.11.0'
On fedora is a bit more complicated. I did the next which takes a while:
$ sudo dnf install make gcc-c++ gdb qt5*-devel qt-creator
$ export QMAKE=/usr/bin/qmake-qt5
$ gem install capybara-webkit
Then it worked!
See more info on capybara-webkit wiki

sudo gem install pg won't work

I'm trying to get Rails to work with PostgreSQL. Apparently one thing I need to do along the way is sudo gem install pg. When I do that, I get this:
jason#buster:~/projects$ sudo gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:2:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:2
Gem files will remain installed in /var/lib/gems/1.8/gems/pg-0.10.0 for inspection.
Results logged to /var/lib/gems/1.8/gems/pg-0.10.0/ext/gem_make.out
I've Googled and tried a few things based on what I've found but nothing seems to help. Any advice? I'm on Ubuntu.
You need to install your distro ruby-dev (or devel) package otherwise you won~t be able to build any ruby C extensions.
I'm not on ubuntu, but you package-manager command might be somewhat like this:
$ sudo apt-get install ruby-dev build-essential
On Ubuntu:
$ sudo apt-get install postgresql-client libpq5 libpq-dev
$ sudo gem install pg

Resources