Error while installing Ruby on Rails - 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.

Related

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

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

Error installing gem failed to build gem native extensions -- cannot load such file -- mkmf

RoR is nice, but sometimes makes me want to bang my head against the wall (and it's probably my fault anyway). I'm simply trying to install the Thin web-client gem, and when I run sudo gem install thin, I get the following error (it requires the installation of the eventmachine gem first):
sudo gem install thin
Fetching: eventmachine-1.0.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing thin:
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:2:in `<main>'
I've searched for the "cannot load such file -- mkmf" error, but most issues seem to be surrounding the fact that it was available in 1.8-dev but not 1.8, but as I'm running 1.9.3 I figured I had mkmf - which I verified with locate mkmf:
/home/ubuntu/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb
The directory that mkmf is located in is obviously not under the /usr/lib/ruby/... directory - I'm not sure if this is my problem or not, but it maybe enough to jumpstart one of you experts out there as to what's going on and what the solution could be.
Also, I've used RVM to install ruby 1.9.3 rather than just a gem install...
Thanks in advance!
if you're using RVM, you shouldn't ever be using 'sudo'. Using sudo calls libs and such out of the rvm path. Try just a flat
gem install thin
and see if that helps.
~Kevin
I had a similar error to this outside of rvm, I found that i needed to install ruby-devel
I have same problem in Ubuntu 12.04 . Solved by:
sudo apt-get install build-essential
sudo apt-get install curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev
Try below command it will helps to resolve the problem
sudo gem install thin -- --with-cflags=\"-O2 -pipe -march=native -w\"
This did it for me:
sudo apt-get install ruby-dev
Cheers

Trouble installing ruby on rails

I'm getting
ERROR: While executing gem ... (NameError) uninitialized constant Gem::RemoteFetcher::OpenSSL
When I try to run # gem install rails
I already have
Ruby v1.8.7
Gem (rubygems.nonarch) v1.7.2
Installed.
Any Idea what I should do?
Running sudo gem install rails now gives me:
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/lib/ruby/ruby.h
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/json-1.7.4 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/json-1.7.4/ext/json/ext/generator/gem_make.out
Everything Installed via YUM
Running Fedora 15
I was having a similar issue while doing #gem install rake, but I found out that my system was behind a proxy server, and so I tried supplying the proxy address by this command:
gem install rake -p http//IPaddress:proxyport (put : after http)
and it worked for me, with no such error afterwards.
Hit rvm requirements. You don't have libssl-dev installed.
➜ ~ rvm requirements
Requirements for Linux ( DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu 10.10" )
NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
This is the *original* / standard Ruby Language Interpreter
'ree' represents Ruby Enterprise Edition
'rbx' represents Rubinius
bash >= 4.1 required
curl is required
git is required (>= 1.7 for ruby-head)
patch is required (for 1.8 rubies and some ruby-head's).
To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),
then you must install and use rvm 1.8.7 first.
Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
ruby: /usr/bin/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
# For JRuby, install the following:
jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk
# For IronRuby, install the following:
ironruby: /usr/bin/apt-get install curl mono-2.0-devel
I'm not aware how Fedora's requirements differ from Ubuntu's, but that's probably only in package names.
I have just had same issue with gem install on Ubuntu. It is now working and I think that what I did to fix it was enable ssl out through the firewall.
It looks as if gem returns this error in response to failure to establish an SSL connection, presumably while trying to handle the failure.
Russell

How to install Rails application on ubuntu?

While installing, some errors are displayed. The command I am using is:
sudo gem install rails --include-dependencies
or
sudo gem install rails --no-rdoc --no-ri
In both cases, it is the same error. I think my rubygems may not be installed properly?
ERROR: Loading command: install (LoadError) no such file to load -- zlib ERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::InstallCommand
I have installed ruby-1.9.2-p0 and rubygems-1.3.7
One more thing: Do I have to cd into the ruby or rubygems directory and then install rails or can I do it from default directory?
Open command prompt and please let us know the results
verify Ruby version
ruby -v
verify gem version
gem -v
Use command
gem install rails
verify the rails version
rails -v
$ sudo apt-get install ruby1.9 gem1.9
checkout below mentioned link that would help you to install rails3 using rvm on ubuntu box
http://www.jaikeerthi.in/2010/11/install-rails-ubuntu/
You have to install zlib1g and zlib1g-dev
sudo aptitude install zlib1g zlib1g-dev
Some GEMs compile some binaries at installation time and need other libraries (such as zlib) be installed on the system.
Assuming that you are installing on Ubuntu 14.04...
First install rbev to pick a Ruby version for your application.
sudo apt-get update
Install the rbenv and Ruby dependencies with apt-get:
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
Now let's install rbenv
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
And now let's install Ruby:
rbenv install -v 2.2.3
rbenv global 2.2.3
Verify that Ruby is installed with this command:
ruby -v
Install bundler to manage gems:
gem install bundler
Now we are set to install Rails:
gem install rails
Then run
rbenv rehash
It's good to verify if the Rails is installed properly:
rails -v
Make sure to install database and Javascript runtime afterwards...

mod_rails make: command not found

I'm setting up mod_rails on a Debian server but somehow something got screwed up (it wasn't me :P ).
gem install passenger
Building native extensions. This could take a while...
ERROR: Error installing passenger:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
creating Makefile
make
sh: make: command not found
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.7 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.7/ext/fastthread/gem_make.out
gem is installed:
gem -v
1.3.5
ruby also fine:
ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
Are you sure you have make, gcc et al?
$ sudo apt-get install build-essential
Does "which make" point to anything?
apt-get install build-essential zlib1g-dev libssl-dev libreadline5-dev
This should be everything you need to get passenger to build

Resources