如何让 Phusion Passenger 识别正确版本的捆绑器?

How do I get Phusion Passenger to recognize the correct version of bundler?

首先,我是一个编程新手,甚至是最近的 Ruby/Rails 新手。我有一个要上传的网站 (http://suzyogi.com)。大多数页面只是 HTML 和 CSS,还有一点 jQuery,但我想包括一个博客,所以我在 Rails 4.2.0 中构建了它。我正在使用 DreamHost 来托管我的网站,他们对 Rails 应用程序的说明告诉我在 Web 选项下选中此选项:乘客(仅限 Ruby/Python 应用程序)。在我的本地环境中一切正常,但是当我尝试在互联网上查看该站点时,我从 Phusion Passenger 收到此错误:

compile error
/home/nictob3/suzyogi.com/Gemfile:24: syntax error, unexpected ':', expecting $end
gem 'sdoc', '~> 0.4.0', group: :doc
                          ^ (SyntaxError)
/home/nictob3/suzyogi.com/Gemfile:24:in `evaluate'
/usr/lib/ruby/vendor_ruby/bundler/definition.rb:17:in `build'
/usr/lib/ruby/vendor_ruby/bundler.rb:136:in `definition'
/usr/lib/ruby/vendor_ruby/bundler.rb:124:in `load'
/usr/lib/ruby/vendor_ruby/bundler.rb:107:in `setup'
/usr/lib/ruby/vendor_ruby/bundler/setup.rb:17
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/dh/passenger/lib/phusion_passenger/loader_shared_helpers.rb:263:in `run_load_path_setup_code'
/dh/passenger/lib/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
/dh/passenger/lib/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
/dh/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
/dh/passenger/helper-scripts/rack-preloader.rb:158

我四处寻找修复并找到了这个可能的答案,将 Gemfile 编辑为如下所示:

group :doc do
  gem 'sdoc', '~> 0.4.0'
end

现在我收到一个新错误:

Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 4.2.0) depends on
  bundler (< 2.0, >= 1.3.0)

Current Bundler version:
  bundler (1.0.15)
(Bundler::VersionConflict)
/usr/lib/ruby/vendor_ruby/bundler/resolver.rb:129:in `resolve'
/usr/lib/ruby/vendor_ruby/bundler/resolver.rb:127:in `catch'
/usr/lib/ruby/vendor_ruby/bundler/resolver.rb:127:in `resolve'
/usr/lib/ruby/vendor_ruby/bundler/definition.rb:151:in `resolve'
/usr/lib/ruby/vendor_ruby/bundler/definition.rb:90:in `specs'
/usr/lib/ruby/vendor_ruby/bundler/definition.rb:135:in `specs_for'
/usr/lib/ruby/vendor_ruby/bundler/definition.rb:124:in `requested_specs'
/usr/lib/ruby/vendor_ruby/bundler/environment.rb:23:in `requested_specs'
/usr/lib/ruby/vendor_ruby/bundler/runtime.rb:11:in `setup'
/usr/lib/ruby/vendor_ruby/bundler.rb:107:in `setup'
/usr/lib/ruby/vendor_ruby/bundler/setup.rb:17
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/dh/passenger/lib/phusion_passenger/loader_shared_helpers.rb:263:in `run_load_path_setup_code'
/dh/passenger/lib/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
/dh/passenger/lib/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
/dh/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
/dh/passenger/helper-scripts/rack-preloader.rb:158

然而,当我在终端中运行命令bundler -v时,它returns Bundler version 1.7.12

那么如何让 Passenger 认识到我有这个更新的 Bundler?

感谢您的帮助。

我的 Gemfile:

source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'

# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
group :doc do
  gem 'sdoc', '~> 0.4.0'
end

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

根据 http://wiki.dreamhost.com/Passenger#A_couple_of_technical_notes 只有 Ruby 1.8.7 在 DreamHost 共享主机上受支持。该信息的日期为 2011 年 8 月 18 日,但从您的错误消息来看,情况似乎仍然如此。

线索是/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb等路径中的“1.8”以及错误syntax error, unexpected ':', expecting $end(因为Ruby1.8不支持key: value散列语法, 只有 :key => value).

根据上面链接的 wiki 页面,您需要使用私人服务器来安装您自己的 Ruby 版本,但联系 DreamHost 支持人员询问他们的升级计划可能也是值得的。 Ruby 1.8.7 已结束,不再接收安全更新。