Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: RuntimeError: Don't know how to build task 'db:migrate' #844

Merged
merged 1 commit into from Jan 3, 2021

Conversation

onk
Copy link
Contributor

@onk onk commented Dec 3, 2020

ActiveRecord's migrate tasks are required since v2.7.5 (#588).

How to reproduce

  1. create non-rails project (like sinatra)
./
├── app.rb
├── Gemfile
├── Gemfile.lock
└── models/
   └── user.rb
# Gemfile
source "https://rubygems.org"
gem "activerecord", require: "active_record"
gem "annotate"
gem "sqlite3"
# app.rb
Bundler.require(:default)

ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Schema.define do
  create_table :users, force: true do |t|
  end
end

Dir["models/*.rb"].sort.each {|f| require_relative f }
# models/user.rb
class User < ActiveRecord::Base
end
  1. execute annotate
$ bundle exec annotate -R ./app.rb --models --model-dir models

Expected behavior

$ bundle exec annotate -R ./app.rb --models --model-dir models
-- create_table(:users, {:force=>true})
   -> 0.0025s
Annotated (1): models/user.rb
$ cat models/user.rb
# == Schema Information
#
# Table name: users
#
#  id :integer          not null, primary key
#
class User < ActiveRecord::Base
end

Actual behavior

$ bundle exec annotate -R ./app.rb --models --model-dir models
bundler: failed to load command: annotate (/Users/onaka/.bundle/ruby/3.0.0/bin/annotate)
RuntimeError: Don't know how to build task 'db:migrate' (See the list of available tasks with `rake --tasks`)
  /Users/onaka/.bundle/ruby/3.0.0/gems/rake-13.0.1/lib/rake/task_manager.rb:59:in `[]'
  /Users/onaka/.bundle/ruby/3.0.0/gems/rake-13.0.1/lib/rake/task.rb:405:in `[]'
  /Users/onaka/.bundle/ruby/3.0.0/gems/annotate-3.1.1/lib/tasks/annotate_models_migrate.rake:8:in `block in <top (required)>'
  /Users/onaka/.bundle/ruby/3.0.0/gems/annotate-3.1.1/lib/tasks/annotate_models_migrate.rake:7:in `each'
  /Users/onaka/.bundle/ruby/3.0.0/gems/annotate-3.1.1/lib/tasks/annotate_models_migrate.rake:7:in `<top (required)>'
  /Users/onaka/.bundle/ruby/3.0.0/gems/annotate-3.1.1/lib/annotate.rb:78:in `load'
  /Users/onaka/.bundle/ruby/3.0.0/gems/annotate-3.1.1/lib/annotate.rb:78:in `block in load_tasks'
  /Users/onaka/.bundle/ruby/3.0.0/gems/annotate-3.1.1/lib/annotate.rb:77:in `each'
  /Users/onaka/.bundle/ruby/3.0.0/gems/annotate-3.1.1/lib/annotate.rb:77:in `load_tasks'
  /Users/onaka/.bundle/ruby/3.0.0/gems/annotate-3.1.1/lib/annotate.rb:133:in `bootstrap_rake'
  /Users/onaka/.bundle/ruby/3.0.0/gems/annotate-3.1.1/bin/annotate:20:in `<top (required)>'
  /Users/onaka/.bundle/ruby/3.0.0/bin/annotate:23:in `load'
  /Users/onaka/.bundle/ruby/3.0.0/bin/annotate:23:in `<top (required)>'

ActiveRecord's migrate tasks are required since v2.7.5 (ctran#588).
@onk onk force-pushed the work_on_non_rails_project branch from 93f774f to 1508f2b Compare December 3, 2020 18:26
@masa-iwasaki
Copy link
Contributor

I got simillar errors in one of my projects and this PR solved the errors.

@ctran I would appreciate if this PR got merged and released.

@ctran ctran self-assigned this Jan 3, 2021
@ctran ctran modified the milestones: v3.1.0, v3.1.2 Jan 3, 2021
@ctran ctran merged commit 516ed58 into ctran:develop Jan 3, 2021
ocarta-l pushed a commit to ocarta-l/annotate_models that referenced this pull request Jun 18, 2021
)

ActiveRecord's migrate tasks are required since v2.7.5 (ctran#588).
@ctran ctran modified the milestones: v3.1.2, v3.2.0 Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants