ubuntu上rails mysql gem问题
Ruby on Rails: 我想调用本地主机上的控制器,但服务器说!!!缺少 mysql gem。将其添加到您的 Gemfile 中: gem 'mysql', '2.8.1'
问题是什么?当我点击“gem list”命令时,我得到了一个包含 mysql 2.8.1 的列表。所以宝石已安装!为什么它看不到 webrick ?
谢谢。
Ruby on Rails:
I would like to call a controller on the localhost, but the server said !!! Missing the mysql gem. Add it to your Gemfile: gem 'mysql', '2.8.1'
The problem ? When I hit 'gem list' command then I got a list witch is containing the mysql 2.8.1 . So the gem is INSTALLED ! WHY can't it see by the webrick ?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将行
gem 'mysql', '2.8.1'
添加到您的 Gemfile 中。然后在 Rails 项目的根文件夹中输入bundle install
。听起来您好像忘了运行捆绑程序。MySQL gem 确实需要本机 C 扩展。因此,您需要确保已安装所有开发库。
在 Ubuntu 中,您可以执行以下操作:
如果您使用的是 rvm,请不要将 gems 安装为 sudo。
为了确保安全,您可能还想尝试删除 Gemfile.lock,然后重新运行
bundle install
You need to add the line
gem 'mysql', '2.8.1'
to your Gemfile. Then typebundle install
in the root folder of your Rails project. It sounds like you forgot to run bundler.The MySQL gem does require native C extensions. So you'll need to make sure that you have all the development libraries installed.
In Ubuntu you can do something like this:
If you are using rvm, do not install gems as sudo.
Just to make sure, you might also want to try removing your Gemfile.lock and then re-running
bundle install
看来您正在使用 Rails 3,它使用捆绑器来加载所有需要的 gem。您应该按照错误消息的指示将 gem 添加到 Gemfile 中,以便加载它。
查看捆绑程序项目页面,了解有关 gem 依赖工具以及如何将其与 Rails 一起使用的更多信息。 http://gembundler.com/rails3.html
It seems that you are using Rails 3 which uses bundler to load all needed gem. You should add the gem to your Gemfile as instructed by the error message so that it will be loaded.
Checkout the bundler project page for more information about the gem dependency tool and how to use it with Rails. http://gembundler.com/rails3.html