Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errno::ETXTBSY: Text file busy @ unlink_internal

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)

like image 590
apt Avatar asked Dec 08 '14 14:12

apt


People also ask

How do I fix a busy text file?

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.

What does text file busy mean?

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)


2 Answers

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
like image 75
mkldon Avatar answered Sep 26 '22 01:09

mkldon


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.

like image 38
apt Avatar answered Sep 24 '22 01:09

apt