Emacs: Cannot disable "file changed since visited" check - azure

I am running emacs26 on an ubuntu azure VM and am running into problems when trying to save files on a particular mounted CIFS volume. Emacs will randomly ask "has changed since visited or saved. Save anyway? (yes or no)". When saving to local home storage this is not an issue. I've tried suggestions from this thread: Emacs: how to disable 'file changed on disk' checking? but none have worked. I have tried adding
(defun ask-user-about-supersession-threat (fn)
"ignore")
(defun ask-user-about-lock (file opponent)
"always grab lock"
t)
to my .emacs file and this does not help.
Suggestions?

Related

"Warning" about editing a read-only file although I have permission

I am using VSCode to remotely connect to a file server via SSH. I have another person who uses it as well and they are logging in under their own account, which is a part of a group that has access to an entire directory structure.
Every once in a blue moon, the permissions get screwed and revert back to root:root (ownership) and I have to change it back to root:groupname so that the other person can have access. However, even when I do this, sometimes the other person isn't able to make changes using VS Code. If I su to that user, I am able to save changes.
One thing that I have noticed is that if I run vim <filename> and try to edit it as that user, it'll say, "-- INSERT -- W10: Warning: Changing a readonly file". However, the minute I try to save the file, it actually saves.
It's almost like the permissions are lagging or something and hasn't been updated.
Any idea how I can go about fixing this?
There is code inside vim that does a pretty good job of deciding when a file has been opened by someone else with another editor for writing, and it stops you from a race condition for file write.
Vim is telling you to wait very patiently for the other person to be done writing that file.
Learn more with :help W10
Reproduce this bug in vim 9.0:
Make a /tmp/file.txt owned by youruser with rw-r--r--
Open two unique terminals to /tmp/
Open file.txt for writing in one using vim.
Vim will mark the file as read only awaiting write, since someone else has it open for writing.
Open file.txt for writing in one using vim in the other terminal.
You get:
"-- INSERT -- W10: Warning: Changing a readonly file"
Solutions:
Find the other instance of vim that has locked your file for writing and close that instance of vim. Done
Or if you don't have access to the other terminal, or the instance of the other editor died without releasing its read only lock, or if it's from another person who's opened the file for writing on a session from a different computer, then the only thing I know that can clear all of those conditions is rebooting the computer.
If you want more control over this, you'll have to uncover how vim is deciding when a file is readonly for writing and find out where this information is being stored and clear it manually.

Error on file save: "Opening output file: resource temporarily unavailable"

About 10% of the time, when I attempt to save my file in Emacs I get the following error:
Opening output file: resource temporarily unavailable,
I'm currently using Emacs GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2) on
Ubuntu 12.04. I've also verified that this issue occurs logged in as a different user and using Emacs 23.3.1.
This issue gets to be a real pain when I make a fix, attempt to save, and then wonder why my fix didn't happen.... only to find out later that the Emacs save was never successful.
If I notice it happen, I'll keep hitting Ctrl-x Ctrl-s until a save actually goes through (takes a few times).
Does anyone have any idea why this happens and how to prevent it?
Update:
(More info per request)
I'm currently on a Ruby on Rails project and have been getting the error while editing a variety of file types *.rb, *js.coffee, *js.erb, *html.erb, etc.
The files I receive the error on are always files local to my machine. I haven't tested remote files.
If I look at the *messages buffer, for every time the error message occurred, the error is prefixed with: save-buffer-2
Update 2:
Issue is encountered in multiple Emacs versions by multiple users.
Update 3:
This doesn't appear to be an Emacs specific issue as I now get the occasional "Unable to save" popup window while attempting to save files in Sublime-text editor.
This can be a bug from emacs (M-x report-emacs-bug), some issue with your filesystem (I assume this is not the case because most likely you checked if problem happens with other editors), or some process in your local setup messing with your files.
For testing if the later is the case, you could try to eval this and then reproduce the problem:
(defadvice save-buffer (around find-shenanigan activate)
(condition-case ()
ad-do-it
(error
(shell-command (format "lsof -V %s" (buffer-file-name)) "*debug-issue*"))))
What this does is every time the save operation fails, it executes a command that takes a picture of the processes that have your file opened. If you see any process, you know who investigate. man lsof will help with the details.
Note: Does the problem happen also with emacs -Q?
EDIT: if you can use sudo without password (NOPASSWD in /etc/sudoers), replace "lsof" with "sudo lsof"
EDIT: I redirected the output of the lsof to a buffer named *debug-issue*; check that buffer if error.

How to restore a modified file in geany on linux?

I have modified a file (personal file) and I saved the modification, now I want to restore the file to its last status before the modification, is it possible? how?
Which distro?
I mean if you are using gedit text editor and you have backup option turned on it then go to the directory of your file and switch to "show hidden files and folders" and there should be a backup. for example if the file name is 1.txt, backup would be 1.txt~. It will contain the stuff before the last save,
As far as I know, Geany does not keep a backup of files by default while saving, so your file changes are probably lost.
Geany however does have a plugin which can do this for you in future. You can enable the Save actions plugin and enable the Backup copy option in it.
If you have just overwritten the file (Ctrl+S) and haven't yet quit Geany, you can just Ctrl+Z to the desired document state and save that file version.
If you have already quit Geany after that and haven't set up back up in Geany before, I am afraid that by means of Geany you cannot restore the file to the previous state.
Read this article about how to set up back up in Geany. Basically you can go to Edit -> Preferences -> Various (read the manual and the link above before changing these preferences) and:
disable use_atomic_file_saving (disabled by default)
enable use_gio_unsafe_file_saving (enabled by default)
enable gio_unsafe_save_backup (disabled by default)
This will always keep the previous version of the file (as a hidden file with ~ attached to its name) next to original.
Or you can install/enable the Save Actions Geany plugin and enable the Auto Save and Backup Copy options to automatically save files at a certain time interval and to keep a copy of previous file versions.

