Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 5, Rspec: Environment data not found in the schema

After upgrading a Rails app to Rails 5, running RSpec tests gives me the following error:

rails aborted! ActiveRecord::NoEnvironmentInSchemaError:   Environment data not found in the schema. To resolve this issue, run:       bin/rails db:environment:set RAILS_ENV=test 

However, that bin does not exist and I can't seem to generate it with bundle binstubs rails or with rake rails:update:bin.

I have also tried:

rails db:environment:set RAILS_ENV=test rake db:environment:set RAILS_ENV=test 

There is a related issue on Github here.

How can I address this error?

like image 201
steel Avatar asked Jul 05 '16 17:07

steel


1 Answers

New Rails 5 command to generate binstubs:

rails app:update:bin 

Allows me to run the solution as the error suggested:

bin/rails db:environment:set RAILS_ENV=test 

Tip from @max comment: If you are using database_cleaner and this error keeps popping up then change your config to:

DatabaseCleaner.clean_with(   :truncation,   except: %w(ar_internal_metadata) ) 
like image 54
steel Avatar answered Sep 21 '22 01:09

steel