由于 mysql2 或 mysql gems,无法在 Debian 上启动 Mongrel(或Passenger)

Posted

技术标签:

【中文标题】由于 mysql2 或 mysql gems,无法在 Debian 上启动 Mongrel(或Passenger)【英文标题】:Unable to start Mongrel (or Passenger) on Debian due to mysql2 or mysql gems 【发布时间】:2011-07-03 06:50:31 【问题描述】:

我最初在 Super User 上发布了这个,但现在认为它应该在这里......

我正在尝试将我的 RoR webapp 移植到 DreamHost VPS。我已经从 1.8.7 升级了 VPS --> Ruby 1.9.2,并且正在使用 Rails 3.0.1 和 mysql2 (0.2.6) gem。尝试启动 mongrel 时出现以下错误:

/usr/bin/ruby1.8:符号查找错误:/home/USERNAME/.gems/gems/mysql2-0.2.6/lib/mysql2/mysql2.so:未定义符号:rb_intern2

...所以我尝试改用 mysql (2.8.1) gem 并得到以下错误:

Mysql 参数类型错误(预期的 Struct)(TypeError)

0 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/mysql_adapter.rb 600 在real_connect' 1 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/mysql_adapter.rb 600 inconnect' 2 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/mysql_adapter.rb 164 在initialize' 3 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/mysql_adapter.rb 36 innew' 4 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/mysql_adapter.rb 36 in mysql_connection' 5 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb 230 insend' 6 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb 230 在new_connection' 7 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb 238 incheckout_new_connection' 8 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb 194 in checkout' 9 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb 190 inloop' 10 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb 190 在checkout' 11 /usr/lib/ruby/1.8/monitor.rb 242 insynchronize' 12 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb 189 in checkout' 13 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb 96 inconnection' 14 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb 318 在retrieve_connection' 15 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb 97 inretrieve_connection' 16 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb 89 在connection' 17 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/associations.rb 1804 increate_has_and_belongs_to_many_reflection' 18 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/associations.rb 1411 在has_and_belongs_to_many' 19 /home/USERNAME/.gems/gems/activerecord-3.0.1/lib/active_record/autosave_association.rb 137 inhas_and_belongs_to_many' 20 /home/USERNAME/portfoliofinearts.ca/farr/app/models/project.rb 3 21 /home/USERNAME/.gems/gems/activesupport-3.0.1/lib/active_support/dependencies.rb 239 在require' 22 /home/USERNAME/.gems/gems/activesupport-3.0.1/lib/active_support/dependencies.rb 239 inrequire' 23 /home/USERNAME/.gems/gems/activesupport-3.0.1/lib/active_support/dependencies.rb 227 in load_dependency' 24 /home/USERNAME/.gems/gems/activesupport-3.0.1/lib/active_support/dependencies.rb 239 inrequire' 25 /home/USERNAME/.gems/gems/activesupport-3.0.1/lib/active_support/dependencies.rb 346 在require_or_load' 26 /home/USERNAME/.gems/gems/activesupport-3.0.1/lib/active_support/dependencies.rb 300 independ_on' 27 /home/USERNAME/.gems/gems/activesupport-3.0.1/lib/active_support/dependencies.rb 216 在require_dependency' 28 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/engine.rb 138 ineager_load!' 29 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/engine.rb 137 在each' 30 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/engine.rb 137 ineager_load!' 31 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/engine.rb 135 在each' 32 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/engine.rb 135 ineager_load!' 33 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/application.rb 108 在eager_load!' 34 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/application/finisher.rb 41 35 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/initializable.rb 25 ininstance_exec' 36 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/initializable.rb 25 在run' 37 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/initializable.rb 50 inrun_initializers' 38 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/initializable.rb 49 在each' 39 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/initializable.rb 49 inrun_initializers' 40 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/application.rb 134 在initialize!' 41 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/application.rb 77 insend' 42 /home/USERNAME/.gems/gems/railties-3.0.1/lib/rails/application.rb 77 在method_missing' 43 /home/USERNAME/mydomain.com/test_app/config/environment.rb 10 44 /usr/lib/ruby/1.8/rubygems/custom_require.rb 31 ingem_original_require' 45 /usr/lib/ruby/1.8/rubygems/custom_require.rb 31 在require' 46 config.ru 3 47 /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb 46 ininstance_eval' 48 /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb 46 在initialize' 49 config.ru 1 innew' 50 配置.ru 1

我更喜欢使用 mysql2,所以这是我正在寻找的首选解决方案,但我肯定会感谢您就这两个问题提供意见。

我在我的开发环境(即 windows)中没有遇到任何类似的问题

【问题讨论】:

当您尝试运行像 bundle list 这样的捆绑程序命令时会发生什么情况? @Steven Xu - bundle list 工作。虽然我应该补充一点,有一个警告: /usr/lib/ruby/gems/1.8/specifications/archive-tar-minitar-0.5.1.gemspec:12: invalid multibyte char (UTF-8) /usr /lib/ruby/gems/1.8/specifications/archive-tar-minitar-0.5.1.gemspec:12:语法错误,意外的 tIDENTIFIER,期待关键字_end ...d 严重依赖 Mauricio Fernández 在 rpa-base 中的实现... - 虽然我将尝试卸载 Ruby 1.8,如下所述 Ruby 1.8 上的卸载确实消除了上述警告。 【参考方案1】:

您提到您正在运行 Ruby 1.9.2,但您的错误转储看起来像是在运行 Ruby 1.8。我不确定这是否会导致问题,但这似乎是一个潜在问题。

我会卸载 ruby​​1.8 看看它是否能解决任何问题。

sudo apt-get remove ruby1.8

【讨论】:

以上是关于由于 mysql2 或 mysql gems,无法在 Debian 上启动 Mongrel(或Passenger)的主要内容,如果未能解决你的问题,请参考以下文章

错误:安装 mysql2 时出错:错误:无法在 AWS Linux 上构建 gem 原生扩展

错误:安装 mysql2 时出错:错误:无法构建 gem 原生扩展

无法安装 mysql2 gem

无法在 Bigsur 上安装 mysql2 Gem

无法安装旧的 mysql2 gem

错误:无法构建 gem 本机扩展(rails 3.2.3 上的 mysql2)