gpt4 book ai didi

mysql + ruby​​ on rails + linux mint = 不起作用

转载 作者:可可西里 更新时间:2023-11-01 08:29:12 26 4
gpt4 key购买 nike

我正在使用 Linux Mint,并且刚开始学习 Ruby on Rails。我正在关注 Lynda.com 教程,但在设置 mysql 时遇到了困难。我尝试了人们之前提出的所有问题,但找不到解决方案。让我解释。我已正确安装所有东西。

matth@MatijaComp ~ $ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
matth@MatijaComp ~ $ rails -v
Rails 4.2.3
matth@MatijaComp ~ $ mysql --version
mysql Ver 14.14 Distrib 5.5.44, for debian-linux-gnu (x86_64) using readline 6.3

当我使用“-d mysql”启动项目时,启动我的 mysql 服务器,运行“rake db:create”,配置 database.yml 文件以填充密码,然后简单地执行“rails server”。希望我解释了我所有的步骤,也许我忘记了什么,但我想我已经尝试了一切。设置密码不是问题。 (没有 mysql rails 服务器工作正常)

[2015-07-25 02:58:46] INFO  WEBrick 1.3.1
[2015-07-25 02:58:46] INFO ruby 2.2.2 (2015-04-13) [x86_64-linux]
[2015-07-25 02:58:46] INFO WEBrick::HTTPServer#start: pid=11689 port=3000


Started GET "/" for 127.0.0.1 at 2015-07-25 02:58:48 +0200

Gem::LoadError (Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).):
activerecord (4.2.3) lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec'
activerecord (4.2.3) lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
activerecord (4.2.3) lib/active_record/connection_handling.rb:50:in `establish_connection'
activerecord (4.2.3) lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
activesupport (4.2.3) lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
activesupport (4.2.3) lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
activesupport (4.2.3) lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
activesupport (4.2.3) lib/active_support/lazy_load_hooks.rb:44:in `each'
activesupport (4.2.3) lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
activerecord (4.2.3) lib/active_record/base.rb:315:in `<module:ActiveRecord>'
activerecord (4.2.3) lib/active_record/base.rb:26:in `<top (required)>'
activerecord (4.2.3) lib/active_record/migration.rb:383:in `connection'
activerecord (4.2.3) lib/active_record/migration.rb:370:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.3) lib/active_support/callbacks.rb:84:in `run_callbacks'
actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.2.1) lib/web_console/middleware.rb:39:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.3) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.3) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.3) lib/action_dispatch/middleware/static.rb:116:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.3) lib/rails/engine.rb:518:in `call'
railties (4.2.3) lib/rails/application.rb:165:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
/usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

无论我尝试做什么,它总是显示此错误。即使我删除了 mysql 的 gems,在 database.yml 中注释数据库,它仍然不想工作。谢谢!

最佳答案

首先,尝试运行 bundle exec rails s 并查看它是否给出不同的结果。如果它提示你没有运行 bundler,首先运行 bundle installGem::LoadError 通常意味着您的 Gemfile 有问题,有时——例如,如果您通过系统包管理器或安装程序安装了 Ruby——rails二进制文件将链接到您的系统 gem 而不是您项目的 gem。使用 bundle exec 作为命令前缀可确保它们在当前 Gemfile 的上下文中运行。

关于mysql + ruby​​ on rails + linux mint = 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31621976/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com