未初始化常量 MysqlCompat::MysqlRes 与 RubyMine

发布于 2024-10-25 04:59:34 字数 1271 浏览 0 评论 0原文

通过 RubyMine 3.1 运行开发环境时出现此错误。 mysql gem 已附加,它在 Bundler 上运行。

Gemfile

gem "mysql",         "2.8.1"

Gem 是使用以下方式安装的:

gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

通过 Bundler 配置

=>启动 WEBrick
=> Rails 2.3.10 应用程序从 http://0.0.0.0:3000 启动 [2011-03-21
13:36:43] 信息 WEBrick 1.3.1
[2011-03-21 13:36:43] INFO ruby​​ 1.8.7
(2011-02-18) [i686-darwin10.7.1]
[2011-03-21 13:36:43] 信息
WEBrick::HTTPServer#start: pid=625
端口=3000
=>使用 -d 调用来分离
=> Ctrl-C 关闭服务器 /!\ FAILSAFE /!\ Mon Mar 21 13:36:46
-1000 2011 状态:500 内部服务器错误未初始化常量
MysqlCompat::MysqlRes

系统正在使用 RVM、gemset 和 ruby​​ 1.8.7、rails 2.3.10 和 mysql 5.5.10

我可以通过终端很好地运行 Rails 控制台和服务器

ruby script/server
ruby script/console

问题似乎与尝试运行 Rails 无关通过 RubyMine 进行控制台和服务器。可能有一些我丢失并且没有看到的小配置设置。

RubyMine 配置为使用 RVM 中的 ruby​​ 和 gemset,并且也设置为忽略全局 gemset。

我见过的大多数解决方案都要求降级到 mysql 5.1,但这似乎不是真正的解决方案,因为我可以从终端完美运行 Rails 控制台和服务器。

I'm getting this error when running the development environment through RubyMine 3.1. The mysql gem is attached, it's running off of Bundler.

Gemfile

gem "mysql",         "2.8.1"

Gem was installed using:

gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

via Bundler config.

=> Booting WEBrick
=> Rails 2.3.10 application starting on http://0.0.0.0:3000 [2011-03-21
13:36:43] INFO WEBrick 1.3.1
[2011-03-21 13:36:43] INFO ruby 1.8.7
(2011-02-18) [i686-darwin10.7.1]
[2011-03-21 13:36:43] INFO
WEBrick::HTTPServer#start: pid=625
port=3000
=> Call with -d to detach
=> Ctrl-C to shutdown server /!\ FAILSAFE /!\ Mon Mar 21 13:36:46
-1000 2011 Status: 500 Internal Server Error uninitialized constant
MysqlCompat::MysqlRes

System is using RVM, gemset and ruby 1.8.7, rails 2.3.10, and mysql 5.5.10

I can run the Rails console and server fine through Terminal via

ruby script/server
ruby script/console

Problem seems to be isolated to just trying to run the Rails console and server through RubyMine. There's likely some small configuration setting that I'm missing and haven't seen.

RubyMine is configured to use the ruby and gemset from RVM and it's set to ignore the global gemset as well.

Most solutions I've seen state to downgrade to mysql 5.1, but that doesn't seem to be the real solution as I can run the Rails console and server perfectly fine from the Terminal.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷血 2024-11-01 04:59:35

我和约翰·王谈过,他告诉了我,但他正在解决这个问题。

RubyMine 是一个 GUI,因此它不会获取为 OS X 中的终端定义的环境设置。请参阅此 Jetbrains 文档以更好地了解其工作原理:http://devnet.jetbrains.net/docs/DOC-1160

上面的链接中用于更改环境变量的工具的链接是错误的。我使用过以下内容:
http://www.epikentros.net/Main/Mac_Software.html

您需要确保您在终端(~/.profile 或 ~/.bash_profile)和 OS X GUI(使用上面链接中提供的工具)上都设置了 DYLD_LIBRARY_PATH(需要在此处定义 mysql lib 目录)和 PATH (将已经为终端定义的值复制到 OS X GUI)

这应该可以解决问题。如果您有任何其他问题,请检查您是否对 MySQL 和 MySQL Gem 使用相同的架构(i386 或 x86_64)

I've spoke with John Wang and he told me but was going on with this issue.

RubyMine is a GUI, so it doesn't pick up the env settings defined for the terminal in the OS X. See this Jetbrains doc to understand better how this works: http://devnet.jetbrains.net/docs/DOC-1160

The link to the tool that it's used to change the Enviroment Variables is wrong on the link above. I've used the following:
http://www.epikentros.net/Main/Mac_Software.html

You need to make sure that you have setting on both the Terminal (~/.profile or ~/.bash_profile) and the OS X GUI (using the tool provided in the link above) for DYLD_LIBRARY_PATH (needs to have the mysql lib directory defined here) and PATH (copy the values already defined for the terminal to the OS X GUI)

This should make the trick. If you have any additional problem, check that you are using the same Architecture for the MySQL and the MySQL Gem (i386 or x86_64)

追我者格杀勿论 2024-11-01 04:59:35

刚刚遇到了一个非常相似的问题:

  • OSX Leopard
  • MySQL 5.1
  • Rails 2.3.11

script/console and script/server work OK,但我的规格出错了

未初始化常量 MysqlCompat::MysqlRes

解决方案似乎是使用mysql2而不是mysql。不要忘记更改database.yml中的连接适配器

Just been having a very similar problem:

  • OSX Leopard
  • MySQL 5.1
  • Rails 2.3.11

script/console and script/server worked OK, but my specs were erroring with

uninitialized constant MysqlCompat::MysqlRes

The solution seems to be to use mysql2 instead of mysql. Don't forget to change the connection adaptor in database.yml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文