如何让Phusion Passenger识别正确版本的bundler?

时间:2015-02-05 02:08:30

标签: ruby-on-rails ruby passenger bundler gemfile

首先,我是一个编程新手,甚至是最新的Ruby / Rails新手。我有一个我要上传的网站(http://suzyogi.com)。大多数页面只是HTML和CSS以及一些jQuery,但我想包含一个博客,所以我在Rails 4.2.0中构建它。我使用DreamHost来托管我的网站,他们对Rails应用程序的说明告诉我在Web Options:Passenger(仅限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时,它会返回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

1 个答案:

答案 0 :(得分:0)

根据http://wiki.dreamhost.com/Passenger#A_couple_of_technical_notes,DreamHost共享主机仅支持Ruby 1.8.7。该信息的日期为2011年8月18日,但是根据您的错误消息,情况仍然如此。

线索是/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb等路径中的“1.8”以及错误syntax error, unexpected ':', expecting $end(因为Ruby 1.8不支持key: value哈希语法,只有{{1} })。

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