【问题标题】:Rails app rake db:migrate aborted - syntax errorRails app rake db:migrate aborted - 语法错误
【发布时间】:2012-01-10 19:13:35
【问题描述】:

我在运行 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 错误。

感谢任何帮助。

【问题讨论】:

    标签: ruby-on-rails database gem rake gemfile


    【解决方案1】:

    你的标签是不同的。

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

    尝试以下方法:

    # 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
    

    【讨论】:

    • 很好,但我仍然收到“没有要加载的文件--openid/store/filesystem”错误。
    • 尝试运行bundle exec rake db:migrate
    • 看来要来回解决这个问题,我为这个问题设置了一个聊天室。 chat.stackoverflow.com/rooms/6591/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-15
    • 2023-03-29
    • 1970-01-01
    • 2018-10-06
    相关资源
    最近更新 更多