为什么rake中缺少数据库任务?

时间:2019-04-10 19:22:09

标签: ruby-on-rails rake rake-task

当我运行bundle exec rake db:setup时,我收到一条错误消息,说rake不知道如何构建该任务。然后,我运行bundle exec rake -T,并发现缺少数据库任务(下面的所有输出)。如何访问数据库任务?

-application.rb-

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

require 'rails'
require 'active_model/railtie'
require 'active_job/railtie'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'

Bundler.require(*Rails.groups)

module LofocatsUi
  class Application < Rails::Application

  end
end

-rake命令-

bos-mp478:lofocats_ui rabdelaz$ bundle exec rake db:setup --trace
rake aborted!
Don't know how to build task 'db:setup' (See the list of available tasks with `rake --tasks`)
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/lib/rake/task_manager.rb:59:in `[]'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/lib/rake/application.rb:159:in `invoke_task'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/lib/rake/application.rb:116:in `each'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/lib/rake/application.rb:116:in `block in top_level'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/lib/rake/application.rb:125:in `run_with_threads'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/lib/rake/application.rb:110:in `top_level'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/lib/rake/application.rb:83:in `block in run'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/bin/rake:23:in `load'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@lofocats-ui/bin/rake:23:in `<top (required)>'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/cli/exec.rb:74:in `load'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/cli/exec.rb:74:in `kernel_load'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/cli/exec.rb:28:in `run'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/cli.rb:424:in `exec'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/cli.rb:27:in `dispatch'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/cli.rb:18:in `start'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/bin/bundle:30:in `block in <main>'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/lib/ruby/site_ruby/2.4.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/Users/rabdelaz/.rvm/rubies/ruby-2.4.3/bin/bundle:22:in `<main>'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@global/bin/ruby_executable_hooks:24:in `eval'
/Users/rabdelaz/.rvm/gems/ruby-2.4.3@global/bin/ruby_executable_hooks:24:in `<main>'

-任务列表-

bos-mp478:lofocats_ui rabdelaz$ bundle exec rake -T
rake about                              # List versions of all Rails frameworks and the environment
rake assets:clean[keep]                 # Remove old compiled assets
rake assets:clobber                     # Remove compiled assets
rake assets:environment                 # Load asset compile environment
rake assets:precompile                  # Compile all the assets named in config.assets.precompile
rake cache_digests:dependencies         # Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)
rake cache_digests:nested_dependencies  # Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)
rake doc:app                            # Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE="Custom Title")
rake log:clear                          # Truncates all *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)
rake middleware                         # Prints out your Rack middleware stack
rake notes                              # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)
rake notes:custom                       # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM
rake rails:template                     # Applies the template supplied by LOCATION=(/path/to/template) or URL
rake rails:update                       # Update configs and some other initially generated files (or use just update:configs or update:bin)
rake routes                             # Print out all defined routes in match order, with names
rake secret                             # Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)
rake stats                              # Report code statistics (KLOCs, etc) from the application or engine
rake time:zones:all                     # Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6
rake tmp:clear                          # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)
rake tmp:create                         # Creates tmp directories for sessions, cache, sockets, and pids

0 个答案:

没有答案