简体   繁体   English

Bundle Exec Rake Test 和 rails db:migrate RAILS_ENV=test 不工作

[英]Bundle Exec Rake Test and rails db:migrate RAILS_ENV=test is not working

I run $ bundle exec rake test and I receive this:我运行$ bundle exec rake test并收到以下信息:

ubuntu:~/environment/sample_app (modeling-users) $ bundle exec rake test
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootstrap-4.3.1/lib/bootstrap/version.rb:4: warning: already initialized constant Bootstrap::VERSION
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootstrap-sass-3.4.1/lib/bootstrap-sass/version.rb:2: warning: previous definition of VERSION was here
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootstrap-4.3.1/lib/bootstrap/version.rb:5: warning: already initialized constant Bootstrap::BOOTSTRAP_SHA
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootstrap-sass-3.4.1/lib/bootstrap-sass/version.rb:3: warning: previous definition of BOOTSTRAP_SHA was here
Migrations are pending. To resolve this issue, run:

        rails db:migrate RAILS_ENV=test

Okay, great, so I run $ rails db:migrate RAILS_ENV=test and I receive this:好的,太好了,所以我运行$ rails db:migrate RAILS_ENV=test并收到以下信息:

/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootstrap-4.3.1/lib/bootstrap/version.rb:4: warning: already initialized constant Bootstrap::VERSION
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootstrap-sass-3.4.1/lib/bootstrap-sass/version.rb:2: warning: previous definition of VERSION was here
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootstrap-4.3.1/lib/bootstrap/version.rb:5: warning: already initialized constant Bootstrap::BOOTSTRAP_SHA
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootstrap-sass-3.4.1/lib/bootstrap-sass/version.rb:3: warning: previous definition of BOOTSTRAP_SHA was here
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class AddPasswordDigestToUsers < ActiveRecord::Migration[4.2]
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:536:in `inherited'
/home/ubuntu/environment/sample_app/db/migrate/20200614082512_add_password_digest_to_users.rb:1:in `<main>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1010:in `load_migration'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1006:in `migration'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1002:in `disable_ddl_transaction'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1368:in `use_transaction?'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1360:in `ddl_transaction'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `each'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1231:in `migrate'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1061:in `up'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1036:in `migrate'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <main>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `each'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <main>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/command.rb:48:in `invoke'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<main>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `block in require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/ubuntu/environment/sample_app/bin/rails:9:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
/home/ubuntu/environment/sample_app/bin/spring:15:in `require'
/home/ubuntu/environment/sample_app/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'

Caused by:
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class AddPasswordDigestToUsers < ActiveRecord::Migration[4.2]
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:536:in `inherited'
/home/ubuntu/environment/sample_app/db/migrate/20200614082512_add_password_digest_to_users.rb:1:in `<main>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1010:in `load_migration'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1006:in `migration'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1002:in `disable_ddl_transaction'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1368:in `use_transaction?'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1360:in `ddl_transaction'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `each'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1231:in `migrate'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1061:in `up'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1036:in `migrate'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <main>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `each'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <main>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/command.rb:48:in `invoke'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<main>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `block in require'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/ubuntu/environment/sample_app/bin/rails:9:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
/home/ubuntu/environment/sample_app/bin/spring:15:in `require'
/home/ubuntu/environment/sample_app/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

I see some of the errors, but I don't fully understand what it's asking me to do or what these errors mean.看到了一些错误,但我不完全理解它要求我做什么或这些错误意味着什么。 I'm extremely new to rails, so apologies if these are more than obvious.我对rails非常陌生,所以如果这些很明显,我很抱歉。 This is my literal first time learning any of this, point blank.这是我第一次真正地学习这些,空白。 Thank you!谢谢!

There is a problem with bootstrap-sass. bootstrap-sass 有问题。

Remove it from your gemfile and run gem uninstall bootstrap-sass从你的 gemfile 中删除它并运行gem uninstall bootstrap-sass

That will solve this error;这将解决这个错误; but leave you without bootstrap-sass.但让你没有 bootstrap-sass。 But at least you now have a working rails env.但至少你现在有一个工作的 rails env。

Had you installed 2 separate, conflicting bootstrap gems?您是否安装了 2 个独立的、相互冲突的引导程序 gem? Looks like bootstrap is being instanciated twice (that's the actual error message)看起来引导程序被实例化了两次(这是实际的错误消息)

Also, see my comment in your other question for a “better” way to get bootstrap running in rails 6. https://stackoverflow.com/a/62392966/1777331另外,请参阅我在您的其他问题中的评论,以获得在 Rails 6 中运行引导程序的“更好”方法。 https://stackoverflow.com/a/62392966/1777331

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM