启动 Ruby on Rails 服务器时出现问题

发布于 2024-11-02 23:08:59 字数 1759 浏览 0 评论 0原文

我对 Ruby、Rails 和 MySQL 完全陌生。我正在尝试启动一个新项目并启动默认服务器,但收到下面列出的错误。我安装了以下内容:

  • Ruby:ruby 1.8.7(2008-08-11 patchlevel 72)[i686-darwin9.8.0]
  • Rails:rails(3.0.7)
  • MySql:mysql2(0.2.7)
  • RubyGems:1.7.2

错误如下:

$ rails s
/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlsym(0x251680, Init_mysql2): symbol not found - /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle (LoadError)
    from /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
    from /Users/nelsonwittwer/Sites/simple_cms/config/application.rb:7
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
    from script/rails:6:in `require'
    from script/rails:6

我不太确定从这里该去哪里,并且希望您能提供任何帮助。谢谢。

I am completely new to Ruby, Rails, and MySQL. I am trying to start a new project and start the default server and I get the error listed below. I have the following installed:

  • Ruby : ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.8.0]
  • Rails: rails (3.0.7)
  • MySql: mysql2 (0.2.7)
  • RubyGems: 1.7.2

Error is below:

$ rails s
/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlsym(0x251680, Init_mysql2): symbol not found - /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle (LoadError)
    from /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
    from /Users/nelsonwittwer/Sites/simple_cms/config/application.rb:7
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
    from script/rails:6:in `require'
    from script/rails:6

I'm not quite sure where to go from here and would love any help you may have. Thank you.

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

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

发布评论

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

评论(2

GRAY°灰色天空 2024-11-09 23:08:59

确保您的 ruby​​ 系统中安装了 mysql2 gem。要检查它,请使用gem list -d。如果找不到 mysql2 gem,在 ubuntu 中,您必须在安装 mysql2 gem 之前安装以下库:

# sudo apt-get install libmysqlclient15-dev  (for mysql-5.*)

# sudo apt-get install  libmysql-ruby  ruby-dev

之后,您可以使用 sudo gem install mysql2 进行安装,并确保 database.yml 中的适配器值为 mysql2。另一个问题是库未加载,如果问题库未加载:尝试使用 mysql2 gem 在 OS X 10.6 上运行“rails 服务器”时出现 libmysqlclient.16.dylib 错误

make sure you have mysql2 gem installed in your ruby system. To check it use gem list -d. If mysql2 gem not found, in ubuntu you must install following library before install mysql2 gem :

# sudo apt-get install libmysqlclient15-dev  (for mysql-5.*)

# sudo apt-get install  libmysql-ruby  ruby-dev

After that, you could install with sudo gem install mysql2 and make sure your adapter value inside database.yml is mysql2. Another issue is Library not loaded, you can view this link if that the problem Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem

清秋悲枫 2024-11-09 23:08:59

您需要在系统上安装 mySQL gem。

现在,不要使用 apt-get 来安装它,因为 apt-get 通常具有旧版本的 ruby​​ 库。

另外,我强烈建议您在开始时使用 SQLite。
也非常有帮助(在 railstutorial 中进行了描述)

而且,Bundler在基于 ubuntu/debian 的发行版上 (并且您确实想要使用 MySQL):

如果您使用的是 ruby​​ 1.8.x(使用 ruby -v 检查):

sudo apt-get install libmysqlclient-dev
sudo apt-get install ruby-dev
sudo gem install mysql2 

如果您使用的是 ruby​​ 1.9.x:

sudo apt-get install libmysqlclient-dev
sudo apt-get install ruby1.9.1-dev
sudo gem install mysql2

You need the mySQL gem installed on your system.

Now, DO NOT use apt-get to install this, as apt-get often has old versions of the ruby libraries.

Also, I would highly recommend you use SQLite when starting out.
And, Bundler is also very helpful (described in the railstutorial)

On ubuntu/debian based distributions (and you really want to use MySQL):

If you are using ruby 1.8.x (check with ruby -v):

sudo apt-get install libmysqlclient-dev
sudo apt-get install ruby-dev
sudo gem install mysql2 

If you are using ruby 1.9.x:

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