The error:
Errno::ETXTBSY: Text file busy @ unlink_internal - /home/vagrant/shared/sample_app/db/test.sqlite3
/home/vagrant/shared/sample_app/test/test_helper.rb:3:in <top (required)>'
/home/vagrant/shared/sample_app/test/helpers/static_pages_helper_test.rb:1:in
'
Tasks: TOP => test:run => test:units
(See full trace by running task with --trace)
Text file busy is shown because some other process is accessing it. lsof will show you what's accessing the file. cp -f should work, as it will replace the file if it can't overwrite it. cp -f is not safe as it may result in removed/missing files when you are done.
During installation, compilation and such, you may see: cannot create regular file filename: Text file busy. Most likely, the file you are attempting to replace is an executable, and it is currently being run. ( You could check this with fuser or lsof)
Move the database files outside vagrant share, for example to /tmp.
edit database.yml:
development:
<<: *default
database: /tmp/project/development.sqlite3
test:
<<: *default
database: /tmp/project/test.sqlite3
Workaround:
The error was related to Vagrant (or VirtualBox) custom shared folders. I couldn't figure out how to solve it, but there is a workaround. Instead of working with a vagrant custom shared folder (~/shared/sample_app), defined in the vagrantfile I moved the app folder to a standard shared folder inside the VM root (/vagrant). Now I still get the file sync in my host machine and the issue is gone.
UPDATE 1
Reached another conclusion today.
Everytime bundle exec rake db:migrate
or rails generate migration
is executed the error will return.
Another Workaround
1 - Delete the test.sqlite3 file.
2 - Copy the development.sqlite3 file
3 - Paste and change the name to test.sqlite3
* - Just migrated for testing and this seems to be a permanent solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With