fedora 上yum install rubygem-sqlite3-ruby

Before 2 yrs, I came to know about Ruby on Rails(RoR) from the internet. I tried learning it. But failed. May be I was very lazy. Recently,I attended a 3 day workshop on Ruby on Rails in my college which helped me to kickstart my RoR learning.
Like I expected, the resource persons were comfy with installing RoR on Windows. They got the exe files in CD. People were running around to get it in their pendrives and installed it on their windows machines. I was sitting in the last bench, installing and learning stuff on my own. Why run for setup files when “yum” or “apt-get” makes things easier for you!! I encountered almost all kinds of errors that could occur on a fedora machine during RoR installation. That is the best part of the workshop. Surfing around lot of forums, I came to know that I am not the only person who suffers from such errors. Errors that occured on my system are quite common among linux RoR-ers. But most of the solutions were available for Ubuntu users. Are there less number of Fedora RoR-ers? I dont know!!
I dedicate this post to all newbies struggling with RoR installation on Fedora 

To install:

#yum install ruby sqlite rubygems rubygem-sqlite3-ruby
#gem install rails rake

To see the list of gems installed type,

#gem list

Now everything is set and ready to roar.

To test the installation, let us create an application.

$ rails new sample
$ cd sample
$ rails server

This will get your server running.
If you see something like,

=> Booting WEBrick

=> Rails 3.0.4 application starting in development on http://localhost:3000

=> Call with -d to detach

=> Ctrl-C to shutdown server

it is a sign of proper installation. 

First, learn the basic syntax of ruby language. There are a plenty of tutorials available on the internet.

Then learn how to create the Model, View and Controller for your application.

I used the following tutorials to get started with RoR:

http://www.ruby-lang.org/en/documentation/quickstart

http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html

http://guides.rubyonrails.org/getting_started.html

Installation seems to be quite simple, right? Let me post the list of bugs I encountered in this process.

#gem install rails
1 gem installed
Installing ri documentation for rails-3.0.0…
File not found: lib
Installing rdoc documentation for rails-3.0.0…
File not found: lib
Install rdoc and ri before installing rails

#gem install rdoc ri rails

It will work fine.

#gem install sqlite3
Building native extensions. This could take a while…
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
checking for sqlite3.h… no
sqlite3.h is missing. Try ‘port install sqlite3 +universal’
or ‘yum install sqlite3-devel’ and check your shared library search path
(the location where your sqlite3 shared library is located).
*** extconf.rb failed *** ….

I think sqlite3 gem is not available for fedora. sqlite3-ruby is a similar gem. So, let us install it.

#gem install sqlite3-ruby
Building native extensions. This could take a while…
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
checking for sqlite3.h… no
sqlite3.h is missing. Try ‘port install sqlite3 +universal’
or ‘yum install sqlite3-devel’ and check your shared library search path
(the location where your sqlite3 shared library is located).
*** extconf.rb failed *** ….

Oh no! sqlite3-ruby should be installed using yum. (Chill. Just wanted you to know the problems involved  )

#yum install rubygem-sqlite3-ruby

This will work perfectly fine. This happens during the installation of most of the gems.
If “gem install some_gem” throws a similar error as mentioned above, install it using “yum install rubygem-some_gem” .

The major cause of any problem arising due to sqlite3 is its improper installation. It is NOT SAFE to move on with incomplete sqlite3 installation. You will face lot of complicated problems in the later stage.

Now, create your application.

rails new sample
cd sample
rails server

You will get the error
“Could not find sqlite3-1.3.3 in any of the sources”
Because, you have the gem sqlite3-ruby. Not sqlite3. So you should map between these two gems. This can be done using the Gemfile. (sample/Gemfile)

I have shown only the necessary lines of the Gemfile.

gem ‘sqlite3′

#..
#..
# gem ‘sqlite3-ruby’, :require => ‘sqlite3′

Uncomment the line “gem ‘sqlite3-ruby’, :require => ‘sqlite3′” and comment the line “gem ‘sqlite3′”
Now your Gemfile looks like

#gem ‘sqlite3′

#..
#..
gem ‘sqlite3-ruby’, :require => ‘sqlite3′

Thats it. Now run your server. Don’t forget to edit the Gemfile of every new project you create.

$rails server
=> Booting WEBrick

=> Rails 3.0.4 application starting in development on http://localhost:3000

=> Call with -d to detach

=> Ctrl-C to shutdown server

Installation Success 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值