Error when trying to run gem install - ruby-on-rails

I'm trying to get rails up and running on my development server. It's a fedora14 box. I installed rvm, ruby 1.8.7, and rubygems 1.6.2. When I try to install rails via gem, gem install rails, i get the following error:
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
Any ideas as to what is going on. I'm 100% new to ruby/rubygems/rails and I know enough about Linux to be dangerous so any help/suggestions would be greatly appreciated.
Thanks in advance

Run rvm notes and install whatever it tells you (zlib-devel will probably be one of the packages you'll need to install via yum). The output you'll see will be similar to this:
# For Ruby (MRI & Ree) you should install the following OS dependencies:
ruby: yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel ;
yum install -y make bzip2 ;
yum install -y iconv-devel # NOTE: For centos 5.4 final iconv-devel might not be available :(

You need to install the zlib libraries. A gem is trying to use it with a C extension but it is not found. http://fr.rpmfind.net/linux/rpm2html/search.php?query=zlib-devel&system=&arch= Install zlib-devel.

What this error means is that zlib library is missing. This is a common problem and if you google for it, you'd find loads of information on the same. In ubuntu (where I work) installing the package zlib1g-dev and zlib1g fixes it. I am not sure what the equivalent package in Fedora is, but you should be able to search / find that.

Related

Why is Bundler unable to fetch gem metadata?

So very new to rails. I managed to install ruby and then rails framework on Fedora 17.
Here are the summary of steps I did to install ruby and rails framework:
yum install make openssh-clients gcc libxml2 libxml2-devel libxslt libxslt-devel python-devel
sudo bash -s stable < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
source /etc/profile.d/rvm.sh
rvm install ruby-1.9.2-p290 --with-openssl
rvm use ruby-1.9.2-p290 --default
rvm all do gem update --system
rvm all do gem install rails
Well.. So far so good.. Just wanted to test if the installation was perfect.
I created a hello world sample (test.rb) to test ruby installation
#!/usr/bin/env ruby
puts "hello World"
and running this with ./test.rb it works fine.
Now when I was test rails framework installation by creating a new project using
rails new demo
I receive the error
Fetching gem metadata from https://rubygems.org/.Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
What am I missing here? Or what have I done additionally which I was not suppose to do?
Looked into https://github.com/carlhuda/bundler/blob/master/ISSUES.md. Could not figure out. Has anyone come across similar issue and found a way to deal with it?
Double check that you have these packages installed...
git-core curl make bzip2 gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel libxslt-devel sqlite sqlite-devel openssl openssl-devel
You might want to check out this blog post to see if it helps you at all.
Are you using Xcode 4.1 by any chance? Seems like a lot of people have run into bundler issues after upgrading to Lion (but neglecting to upgrade Xcode as well...).
As in this thread.

Ruby on Rails and SSL error

I formatted my computer and transferred all my RoR applications to my new Lubuntu System.
I had Ubuntu with Unity. (still a linux system). I have installed rvm, ruby, rails, and they all work fine! I then run "bundle install" before actually running "rails s" to test my app.
This is what I get
Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Please include the full output of the command, your Gemfile and Gemfile.lock. Thanks!
/home/user/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- openssl (LoadError)
Any help ?
This is what sudo apt-get install openssl gives me:
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssl is already the newest version.
The following packages were automatically installed and are no longer required:
libreadline-gplv2-dev git-man libncurses5-dev libnspr4-0d libtinfo-dev git libreadline5 zlib1g-dev liberror-perl libsqlite3-dev
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Did you install the packages before installing the ruby version with RVM?
Try removing the ruby version, running
sudo apt-get install libssl-dev openssl
and then install ruby version again

`require': no such file to load -- mkmf (LoadError)

I was trying to install rails on Ubuntu Natty Narwhal 11.04, using ruby1.9.1.
I installed ruby using apt-get install ruby1.9.1-full which contains the dev package. I googled the error and all have suggested I install the 1.9.1-dev which I already have.
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:36:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:36
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
After some search for a solution it turns out the -dev package is needed, not just ruby1.8. So if you have ruby1.9.1 doing
sudo apt-get install ruby1.9.1-dev
or to install generic ruby version, use (as per #lamplightdev comment):
sudo apt-get install ruby-dev
should fix it.
Try locate mkmf to see if the file is actually there.
This is the answer that worked for me. Was in the comments above, but deserves its rightful place as answer for ubuntu 12.04 ruby 1.8.7
sudo apt-get install ruby-dev
# if above doesnt work make sure you have build essential
sudo apt-get install build-essential
I also needed build-essential installed:
sudo apt-get install build-essential
The problem is still is recursive on Ubuntu 13/04/13.10/14.04
and
sudo apt-get install ruby1.9.1-dev
worked out for me okay. So If you are using Ubuntu 13.04/13.10/14.04 then using this will really come in handy.
This works even if ruby version is 1.9.3. This is because there is no ruby1.9.3-dev available in the Repository...
Have you tried:
sudo apt-get install ruby1.8-dev
I got the similar error when install bundle
sudo apt-get install ruby-dev
Works great for me and solve the problem
Mint 16 ruby1.9.3
I think is a little late but
sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
worked for me on fedora.
http://nokogiri.org/tutorials/installing_nokogiri.html
You've Ruby 1.8 so you need to upgrade to at least 1.9 to make it working.
If so, then check How to install a specific version of a ruby gem?
If this won't help, then reinstalling ruby-dev again.
You can use RVM(Ruby version manager) which helps in managing all versions of ruby on your machine , which is very helpful for you development (when migrating to unstable release to stable release )
or for Linux (ubuntu) go for
sudo apt-get install ruby1.8-dev
then sudo gem install rails to verify it do rails -v it will show version on rails
after that you can install bundles (required gems for development)
Ruby version: 2.7.1
gem version: 3.1.3
You need to check the extension that could not be installed, and find the reasons.
Read the mkmf.log file showed at the installation error under "To see why this extension failed to compile, please check the mkmf.log which can be found here" , perhaps there is a missing lib ( sometimes iconv ), and you must install it.
You can search the extension with your package manager(apt, yum, pacman...) too.
(Personal case) Arch Linux->nokogiri
gem install rails
Showed me:
To see why this extension failed to compile, please check the mkmf.log
which can be found here:
/home/user/.gem/ruby/2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.10.9/mkmf.log
Go to: https://aur.archlinux.org/packages/ruby-nokogiri/
Make sure you have all dependencies installed
Make sure you have make installed
git clone the package
cd to package
makepkg the package
Hope to help!

ROR Installation "no such file to load"

I'm new to Ruby on Rails. I'm trying to install rails on an ubuntu linux platform. I've already installed RVM and ruby. When I type
gem install rails --version 3.0.0
I get this error:
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
Please help me install rails and learn a bit about the command line while I'm at it.
looks like you dont have ZLib installed. try gem install zlib and also apt-get install zlib zlib-dev if you dont have the system library installed
you need both the .so c-extension files (apt-get)
and the ruby interface to them (gem )
also this may be the same thing as in Antother Stackoverflow Question
I guess you need zlib package to install rails.
try
rvm pkg install zlib
after that
sudo apt-get install zlib1g
and then the development package. not sure why but you need it.
sudo apt-get install zlib1g-dev
then remove the current version of ruby because you didn't have zlib when ruby was compiled. type
rvm remove 1.9.2
(replace 1.9.2 with your version)
and then install it again with
rvm install 1.9.2
(again your version here)
That's basically it. I had the same error and it worked for me, hope it helps you too.
This has happened to me a few times. The answers near the bottom should fix it, but unfortunately you will need to remove and then recompile ruby :(
I have never gotten it to work without totally removing ruby.
http://ubuntuforums.org/showthread.php?t=1494997

Why can't I install the SQLite gem?

I'm try to install the SQLite gem on a Fedora 9 Linux box with Ruby 1.8.6, Rails 2.2.2, gem 1.3, and sqlite-3.5.9. Here's the command I'm running and its results:
sudo gem install sqlite3-ruby
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb install sqlite3-ruby
can't find header files for ruby.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out
gem_make.out just repeats what was already sent to the console. How can I install this gem?
The SQLite RubyGem isn't actually a RubyGem, it's a "CGem", IOW it's written in C. This means it has to be compiled and linked to the Ruby interpreter when you install it and in order to do that it needs the C header files for the Ruby interpreter.
If you compile Ruby yourself, those header files will be installed automatically, however, in RedHat-ish systems, such header files are usually packaged in a seperate package, called <whatever>-dev. So, in this case you will need to install the ruby-dev package and possibly the libsqlite3-dev (Ubuntu) or sqlite-devel (Fedora) package as well.
However, you might be better off just installing your Operating System's pre-packaged libsqlite3-ruby package, that way all the dependencies are automatically satisfied.
(Note: all package names pulled out of thin air, might be different on your system.)
You probably need the ruby dev package. For Ubuntu you have to install ruby1.8-dev which includes the ruby header files. A quick google says that the yum package is ruby-devel. so run this:
sudo yum install ruby-devel
I faced problem installing sqlite3-ruby gem on my fedora 13 box.
It was fixed after sudo yum install sqlite-devel
When I had that problem:
gem install sqlite3 -v '1.3.9'
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
For me worked, installing the "libsqlite3-dev" with:
apt-get install libsqlite3-dev
sudo apt-get install ruby-dev
Fixed it for me.
On Ubuntu 9 and 10 try:
sudo apt-get install ruby-dev
sudo apt-get install sqlite3-dev
Then run
gem install sqlite3
Run the following for Fedora OS:
yum install rubygem-sqlite3
On alpine, you need to install the sqlite-dev package.
I also faced this same issue, the problem is that your Linux installation requires the development libraries for SQLite3 to be installed in order to build the gem.
Here's how I fixed the issue
Open your terminal and run the following commands
sudo apt-get install sqlite3
sudo apt-get install libsqlite3-dev
And then try installing Sqlite3 gem again using this command
gem install sqlite3
That's all.
I hope this helps
Do you have all the source code required to build sqlite3-ruby? Gem is trying to compile some C code and cannot find the headers. You can probably use a fedora rpm for sqlite3-ruby (I don't use fedora, but I'm sure one exists) if you prefer to forgo compiling. Personally for ruby stuff, I prefer to use gem rather than a distro's packaging system.
I'm not really familiar with Fedora, but in Ubuntu when you are installing packages you have apt-get, and you have to install the build-essentials which includes gcc and other compilation tools for C. I would say that could be your issue, and you make look into how that can be install either using RPM or apt-get on Fedora.
I fixed the problem on my OLPC (Fedora 9) by installing 'gcc' oddly enough. It seems like it should have been one of those dev packages, but no.
Also, regarding the other packages, the suffix is "-devel", not "-dev", so make sure you get those ending right: "ruby-devel", "sqlite-devel"...
Once you get that installed, if you get errors about your gems being too old "< 1.3.1" when you try to run various rails scripts, eg: script/server or script/console, google "upgrade_rubygems" to fix that problem...
HTH...
Run "sudo yum install sqlite-devel" and then "gem install sqlite3". Had the same problem on my Fedora 15.
I had this same exact issue...instead of gem'ing the missing pieces I used synaptic on unbuntu.
The key package for me was libsqlite-ruby1.9.1 ... I documented my experience (for reference) with this error at :
Sqlite3-gem-error-during-bundle-install
I encountered this error while running bundle install after generating a react-rails app on Fedora 29. I was able to identify a suitable development package by running dnf search sqlite3, then installed it dnf install libsqlite3x-devel. This fixed it for me.

Resources