fedora 上yum install rubygem-sqlite3-ruby

本文详细介绍了如何在Fedora操作系统上安装和使用Ruby on Rails,包括解决常见错误的方法,并提供了Ruby语言基础语法的学习资源,以及创建应用的步骤。此外,还分享了在安装过程中遇到的问题及其解决方案,如SQLite3库的安装问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 


<think>嗯,用户让我介绍一下这两个命令:yum install epel-release -y 和 yum install dnf。首先,我需要确认用户可能是在使用基于Red Hat的Linux系统,比如CentOS或者RHEL。这两个命令都是通过yum来安装软件包的,但各自的作用是什么呢? 首先看第一个命令,yum install epel-release -y。EPEL是Extra Packages for Enterprise Linux的缩写,它是由Fedora项目维护的,为企业级Linux提供额外软件包的仓库。很多情况下,系统自带的官方仓库可能没有某些软件,这时候EPEL就能派上用场。安装epel-release包会启用EPEL仓库,这样用户之后就可以方便地安装更多软件了。加上-y选项是为了自动确认安装,省去手动输入yes的步骤。 接下来第二个命令是yum install dnf。DNF是新一代的包管理工具,旨在替代YUM。在较新的系统版本中,比如CentOS 8及以上,DNF已经成为默认的包管理器。但如果是CentOS 7或者更旧的系统,可能还需要手动安装。用户可能在旧系统上想要使用DNF的新特性,比如更好的依赖解决和性能优化,所以需要先安装它。不过需要注意的是,虽然DNF和YUM兼容,但切换使用时可能会有细微差别,需要谨慎操作。 现在需要检查这两个命令的顺序是否有问题。通常,先安装EPEL仓库,再安装其他软件会更合适,因为EPEL可能提供了某些依赖包。但这里用户是先装epel-release,然后装dnf,这应该是正确的,因为安装dnf可能需要EPEL中的某些包?不过实际上,在CentOS 7中,dnf可能并不在EPEL里,而是需要启用其他仓库。可能需要确认这一点,避免给出错误的信息。 另外,用户可能是在CentOS 7环境下,因为CentOS 8已经默认使用DNF了。所以用户想升级到DNF来替代YUM。但需要提醒用户,在CentOS 7中,虽然可以安装DNF,但官方还是推荐使用YUM,因为系统的一些工具可能仍然依赖YUM。此外,安装DNF可能会引入依赖问题,需要特别注意。 接下来,回答的结构应该分步骤解释每个命令的作用,注意事项,以及可能的问题。需要确保使用正确的中文术语,比如“仓库”、“软件包”、“依赖关系”等。同时,按照系统级指令的要求,数学公式要用$...$,但这里可能用不上,不过需要检查是否有需要用到LaTeX的地方,比如版本号之类的,但可能不需要。所以主要确保使用正确的格式,比如代码块用反引号,但用户提供的命令已经用数字标出,可能需要用代码块格式突出显示。 需要提醒用户,在运行这些命令之前,最好先更新系统,确保仓库信息是最新的,避免安装冲突。另外,安装EPEL后,可能需要清除缓存并生成新的缓存,以确保包列表正确。最后,确认用户是否了解这些步骤的影响,特别是在生产环境中,随意更换包管理器可能存在风险,建议在测试环境中先尝试。 总结一下,回答的结构应该是: 1. 解释每个命令的作用,EPEL仓库和DNF工具。 2. 分步骤说明执行顺序和可能需要的注意事项。 3. 给出注意事项,比如系统版本、兼容性问题、生产环境建议等。 4. 提供示例代码的正确格式,确保用户能清楚看到命令。 5. 最后总结,确保用户理解每个步骤的意义和潜在影响。 需要确保信息准确,比如EPEL是否真的包含dnf包,或者是否需要其他仓库。查阅资料确认,在CentOS 7中,dnf可能需要安装epel-release,但可能需要额外的步骤,比如启用其他仓库,或者直接从官方源安装。可能需要指出这一点,或者建议用户参考官方文档。 可能的问题点:用户安装dnf后,是否应该用dnf来替代yum?比如后续安装软件应该使用dnf命令还是继续用yum?需要说明两者可以共存,但建议统一使用其中一个,避免混淆。 另外,可能需要提到,在安装dnf之后,用户可以使用dnf来管理包,但系统的一些脚本或工具可能仍然依赖yum,因此需要谨慎替换。 总之,需要明确每个步骤的目的,潜在的问题,以及正确的使用方法,帮助用户安全有效地完成任务。</think>以下是关于命令 `yum install epel-release -y` 和 `yum install dnf` 的分步解释: --- ### **1. `yum install epel-release -y` 的作用** - **EPEL 仓库简介** EPEL(Extra Packages for Enterprise Linux)是由 Fedora 社区维护的第三方软件仓库,为 RHEL、CentOS 等系统提供官方仓库未包含的额外软件包(如开发工具、实用工具等)。安装 `epel-release` 包可启用此仓库。 - **命令解析** - `yum`: 传统的 Red Hat 系 Linux 包管理工具。 - `install epel-release`: 安装 EPEL 仓库的配置包。 - `-y`: 自动确认操作(避免手动输入 `y`)。 - **典型用途** 安装 EPEL 后,可通过 `yum install` 获取更多软件(如 `htop`、`nginx` 等)。 --- ### **2. `yum install dnf` 的作用** - **DNF 简介** DNF(Dandified YUM)是新一代包管理工具,用于替代 YUM。它提供更快的依赖解析、更清晰的输出和更好的 API,已成为 CentOS 8+/RHEL 8+ 的默认工具。 - **命令解析** - `yum install dnf`: 通过 YUM 安装 DNF 工具(在旧版系统如 CentOS 7 中需手动安装)。 - 安装后,可使用 `dnf` 命令替代 `yum`(例如 `dnf install package`)。 - **注意事项** - 在 CentOS 7 中,DNF 可能与部分 YUM 插件不兼容,建议逐步过渡。 - 系统关键脚本可能依赖 YUM,不建议完全卸载 YUM--- ### **3. 执行顺序与逻辑** 1. **先安装 EPEL** 某些软件包(包括 DNF 的依赖项)可能依赖 EPEL 仓库中的内容,因此建议先启用 EPEL: ```bash yum install epel-release -y ``` 2. **再安装 DNF** 通过 EPEL 或官方仓库获取 DNF 包: ```bash yum install dnf -y ``` --- ### **4. 注意事项** - **系统版本兼容性** - **CentOS 7**: 需手动安装 DNF(通过 EPEL 或其他仓库)。 - **CentOS 8+/RHEL 8+**: DNF 已默认安装,无需额外操作。 - **命令兼容性** - DNF 与 YUM 语法高度兼容(例如 `install`, `remove` 等),但部分插件可能需调整。 - 建议统一使用 `dnf` 或 `yum`,避免混用导致依赖冲突。 - **生产环境谨慎操作** 更换核心工具前,建议在测试环境中验证,确保兼容性。 --- ### **5. 总结** - `yum install epel-release -y`:扩展软件源,解锁更多软件包。 - `yum install dnf`:升级包管理工具,提升效率和功能。 - 在旧系统(如 CentOS 7)中,两者结合可为后续软件管理提供便利,但需注意兼容性问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值