Ruby-on-rails 为什么我不能安装 SQLite gem?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/421225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 20:53:52  来源:igfitidea点击:

Why can't I install the SQLite gem?

ruby-on-railsrubysqlitegem

提问by Eric Noob

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:

我尝试在带有 Ruby 1.8.6、Rails 2.2.2、gem 1.3 和 sqlite-3.5.9 的 Fedora 9 Linux 机器上安装 SQLite gem。这是我正在运行的命令及其结果:

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.outjust repeats what was already sent to the console. How can I install this gem?

gem_make.out只是重复已经发送到控制台的内容。我该如何安装这个 gem?

回答by J?rg W Mittag

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 thatit needs the C header files for the Ruby interpreter.

SQLite RubyGem 实际上不是RubyGem,它是一个“ CGem”,它是用 C 编写的。这意味着它必须在安装时编译并链接到 Ruby 解释器,为了做到一点它需要Ruby 解释器的 C 头文件。

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-devpackage and possibly the libsqlite3-dev(Ubuntu) or sqlite-devel(Fedora) package as well.

如果你自己编译 Ruby,这些头文件会自动安装,但是,在 RedHat-ish 系统中,这些头文件通常打包在一个单独的包中,称为<whatever>-dev. 因此,在这种情况下,您将需要安装该ruby-dev软件包,也可能需要安装libsqlite3-dev(Ubuntu) 或sqlite-devel(Fedora) 软件包。

However, you might be better off just installing your Operating System's pre-packaged libsqlite3-rubypackage, that way all the dependencies are automatically satisfied.

但是,您最好只安装操作系统的预打包libsqlite3-ruby软件包,这样所有依赖项都会自动得到满足。

(Note: all package names pulled out of thin air, might be different on your system.)

(注意:所有的包名都是凭空而来的,在你的系统上可能会有所不同。)

回答by hacintosh

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:

您可能需要 ruby​​ dev 包。对于 Ubuntu,您必须安装包含 ruby​​ 头文件的 ruby​​1.8-dev。一个快速的谷歌说 yum 包是 ruby​​-devel。所以运行这个:

sudo yum install ruby-devel

须藤 yum 安装 ruby​​-devel

回答by Rahul

I faced problem installing sqlite3-ruby gem on my fedora 13 box. It was fixed after sudo yum install sqlite-devel

我在我的 Fedora 13 盒子上安装 sqlite3-ruby gem 时遇到了问题。sudo yum install sqlite-devel后修复

回答by matiasmasca

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:

对我来说,安装“ libsqlite3-dev”:

apt-get install libsqlite3-dev

回答by Sacha

sudo apt-get install ruby-dev

Fixed it for me.

为我修好了。

回答by ldemon

On Ubuntu 9 and 10 try:

在 Ubuntu 9 和 10 上尝试:

sudo apt-get install ruby-dev
sudo apt-get install sqlite3-dev

Then run

然后运行

gem install sqlite3

回答by Promise Preston

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.

我也遇到了同样的问题,问题是你的 Linux 安装需要安装 SQLite3 的开发库才能构建 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

然后尝试使用此命令再次安装 Sqlite3 gem

gem install sqlite3

That's all.

就这样。

I hope this helps

我希望这有帮助

回答by Chase

Run the following for Fedora OS:

为 Fedora 操作系统运行以下命令:

yum install rubygem-sqlite3

回答by barneytron

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.

你有构建 sqlite3-ruby 所需的所有源代码吗?Gem 正在尝试编译一些 C 代码,但找不到头文件。如果您更愿意放弃编译,您可能可以将 Fedora rpm 用于 sqlite3-ruby(我不使用 Fedora,但我确定存在)。就个人而言,对于 ruby​​ 的东西,我更喜欢使用 gem 而不是发行版的打包系统。

回答by Omer Levi Hevroni

On alpine, you need to install the sqlite-devpackage.

在 alpine 上,您需要安装该sqlite-dev软件包。