I have a file setup.py
created with Emacs and I set 744 permissions to it:
$ ls -la
total 8
drwxr-xr-x 3 user staff 96 10 Dec 20:49 .
drwxr-xr-x 6 user staff 192 10 Dec 20:47 ..
-rwxr--r-- 1 user staff 39 10 Dec 20:49 setup.py
When I edit the file so that Emacs auto-saves, it creates a linked file that represents a lock, which is also executable:
$ ls -la
total 8
drwxr-xr-x 4 user staff 128 10 Dec 20:56 .
lrwxr-xr-x 1 user staff 36 10 Dec 20:56 .#setup.py -> [email protected]
drwxr-xr-x 6 user staff 192 10 Dec 20:47 ..
-rwxr--r-- 1 user staff 39 10 Dec 20:49 setup.py
I save the file with Emacs, and the executable bit resets to 0:
$ ls -la
total 8
drwxr-xr-x 3 user staff 96 10 Dec 20:56 .
drwxr-xr-x 6 user staff 192 10 Dec 20:47 ..
-rw-r--r-- 1 user staff 40 10 Dec 20:56 setup.py
I have the same problem if I edit with -q
, which skips initialisation:
$ chmod +x setup.py
$ emacs -q setup.py
2019-02-01 10:26:12.136 Emacs-x86_64-10_10[7566:50149] ...
$ ls -la
total 48
drwxr-xr-x 10 user staff 320 1 Feb 10:26 .
drwxr-xr-x 15 user staff 480 31 Jan 14:56 ..
-rwxr-xr-x 1 user staff 2139 1 Feb 10:26 setup.py
The version is 26.1 (9.0).
How can I prevent Emacs from resetting the executable bit?
emacs -Q
? If not, bisect your init file to find the problem. – Drew Dec 10 '18 at 21:27C-h i g (emacs)Backup Copying
a factor here? – phils Dec 11 '18 at 00:15(setq backup-by-copying 't)
forced backup by copying instead of renaming and solved this issue. Do you want to write an answer? – miguelmorin Feb 01 '19 at 10:36