Rails app rake db:migrate aborted - 语法错误 [英] Rails app rake db:migrate aborted - syntax error

查看:295
本文介绍了Rails app rake db:migrate aborted - 语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行rake db时,我会收到以下错误:migrate:

  rake aborted! 
第18行,第9列的语法错误:`adapter:mysql'

任务:TOP => db:migrate =>环境
(通过使用--trace运行任务来查看完整跟踪)

这是我的数据库.yml文件:

 #SQLite version 3.x 
#gem install sqlite3-ruby Leopard)
开发:
适配器:sqlite3
数据库:db / development.sqlite3
池:5
超时:5000

#警告:当您运行rake时,定义为test的数据库将被清除,
#从您的开发数据库中重新生成。
#不要将此数据库设置为与开发或生产相同。
test:
adapter:sqlite3
database:db / test.sqlite3
pool:5
timeout:5000

production:
adapter:mysql
数据库:DATABASENAME
用户名:USERNAME
密码:PASSWORD

如果我删除生产设置,尝试并纠正我的开发环境中的问题,我得到以下错误:

 耙子中止! 
没有这样的文件加载 - openid / store / filesystem

任务:TOP => db:migrate =>环境
(通过使用--trace运行任务来查看完整跟踪)

由于某种类型的gem依赖性问题,所以这里是我的Gemfile:

  source'http://rubygems.org'

gem'rails','〜> 3.1.0'

#使用Capistrano部署
gem'capistrano'
gem'capistrano-ext'
gem'devise'
gemconfigatron
gempost_commit
gem'will_paginate','> 3.0'
gemconfigatron
gemdeclarative_authorization
gemaasm
gemgravatar_image_tag
gempolish
gemsimple_form
gemi18n_generators
gemi18n_routing
gemdelayed_job
gemoauth2
gemfb_graph
gemomniauth
gempaperclip,〜> 2.4
gemmeta_search

group:development do
#使用调试器
# debug'
#gem'ruby-debug19'如果你使用ruby 1.9.2或更高版本
gem'sqlite3-ruby',:require => sqlite3
gemnifty-generators
end

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

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

#捆绑本地环境的gem。确保
#在这个组中测试只有宝石,所以他们的生成器
#和rake任务在开发模式下可用:
group:test do
gem'webrat'
gem'rspec'
gem'rspec-rails'
end
gemmocha,:group => :test

我无法弄清楚为什么A)它不接受生产信息和B)

解决方案

任何帮助都可以加载错误。



您的标签是不同的。



空格缩进用于表示结构;但



请尝试以下操作:

 #SQLite version 3.x 
#gem install sqlite3-ruby(在OS X Leopard上不需要)
开发:
适配器:sqlite3
数据库:db /development.sqlite3
pool:5
timeout:5000

#警告:定义为test的数据库将被清除,
#开发数据库时运行rake。
#不要将此数据库设置为与开发或生产相同。
test:
adapter:sqlite3
database:db / test.sqlite3
pool:5
timeout:5000

production:
adapter:mysql
数据库:DATABASENAME
用户名:USERNAME
密码:PASSWORD


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.

解决方案

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

这篇关于Rails app rake db:migrate aborted - 语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