6

我正在尝试使用 Phusion 乘客和 RVM 在 Ubuntu 生产服务器上部署 Rails 3 应用程序。我已成功安装 Phusion 乘客,但在浏览器上访问服务器时出现以下错误:

Ruby (Rack) application could not be started

These are the possible causes:

There may be a syntax error in the application's code. Please check for such errors and fix them.

A required library may not installed. Please install all libraries that this application requires.

The application may not be properly configured. Please check whether all configuration files are written correctly, fix any incorrect configurations, and restart this application.

A service that the application relies on (such as the database server or the Ferret search engine server) may not have been started. Please start that service.

有关错误的更多信息可能已写入应用程序的日志文件。请检查它以便分析问题。

错误消息:US-ASCII 中的无效字节序列

异常类:ArgumentError

这是回溯:

0   /usr/lib/ruby/1.9.1/rubygems/specification.rb   575     in `normalize_yaml_input'
1   /usr/lib/ruby/1.9.1/rubygems/specification.rb   487     in `from_yaml'
2   /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler.rb   294     in `block in load_gemspec_uncached'
3   /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler.rb   291     in `chdir'
4   /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler.rb   291     in `load_gemspec_uncached'
5   /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler.rb   282     in `load_gemspec'
6   /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/source.rb    411     in `block in load_spec_files'
7   /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/source.rb    410     in `each'
8   /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/source.rb    410     in `load_spec_files'
9   /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/source.rb    799     in `load_spec_files'
10  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/source.rb    381     in `local_specs'
11  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/source.rb    774     in `specs'
12  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/lazy_specification.rb    53  in `__materialize__'
13  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/spec_set.rb  86  in `block in materialize'
14  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/spec_set.rb  83  in `map!'
15  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/spec_set.rb  83  in `materialize'
16  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/definition.rb    113     in `specs'
17  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/definition.rb    158     in `specs_for'
18  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/definition.rb    147     in `requested_specs'
19  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/environment.rb   23  in `requested_specs'
20  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/runtime.rb   11  in `setup'
21  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler.rb   116     in `setup'
22  /var/lib/gems/1.9.1/gems/bundler-1.2.2/lib/bundler/setup.rb     17  in `'
23  /usr/lib/ruby/1.9.1/rubygems/custom_require.rb  59  in `require'
24  /usr/lib/ruby/1.9.1/rubygems/custom_require.rb  59  in `rescue in require'
25  /usr/lib/ruby/1.9.1/rubygems/custom_require.rb  35  in `require'
26  /home/juniormarketing/trndclone/config/setup_load_paths.rb  14  in `'
27  /usr/lib/ruby/1.9.1/rubygems/custom_require.rb  36  in `require'
28  /usr/lib/ruby/1.9.1/rubygems/custom_require.rb  36  in `require'
29  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/utils.rb    301     in `prepare_app_process'
30  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/rack/application_spawner.rb     156     in `block in initialize_server'
31  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/utils.rb    563     in `report_app_init_status'
32  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/rack/application_spawner.rb     154     in `initialize_server'
33  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server.rb  204     in `start_synchronously'
34  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server.rb  180     in `start'
35  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/rack/application_spawner.rb     129     in `start'
36  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/spawn_manager.rb    253     in `block (2 levels) in spawn_rack_application'
37  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server_collection.rb   132     in `lookup_or_add'
38  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/spawn_manager.rb    246     in `block in spawn_rack_application'
39  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server_collection.rb   82  in `block in synchronize'
40      prelude>    10:in `synchronize'
41  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server_collection.rb   79  in `synchronize'
42  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/spawn_manager.rb    244     in `spawn_rack_application'
43  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/spawn_manager.rb    137     in `spawn_application'
44  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/spawn_manager.rb    275     in `handle_spawn_application'
45  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server.rb  357     in `server_main_loop'
46  /var/lib/gems/1.9.1/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server.rb  206     in `start_synchronously'
47  /var/lib/gems/1.9.1/gems/passenger-3.0.18/helper-scripts/passenger-spawn-server     99  in `'

据我了解,启动应用程序时会调用 Bundler.setup() 并偶然发现一个非 ascii 字符。这是有道理的,因为该应用程序是针对法国网站的,但我确保# -*- encoding : utf-8 -*-在每个包含非 ascii 字符的源文件之上添加。

这是我的 Gemfile :

# -*- encoding : utf-8 -*-
source 'https://rubygems.org'

gem 'rails', '3.2.7'
gem "will_paginate", :git => "https://github.com/p7r/will_paginate.git", :branch => "rails3"
gem "lorem"
gem 'paperclip'
gem 'rails3-jquery-autocomplete'
gem 'spreadsheet'


group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.10.0'
  gem 'faker', '0.3.1', :require => false
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.4'
  gem 'coffee-rails', '3.2.2'
  gem 'uglifier', '1.2.3'
  gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
  gem 'jquery-ui-rails'
end

gem 'jquery-rails', '2.0.2'

group :test do
  gem 'capybara', '1.1.2'
    gem 'factory_girl_rails', '1.0'
  gem 'webrat'
  gem 'cucumber-rails', '1.2.1', :require => false
  gem 'database_cleaner', '0.7.0'
end

group :production do
  #gem 'pg', '0.12.2'
end

关于出了什么问题的任何想法?

4

4 回答 4

20

我在这篇文章中找到了解决方案:When run bundle get invalid byte sequence in US-ASCII

我所要做的就是将这个添加到我的 Gemfile 之上:

if RUBY_VERSION =~ /1.9/
  Encoding.default_external = Encoding::UTF_8
  Encoding.default_internal = Encoding::UTF_8
end
于 2012-11-30T18:29:46.693 回答
4

我在运行 ruby​​ 1.9.3 的 Rails 2.3 应用程序中遇到了这个问题。一种解决方案是降级到 1.8.7,但这不是您真正想要的。如果在运行 rails 应用程序时发生此错误(例如浏览器显示错误消息),请将这些行放入您的 config/environment.rb (我将它们放在 RAILS_GEM_VERSION 行之后):

    if RUBY_VERSION =~ /1.9/
        Encoding.default_external = Encoding::UTF_8
        Encoding.default_internal = Encoding::UTF_8
    end

并重新启动应用程序(我总是重新启动整个 apache,还有其他方法)。

于 2013-03-01T18:46:30.020 回答
2

我遇到了这个问题,原来是消息文本中的引号不合适。

卷曲其中之一:'

于 2013-05-22T02:45:50.190 回答
0

另一种选择是将-E命令行标志传递给 ruby​​:

export RUBYOPT=-EUTF-8:UTF-8

在尝试恢复针对运行 10 年历史版本 Debian 的嵌入式设备的旧项目时遇到。

于 2021-03-07T19:29:00.927 回答