Heroku 应用程序崩溃,日志显示“No such file to load -- nokogiri (LoadError)”
我有一个工作应用程序,添加了 Nokogiri,用于解析一些 xml,在本地运行良好。
我的 Gemfile 包括:gem 'nokogiri'
我运行了 bundle install
并验证了我的 Gemfile.lock 包括 DEPENDENCIES
... nokogiri
code>
在我的控制器类中,我添加了(我不认为我必须这样做,但如果我没有这样做,就会在本地出现错误):
class MydealController < ApplicationController
require 'rubygems'
require 'open-uri'
require 'nokogiri'
当我使用浏览器获取使用 nokogiri doc = Nokogiri::XML(getresult)< 的 MydealController 中的 url 时/code> Heroku 崩溃。
heroku 日志
显示此错误 No such file to load -- nokogiri (LoadError)
看看当我 git push heroku
时会发生什么,我没有看到nokogiri 在许多已安装的 gem 列表中。 Heroku 说推送很好,但 nokogiri 未列出,我收到上述错误......
I had a working app, added Nokogiri, to parse some xml, runs fine locally.
My Gemfile includes: gem 'nokogiri'
I ran bundle install
and verified my Gemfile.lock includes DEPENDENCIES
... nokogiri
In my controller class I added (didnt thinkI had to but got an error locally if I didnt):
class MydealController < ApplicationController
require 'rubygems'
require 'open-uri'
require 'nokogiri'
when I use my browser to get the url in MydealController that uses nokogiri doc = Nokogiri::XML(getresult)
Heroku crashes.
heroku logs
shows this error No such file to load -- nokogiri (LoadError)
Looking at what happens when I git push heroku
I do not see nokogiri on the list of many many gems that get installed. Heroku says the push was fine, but nokogiri is not listed and I get the aforementioned error...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
似乎在使用 Windows
Gemfile.lock
时将包含特定于 Windows 的nokogiri
gem 版本,解决方案是删除 Gemfile.lock 并推送到赫罗库。有关此主题的更多信息此处
It seems that when using Windows
Gemfile.lock
will contain version ofnokogiri
gem specific for windows, solution is to remove Gemfile.lock and push to heroku.More info on this subject here
你的使命应该选择接受它。
确保:
祝你好运!此消息将在 10 秒后自毁...
Your mission should you choose to accept it.
Ensure:
Good luck! This message will self destruct in 10 seconds...
刚刚遇到了同样的问题 - 您必须运行
bundle install
才能将其添加到Gemfile.lock
中,heroku 会查看该文件以查找已卸载的依赖项。Just had the same problem -- you have to run
bundle install
to get it added to theGemfile.lock
which heroku looks at to find uninstalled dependencies.这可能有助于理解原因:
http://devcenter.heroku.com/articles/ps
确实删除 Gemfile.lock 可能会有所帮助。所有其他编译的 gem 都会导致问题。最好的方法是寻求 Heroku 的支持。
只找到这篇文章:
http://ganeshprasadsr.blogspot.com /2010/10/installing-nokogiri-for-rails-3-app-on.html
This might help to understand the reason:
http://devcenter.heroku.com/articles/ps
Indeed removing Gemfile.lock might help. All other compiled gem will cause isseu. Best way is to ask Heroku's support.
Only found this article:
http://ganeshprasadsr.blogspot.com/2010/10/installing-nokogiri-for-rails-3-app-on.html
尝试从控制器中删除
require 'nokogiri'
。这对我有用。
Try to remove
require 'nokogiri'
from controller.It works for me.