LoginSignup
0
1

More than 3 years have passed since last update.

Vagrant環境で、rails db:dropでエラーになるトラブルシューティング

Posted at

環境

Vagrant + Ubuntu 16.04.5 LTS
Rails 5.2.4.2
ruby 2.5.1p57

はじめに

rails db:createした後に、rails db:dropをすると、下記のエラーが出た時のトラブルシューティング

$ rails db:drop
Text file busy @ apply2files - /vagrant/test03/db/development.sqlite3
Couldn't drop database 'db/development.sqlite3'
rails aborted!
Errno::ETXTBSY: Text file busy @ apply2files - /vagrant/test03/db/development.sqlite3
/vagrant/test03/bin/rails:9:in `<top (required)>'
/vagrant/test03/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:drop:_unsafe
(See full trace by running task with --trace)

内容

どうも、Railsのバグらしく、Vagrant環境で、データベースがsqlite3の場合に発生するようです。
同じVagrant環境でも、postgresqlの場合は発生しませんでした。(確認済)
sqlite3のデータベースファイルを直接削除して対応するしかないようです。

rm db/development.sqlite3
rm db/test.sqlite3

なお、下記コマンドでも同じエラーが出ます。

rails db:migrate:reset

rails db:createrails db:migrateを連続して、1コマンドつづ打っていくしかないようです。

参考URL
https://teratail.com/questions/67393
https://qiita.com/totechite/items/d4b7f97372881d1d7a25

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1