Nokogiri 和 Openshift

Nokogiri and Openshift

我在 Openshift 服务器上上传了我的 Rails 应用程序,但出现以下错误:

我在 Google 中进行了搜索,但没有找到解决方案。

我有 Ruby 2.0 和 Rails 4.

在我的本地主机上,我的应用程序可以正常运行,但是当我上传它时,由于这个错误,它无法运行。

我在 Windows 8.

这是我的 Gemfile 和 Gemfile.lock:

source 'https://rubygems.org'

gem 'rails', '4.2.4'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
gem 'byebug'
end

group :development do
gem 'web-console', '~> 2.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
gem 'rake'
gem 'rack'
gem 'nokogiri'

Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.2.4)
      actionpack (= 4.2.4)
      actionview (= 4.2.4)
      activejob (= 4.2.4)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.4)
      actionview (= 4.2.4)
      activesupport (= 4.2.4)
      rack (~> 1.6)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (4.2.4)
      activesupport (= 4.2.4)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    activejob (4.2.4)
      activesupport (= 4.2.4)
      globalid (>= 0.3.0)
    activemodel (4.2.4)
      activesupport (= 4.2.4)
      builder (~> 3.1)
    activerecord (4.2.4)
      activemodel (= 4.2.4)
      activesupport (= 4.2.4)
      arel (~> 6.0)
    activesupport (4.2.4)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    arel (6.0.3)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    builder (3.2.2)
    byebug (8.2.2)
    coffee-rails (4.1.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.1.x)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.10.0)
    concurrent-ruby (1.0.1)
    debug_inspector (0.0.2)
    erubis (2.7.0)
    execjs (2.6.0)
    globalid (0.3.6)
      activesupport (>= 4.1.0)
    i18n (0.7.0)
    jbuilder (2.4.1)
      activesupport (>= 3.0.0, < 5.1)
      multi_json (~> 1.2)
    jquery-rails (4.1.1)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (1.8.3)
    loofah (2.0.3)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    mime-types (2.99.1)
    mini_portile2 (2.0.0)
    minitest (5.8.4)
    multi_json (1.11.2)
      mini_portile2 (~> 2.0.0.rc2)
    nokogiri (1.6.7.2-x86-mingw32)
      mini_portile2 (~> 2.0.0.rc2)
    rack (1.6.4)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.4)
      actionmailer (= 4.2.4)
      actionpack (= 4.2.4)
      actionview (= 4.2.4)
      activejob (= 4.2.4)
      activemodel (= 4.2.4)
      activerecord (= 4.2.4)
      activesupport (= 4.2.4)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.4)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.7)
      activesupport (>= 4.2.0.beta, < 5.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.3)
      loofah (~> 2.0)
    railties (4.2.4)
      actionpack (= 4.2.4)
      activesupport (= 4.2.4)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (11.1.0)
    rdoc (4.2.2)
      json (~> 1.4)
    sass (3.4.21)
    sass-rails (5.0.4)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    sdoc (0.4.1)
      json (~> 1.7, >= 1.7.7)
      rdoc (~> 4.0)
    sprockets (3.5.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.0.4)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sqlite3 (1.3.11-x86-mingw32)
    thor (0.19.1)
    thread_safe (0.3.5)
    tilt (2.0.2)
    turbolinks (2.5.3)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    tzinfo-data (1.2016.1)
      tzinfo (>= 1.0.0)
    uglifier (2.7.2)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    web-console (2.3.0)
      activemodel (>= 4.0)
      binding_of_caller (>= 0.7.2)
      railties (>= 4.0)
      sprockets-rails (>= 2.0, < 4.0)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  byebug
  coffee-rails (~> 4.1.0)
  jbuilder (~> 2.0)
  jquery-rails
  nokogiri
  rack
  rails (= 4.2.4)
  rake
  sass-rails (~> 5.0)
  sdoc (~> 0.4.0)
  sqlite3
  turbolinks
  tzinfo-data
  uglifier (>= 1.3.0)
  web-console (~> 2.0)

BUNDLED WITH
   1.10.4

编辑:

C:\Bitnami\game_test>bundle install
Using rake 11.1.0
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.4
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using nokogiri 1.6.7.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using loofah 2.0.3
Using rails-html-sanitizer 1.0.3
Using actionview 4.2.4
Using rack 1.6.4
Using rack-test 0.6.3
Using actionpack 4.2.4
Using globalid 0.3.6
Using activejob 4.2.4
Using mime-types 2.99.1
Using mail 2.6.3
Using actionmailer 4.2.4
Using activemodel 4.2.4
Using arel 6.0.3
Using activerecord 4.2.4
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using byebug 8.2.2
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.4
Using coffee-rails 4.1.1
Using concurrent-ruby 1.0.1
Using multi_json 1.11.2
Using jbuilder 2.4.1
Using jquery-rails 4.1.1
Using bundler 1.10.4
Using sprockets 3.5.2
Using sprockets-rails 3.0.4
Using rails 4.2.4
Using rdoc 4.2.2
Using sass 3.4.21
Using tilt 2.0.2
Using sass-rails 5.0.4
Using sdoc 0.4.1
Using sqlite3 1.3.11
Using turbolinks 2.5.3
Using tzinfo-data 1.2016.1
Using uglifier 2.7.2
Using web-console 2.3.0
Updating files in vendor/cache
Bundle complete! 15 Gemfile dependencies, 54 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

昨晚,João Gonçalves给了我有用的建议。

问题出在 Openshift 服务器端,因为服务器无法加载 nokogiri gem。

这是我做的事情:

  1. 下载用于 SSH 的 Putty,因为我需要连接到我的 Openshift 服务器。

    您需要下载 putty.exeputtygen.exe。我在 Windows,所以如果你有另一个 OS,你必须找到另一种方法通过 SSH 连接到你的服务器。

    按照this guide配置Putty。

    当您必须在 Putty 中为提示输入主机名或 IP 时:

    Hostname(or IP address)
    

    你必须把你的 Remote Access(没有 SSH 前缀的 Remote Access 下的字符串),如图所示,然后粘贴到 Putty 中。

    1. 连接到您的服务器并切换到您的应用程序目录。我看到我的目录在哪里使用 rhc tail appname。正如你在这张 post 的第一张图片中看到的,你可以看到以下路径:

      openshift/56e4ae0e0c1e66cdb7000051/app-root/runtime/repo/

    您必须移动到 repo 目录。

    1. 运行 gem install bundler.
    2. 运行 bundle install --no-deployment.
    3. 可以肯定的是,在此之后,运行 bundle install

您现在应该在您的主机上安装了 nokogiri。

尝试从 URL 启动您的应用程序,您应该能够看到没有错误的正确页面。

您的 Gemfile.lock 指定了 mingw 平台,因为您的开发机器是 Windows。然而,OpenShift 运行 Linux 个容器。

不要上传您的 Gemfile.lock 文件,而是让 OpenShift 的暂存过程找到与平台匹配的正确 gem。