rails安装_Nokogiri在安装Rails时出错

本文提供了解决在Fedora操作系统上安装Ruby on Rails时遇到的Nokogiri错误的方法。作者在遵循Pragmatic Studio Rails课程教程时遇到问题,通过特定的dnf命令和gem安装解决了这一难题,使Rails应用程序得以成功创建和运行。

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

rails安装

How I solved Nokogiri error and installed Ruby on Rails on Fedora OS

我如何解决Nokogiri错误并在Fedora OS上安装Ruby on Rails

Note: This post does not discuss about what these problems were, rather it provides solution to the problems which I faced.

注意: 本文不讨论这些问题是什么,而是提供了我所遇到问题的解决方案。

I was following a tutorial, Pragmatic Studio Rails Course. In that exercise, it asks you to make a rails app.

我一直在关注Pragmatic Studio Rails课程教程。 在该练习中,它要求您制作一个Rails应用程序。

Going through the tutorial, I did rails new eventz but it could not install all the packages present in the Gemfile. It always showed this error:

在本教程中,我做了rails new eventz但是它无法安装Gemfile中存在的所有软件包。 它总是显示此错误:

The initial packages couldn’t be installed so I tried bundle install --path vendor/bundle but that too resulted in the error.

最初的软件包无法安装,所以我尝试了bundle install --path vendor/bundle但这也导致了错误。

No matter what solution I use it always ended up in this error:

无论我使用哪种解决方案,总是会导致以下错误:

Image for post
Again, Nokogiri Error: Failed to build gem native extension.
再次,Nokogiri错误:无法构建gem本机扩展。

解决方案 (The Solution)

After a lot of frustration and attempts, I got the something on FedoraProject.

经过很多挫折和尝试,我在FedoraProject上得到了一些东西。

The problem was: I did not have the proper files required to bundle things together.

问题是:我没有足够的文件来捆绑东西。

解决此错误的命令: (Commands that fixed this error:)

$ sudo dnf group install "C Development Tools and Libraries"
$ sudo dnf install ruby-devel zlib-devel
$ gem install rails
$ bundle install

If you get sqlite3 error that means you’re on the right track

如果您收到sqlite3错误,则表示您sqlite3正确的轨道上

You have to install sqlite3 header packages, you can get the package here.

您必须安装sqlite3标头软件包,您可以在此处获取该软件包。

This command installs the files.

此命令将安装文件。

dnf install sqlite-devel

then generate bundle

然后生成捆绑

bundle install

And, voila! You are good to go. Run your server using:

而且,瞧! 你已准备好出发。 使用以下命令运行服务器:

rails s
Image for post
The server successfully started on port 3000
服务器在端口3000上成功启动

Now, your app starts at http://localhost:3000

现在,您的应用程序从http://localhost:3000

Image for post

I wasted my 20+ hours on this problem. I hope no one else has to do that.

我在这个问题上浪费了20多个小时。 我希望没有其他人必须这样做。

If you found something wrong with the article or something doesn't work or maybe you found another solution, please mention them in the responses so that don't have to go through things that you have.

如果您发现文章有问题或不起作用,或者您找到了另一种解决方案,请在回复中提及它们,这样就不必遍历您已有的东西。

Thank you for your time.

感谢您的时间。

I’m Anas Ansari.

我是Anas Ansari。

翻译自: https://medium.com/@anasansari157/nokogiri-error-on-installing-rails-c0b2cdf95e1b

rails安装

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值