strange behavior saving a file with vim on Windows in a folder that requires elevated permission

I'm editing the apache2.conf configuration file under the 'C:\Program Files...' folder. This folder requires elevated permission ("Start program as administrator") for writing to anywhere on this folder.
Opening the file by mistake with vim without elevation - didn't show any warning. Moreover, I was able to save the file (':wq') just fine without any warning. Opening the file again with vim - showed me the modified file. However - no changes in the behavior of Apache (of course).
Trying to open the file with Notepad - show me the file was not modified.
Then, trying to open the file with vim from an elevated shell - I got the original file (just like notepad), but this time, I was able to edit the file, and save it.
I know have two versions of the file. The real file (shown by notepad, elevated shell, just 'type' and seen by apache httpd), and the file I edited and saved from an unelevated shell - stored somewhere (where???).
This is very uncomfortable, as sometime I open this file by mistake from a regular shell (even just for read).
What is going on? How do I exit this state?
I was hit by a Windows feature called "Virtual Store". Underneath the unaware application (that is, vim in this case), the OS running in compatibility mode will save the files in a folder named "Virtual Store", at this location: C:\Users\<login name>\AppData\Local\VirtualStore\.... The application will not be aware the file went there. Subsequent reads will read from that Virtual Store location.
It seems vim isn't UAC aware and it is running in compatibility mode - which could be fixed, but as for version 7.4 it hasn't.

TortoiseSVN update/cleanup error between Linux repository and Windows XP

For no reason that I can see, I can no longer run a TortoiseSVN Update on a development directory on my portable Windows XP Professional SP3 machine, getting the error:
Previous operation has not finished; run 'cleanup' if it was interrupted
Please execute the 'Cleanup' command.
If I try running cleanup, I get another error,
cannot process the following paths: cannot move $ROOT_DIR/.svn/tmp/tmp-... to $ROOT_DIR/path/where/thing/should/go: no such file or directory
I have verified that both files exist, and actually from CMD.EXE prompt I am able to issue a MOVE with those two filenames and have it work correctly. It's no use because next time SVN tries to repeat the operation itself after creating a different tmp file name, and while CMD succeeded, SVN fails.
UPDATE: the path lengths are in both cases well below PATH_MAX, target file system is NTFS, and permissions are OK. Maybe I'll now try with FileMon to see whatever TortoiseSVN is really up to.
I tried downgrading TortoiseSVN but to no avail. Other repositories work OK between the same machines.
TortoiseSVN 1.7.9, Build 23248 - 32 Bit , 2012/08/30 18:25:37
Subversion 1.7.6,
apr 1.4.6
apr-utils 1.3.12
neon 0.29.6
OpenSSL 1.0.1c 10 May 2012
zlib 1.2.7
Both server (OpenSuSE Linux 12.2) and client now run the latest version of SVN.
On Windows, I also cannot seem to get any more informative logs or information (I'm not very skilled with TortoiseSVN, I have always used the Linux command line version).
I might delete the local copy and run a checkout, but it's about 2 GB of data, and I'm on a slow connection, so it is really more of a "fly physically to server location and hook a copper Ethernet to the local network there" alternative. I'm reserving that as a sort of last ditch, nuclear option; I'd really rather understand what the problem is, for I fear it might happen again.
UPDATE
I've tried to delete remotely the subdirectory involved, committing the deletion on the server; deleting the subdirectory locally, and emptying the .svn/tmp subdirectory where I found sixteen tmp files, all copies of the one PNG causing problems.
I am still not able to perform any SVN subcommand, getting "Run cleanup!" error; on cleanup; I get a failed attempt to copy a tmpfile to the never-sufficiently-damned .PNG file, which no longer exists anywhere, into a directory that no longer exists anywhere.
I tried recreating the directory locally (but not the file!), no changes.
With FileMon, I traced the source PNG to 8e4c2389cf9d85c8b8ee54d49ea053c752a38187.svn-base in .svn/pristine subdirectory, tried removing it and got SVN complaining. I tried copying it to its intended destination (so that the file-as-it-should-be and the file-as-it-is are identical), no joy.
UPDATE
Well, this is weird. I decided to track everything that TortoiseSVN is doing using FileMon. I could see it checking the wc.db and search the item, checking for it in .svn/pristine (and finding it), copying it (unnecessarily if you ask me...) in .svn/tmp, and finally checking $DESTINATION_FILE (with correct case) using Windows Open() API. And getting PATH NOT FOUND. Yet the file is there, I can see it (and the name is less than 8.3 characters). And why PATH not found and not FILE not found?
Okay, it all boiled down to a directory that had been created remotely with a name ending with space. The file in itself was OK; the directory where it stood was not.
When updating, apparently, the directory got created but the name was shortened by Windows to exclude the final space.
To add to the difficulty of diagnosing, while TortoiseSVN did tell me what the problem was, it did so in the dialog box where the Arial font made the space in \path\to\your \file not clearly recognizable (it was, once I knew where to look, and compared that slash with the others. This one stood a little farther from the letter at its left).
Lesson learned: check really carefully the dialog file name, character by character (note to self: find a way of having it in Courier New if at all possible).
You may have two files in the repository that differ only in case. That's a problem on Windows. See this FAQ for details.

Resources