44

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?

Anthon
  • 78,313
  • 42
  • 165
  • 222
user654019
  • 2,277
  • 4
  • 21
  • 20

6 Answers6

25

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...

stackprotector
  • 400
  • 2
  • 3
  • 17
David
  • 251
  • 2
  • 3
  • 1
    Here's a few: https://www.virtualbox.org/ticket/2553 https://www.virtualbox.org/ticket/9203 https://bugs.launchpad.net/ubuntu/+source/gedit/+bug/341725 – laebshade Nov 14 '12 at 00:58
  • 5
    Greetings from the future. _"Over three years"_ has now turned into _"Over eight years"_. This is still a problem. – pipe Oct 03 '17 at 11:31
  • 4
    Greetings from the future's future. Now it is "Over 10 years". I am afraid I don't have enough time to see a fix to this...I turn to use *mousepad*. – smwikipedia May 02 '19 at 08:22
  • It's not an gedit problem. I have this when trying to do folder rename. – Mr.TK May 25 '21 at 10:01
8

“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.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • 5
    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
4

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

TimSC
  • 181
  • 3
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.

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
Mat
  • 51,578
  • 10
  • 158
  • 140
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