Rails 应用程序 rake db:迁移中止 - 语法错误

发布于 2024-12-26 13:32:52 字数 2235 浏览 0 评论 0原文

运行 rake db:migrate 时不断收到以下错误:

rake aborted!
syntax error on line 18, col 9: `   adapter: mysql'

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

这是我的 database.yml 文件:

# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
    adapter: mysql
    database: DATABASENAME
    username: USERNAME
    password: PASSWORD

如果我删除生产设置以尝试在开发环境中纠正问题,则会收到以下错误:

rake aborted!
no such file to load -- openid/store/filesystem

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

我认为这是由某种 gem 依赖性问题,所以这是我的 Gemfile:

source 'http://rubygems.org'

gem 'rails', '~> 3.1.0'

# Deploy with Capistrano
gem 'capistrano'
gem 'capistrano-ext'
gem 'devise'
gem "configatron"
gem "post_commit"
gem 'will_paginate', '> 3.0'
gem "configatron"
gem "declarative_authorization"
gem "aasm"
gem "gravatar_image_tag"
gem "polish"
gem "simple_form"
gem "i18n_generators"
gem "i18n_routing"
gem "delayed_job"
gem "oauth2"
gem "fb_graph"
gem "omniauth"
gem "paperclip", "~> 2.4"
gem "meta_search"

group :development do
  # To use debugger
  # gem 'ruby-debug'
  # gem 'ruby-debug19' if you are using ruby 1.9.2 or higher
  gem 'sqlite3-ruby', :require => "sqlite3"
  gem "nifty-generators"
end

group :production do
  gem 'pg'
  gem 'mysql'
end

group :development, :test do
  gem 'sqlite3'
end

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :test do
  gem 'webrat'
  gem 'rspec'
  gem 'rspec-rails'
end
gem "mocha", :group => :test

我无法弄清楚为什么 A)它不接受生产信息和 B)为什么我不断收到 no such file to load 错误。

任何帮助表示赞赏。

I keep getting the following error when running rake db:migrate:

rake aborted!
syntax error on line 18, col 9: `   adapter: mysql'

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

This is my database.yml file:

# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
    adapter: mysql
    database: DATABASENAME
    username: USERNAME
    password: PASSWORD

If I remove the production settings to try and rectify the issue in my development environment, I get the following error:

rake aborted!
no such file to load -- openid/store/filesystem

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

Which I believe is caused by some sort of gem dependancy problem, so here is my Gemfile:

source 'http://rubygems.org'

gem 'rails', '~> 3.1.0'

# Deploy with Capistrano
gem 'capistrano'
gem 'capistrano-ext'
gem 'devise'
gem "configatron"
gem "post_commit"
gem 'will_paginate', '> 3.0'
gem "configatron"
gem "declarative_authorization"
gem "aasm"
gem "gravatar_image_tag"
gem "polish"
gem "simple_form"
gem "i18n_generators"
gem "i18n_routing"
gem "delayed_job"
gem "oauth2"
gem "fb_graph"
gem "omniauth"
gem "paperclip", "~> 2.4"
gem "meta_search"

group :development do
  # To use debugger
  # gem 'ruby-debug'
  # gem 'ruby-debug19' if you are using ruby 1.9.2 or higher
  gem 'sqlite3-ruby', :require => "sqlite3"
  gem "nifty-generators"
end

group :production do
  gem 'pg'
  gem 'mysql'
end

group :development, :test do
  gem 'sqlite3'
end

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :test do
  gem 'webrat'
  gem 'rspec'
  gem 'rspec-rails'
end
gem "mocha", :group => :test

I can't work out why A) It's not accepting the production info and B) why I keep getting the no such file to load error.

Any help is appreciated.

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

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

发布评论

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

评论(1

乖不如嘢 2025-01-02 13:32:53

你的标签是不同的。

空白缩进用于表示结构;但是制表符绝对不允许作为缩进。

请尝试以下操作:

# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: mysql
  database: DATABASENAME
  username: USERNAME
  password: PASSWORD

Your tabbing is different.

Whitespace indentation is used to denote structure; however tab characters are never allowed as indentation.

Try the following:

# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

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