34

I have a text file that I can change using other applications (for example openoffice). But when I try to change and save it using gedit, I am getting error from gedit:

Could not save the file /media/sf_Ubuntu/BuildNotes.txt.
Unexpected error: Error renaming temporary file: Text file busy

the permission of BuildNotes.txt is as follow:

-rwxrwx--- 1 root vboxsf  839 2012-10-26 12:08 BuildNotes.txt

and user id is:

m@m-Linux:/media/sf_Ubuntu$ id
uid=1000(m) gid=1000(m) groups=4(adm),20(dialout),24(cdrom),46(plugdev),105(lpadmin),119(admin),122(sambashare),1000(m),1001(vboxsf)

What is the problem and how I can fix it?

2
  • and vim works fine... – Leon Sep 27 '19 at 3:15
  • nano is also working fine for me. – Ahmed Akhtar Mar 30 at 13:09
21

This problem has been reported since 2009 (example [archived]). It is awful that there's no fix for it yet. Neither VirtualBox nor Gedit developers are willing to take responsibility for it, and instead are content to point fingers at one another for over three years.

You can set your editor preferences to 'Create a backup' then save twice. Incredibly painful, but it works.

Some other editors won't report the problem. However, when I tested Kate and nano, for example, those just silently deleted the file on every other save. That's even worse than the gedit situation...

3
7

“Text file busy” can be confusing here: it isn't actually about text files, but about executables. Executables are called text files because… hum, actually, I don't know why.

What the message really means is “this file is locked by another program that is using it and can't let it be modified under its nose, so you can't write to it.” It is quite unusual to see this message for a text file: unix systems generally frown on mandatory locks on files, and there is no facility for applications to lock out others from modifying a file. (Unix has advisory locks: they can be used to synchronize concurrent accesses to a file by cooperating programs.) The most common circumstance when you'll see “text file busy” (ETXTBUSY) is if you try to modify an executable that's running: the kernel locks it. Another possibility is a disk image that is mounted, again locked by the kernel.

In your case, given the location of the file /media/sf_Ubuntu and the ownership to the group vboxsf, my guess is that the file, which is on a VirtualBox file sharing filesystem, is locked in the host operating system. Presumably the host is a Windows machine and you also have the file open in an editor there. You'll need to close the file on the host before you can save in the editor in the VM.

2
  • 4
    thanks. I am %100 sure that the file is not oprn in windows and also no other application is using it. I can open it using OpenOffice and hence I am sure that it is not opened by other applications. It is only gedit that can not save it. – user654019 Oct 28 '12 at 13:59
  • 2
    I am having the same issue. every program in guest os works great but gedit, something is up. – GlassGhost Apr 22 '13 at 23:44
3

The problem is fundamentally with glib and the way it saves to a temporary file, then renames. The bug has been recorded as: https://bugzilla.gnome.org/show_bug.cgi?id=656225

2

Check with lsof if the file is open by another application

lsof /media/sf_Ubuntu/BuildNotes.txt

Or use fuser:

fuser -km /media/sf_Ubuntu/BuildNotes.txt
2

What fixed it for me (still a bit annoying but works), and is applicable to gedit, is to:

edit - preferences - editor Put a check on "Create backup copy"

When saving from now on, save the file once, ignore the error, save again. works every time.

1
  • In 2019, this error still occurs. This workaround works. – David Apr 11 '19 at 13:28
0

using linux terminal, try editing the file using vi file_name and save it. p.s I could not find another solution for this issue. vi worked

Not the answer you're looking for? Browse other questions tagged or ask your own question.