【问题标题】:Don't know how to build rake db:migrate on Ubuntu natty?不知道如何在 Ubuntu natty 上构建 rake db:migrate?
【发布时间】:2011-10-23 14:21:07
【问题描述】:

我不确定如何使用 Capistrano 部署应用程序,但我想我会尝试至少在我的部署服务器上加载我需要的所有文件,所以我在 Github 上做了一个 git pull 并使用安装了所有依赖项捆绑安装。我有 RVM 1.6.32 在 Ruby 1.9.2p180 和 Rails 3.0.9 中运行,当我运行 rake db:migrate 时,我得到了

rake aborted! Don't know how to build task 'db:migrate'

我没有其他 SO 用户提到的双分号问题,所以我真的很困惑。我已经安装了 0.9.2 和 0.8.7 以及 bundler 1.0.17。我的 rvm 实例显示 rake (0.8.7 ruby)

怎么了?

-- 编辑--

rake --tasks 的输出

rake sunspot:reindex[batch_size,models]  # Reindex all solr models that are...
rake sunspot:solr:run                    # Run the Solr instance in the for...
rake sunspot:solr:start                  # Start the Solr instance
rake sunspot:solr:stop                   # Stop the Solr instance

gem list 的输出是

gem list

*** LOCAL GEMS ***

aaronh-chronic (0.3.9)
abstract (1.0.0)
actionmailer (3.0.9)
actionpack (3.0.9)
activemodel (3.0.9)
activerecord (3.0.9)
activeresource (3.0.9)
activesupport (3.0.9)
arel (2.0.10)
authlogic (3.0.3)
builder (2.1.2)
bundler (1.0.17)
capistrano (2.8.0)
classifier (1.3.3)
daemons (1.1.4)
delayed_job (2.1.4)
docsplit (0.5.2)
erubis (2.6.6)
escape (0.0.4)
fast-stemmer (1.0.0)
gsl (1.14.7)
haml (3.1.2)
highline (1.6.2)
i18n (0.5.0)
lda-ruby (0.3.7)
madeleine (0.7.3)
mail (2.2.19)
mime-types (1.16)
minitest (1.6.0)
mysql (2.8.1)
narray (0.5.9.9)
net-ldap (0.2.2)
net-scp (1.0.4)
net-sftp (2.0.5)
net-ssh (2.1.4)
net-ssh-gateway (1.1.0)
nokogiri (1.5.0)
polyglot (0.3.1)
pr_geohash (1.0.0)
rack (1.2.3)
rack-mount (0.6.14)
rack-test (0.5.7)
rails (3.0.9)
rails3-generators (0.17.4)
railties (3.0.9)
rake (0.9.2, 0.8.7)
rdoc (3.6.1, 2.5.8)
rsolr (0.12.1)
shoulda (2.11.3)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.28)
whenever (0.6.8)
will_paginate (3.0.pre4)

application.rb 的输出是

require File.expand_path('../boot', __FILE__)

require 'rails/all'
require 'net/http'
require 'net/ldap'

【问题讨论】:

  • rake --tasks 的输出是什么?
  • 将代码或命令输出放在你的主帖中,你在你的应用程序目录中吗?
  • 是的,我在应用目录中。
  • 显示你的config/application.rb

标签: ruby-on-rails ruby-on-rails-3 rake bundler


【解决方案1】:

检查require 'rails/all' 是否出现在您的config/application.rb 文件中。看起来sunspot 改变了你的配置。

您也可以先尝试更新您的捆绑程序gem update bundler

【讨论】:

  • require rails/all 在 application.rb 中,gem update bundler 显示所有内容都已更新。
  • 是的,例如,如果您运行“rails new app-name -T -O”,将 mongodb 作为后端数据库,但您也想添加 mysql,您最终会得到那个问题...
  • 哈哈,是的,你为我节省了很多时间。
【解决方案2】:

尝试运行bundle exec rake db:migrate。问题可能是您没有从 bundler 加载 gem,因此没有获得这些 gem 中定义的任务(比如 Rails!)。

【讨论】:

  • 它仍然给我“不知道如何构建任务 'db:migrate'”。
  • 好的。您能否再次检查您是否运行bundle 来安装gems? gem list 的输出是什么?
  • 我确实运行了 bundle,gem 列表如上。
  • 那你让我难住了。祝你好运!
  • @Rio 你找到解决方案了吗?我目前被困在这里。
【解决方案3】:

我用这个命令解决了

bundle install --deployment

【讨论】:

    【解决方案4】:

    检查您的 Rakefile 中是否有 Rails.application.load_tasks

    如果没有,请添加该行。

    【讨论】:

      猜你喜欢
      • 2018-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-12
      • 2012-04-08
      • 2011-07-17
      • 2017-03-01
      • 1970-01-01
      相关资源
      最近更新 更多