GNU bug report logs -
#40156
26.3; append-to-file does not work on nonexistent file over ssh
Previous Next
Reported by: Sean Devlin <spd <at> toadstyle.org>
Date: Fri, 20 Mar 2020 21:21:02 UTC
Severity: normal
Found in version 26.3
Fixed in version 27.2
Done: Michael Albinus <michael.albinus <at> gmx.de>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 40156 in the body.
You can then email your comments to 40156 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#40156
; Package
emacs
.
(Fri, 20 Mar 2020 21:21:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Sean Devlin <spd <at> toadstyle.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 20 Mar 2020 21:21:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi folks,
The append-to-file function (and the underlying write-region in append
mode) fails over ssh (via tramp) when applied to a nonexistent file. The
same invocation creates the file transparently when invoked locally.
I think tramp should create the file as in the local usage, if
possible. If this is not possible, the discrepancy should be documented
somewhere. (Apologies if it is documented somewhere; I tried to find it
and could not.)
The following (edited) eshell transcript demonstrates the behavior
(though it works the same in Lisp):
Welcome to the Emacs shell
> ~ $ ls
> ~ $ append-to-file "something" nil nonexistent.txt
> ~ $ cat nonexistent.txt
> something~ $
> ~ $
> ~ $ cd /ssh:remote:
> /ssh:remote:/home/user $ ls
> /ssh:remote:/home/user $ append-to-file "something" nil nonexistent.txt
> File ‘/ssh:remote:/home/user/nonexistent.txt’ not found on remote host
> /ssh:remote:/home/user $
> /ssh:remote:/home/user $ touch nonexistent.txt
> /ssh:remote:/home/user $
> /ssh:remote:/home/user $ append-to-file "something" nil nonexistent.txt
> /ssh:remote:/home/user $
> /ssh:remote:/home/user $ cat nonexistent.txt
> something/ssh:remote:/home/user $
In GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Version 10.14.3 (Build 18D109))
of 2019-09-02 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.1975
Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'
Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Eshell
Minor modes in effect:
shell-dirtrack-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message rmc puny seq dired
dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config gnus-util
rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils pp files-x tramp-cache tramp-sh tramp
tramp-compat tramp-loaddefs trampver shell parse-time format-spec advice
auth-source cl-seq eieio byte-opt bytecomp byte-compile cconv eieio-core
cl-macs gv eieio-loaddefs password-cache pcmpl-unix em-unix em-term term
disp-table easymenu ehelp em-script em-prompt em-ls cl-loaddefs cl-lib
em-hist em-pred em-glob em-dirs em-cmpl em-basic em-banner em-alias
pcomplete comint ansi-color ring esh-var esh-io esh-cmd esh-opt esh-ext
esh-proc esh-arg esh-groups eshell esh-module esh-mode esh-util
elec-pair time-date tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads kqueue cocoa ns multi-tty make-network-process emacs)
Memory information:
((conses 16 236075 13044)
(symbols 48 23407 1)
(miscs 40 55 96)
(strings 32 40652 1787)
(string-bytes 1 1228751)
(vectors 16 40619)
(vector-slots 8 799289 20336)
(floats 8 72 298)
(intervals 56 830 0)
(buffers 992 14))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#40156
; Package
emacs
.
(Fri, 20 Mar 2020 23:33:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 40156 <at> debbugs.gnu.org (full text, mbox):
Hi folks,
I did a little digging, and I think the problem is in tramp-sh-handle-write-region around line 3240:
> ;; If `append' is non-nil, we copy the file locally, and let
> ;; the native `write-region' implementation do the job.
> (when append (copy-file filename tmpfile 'ok))
It looks like copy-file fails if filename doesn’t exist. Adding a test for file existence (i.e. file-exists-p) to the condition seems to solve the problem, though admittedly I only tested for my own narrow use case.
Thanks!
Reply sent
to
Michael Albinus <michael.albinus <at> gmx.de>
:
You have taken responsibility.
(Sat, 21 Mar 2020 09:32:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Sean Devlin <spd <at> toadstyle.org>
:
bug acknowledged by developer.
(Sat, 21 Mar 2020 09:32:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 40156-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Version: 27.2
Sean Devlin <spd <at> toadstyle.org> writes:
> Hi folks,
Hi Sean,
> I did a little digging, and I think the problem is in
> tramp-sh-handle-write-region around line 3240:
>
>> ;; If `append' is non-nil, we copy the file locally, and let
>> ;; the native `write-region' implementation do the job.
>> (when append (copy-file filename tmpfile 'ok))
>
> It looks like copy-file fails if filename doesn’t exist. Adding a test
> for file existence (i.e. file-exists-p) to the condition seems to
> solve the problem, though admittedly I only tested for my own narrow
> use case.
Thanks, and yes, your analysis is correct. I've committed a respective
patch to Emacs master. I've extended also tramp-tests.el
accordingly. The patch is appended.
Since Emacs 27.1 is already in pretest, I haven't applied it there. The
next Tramp release in GNU ELPA, 2.4.3.3, will contain the patch. It is
expected end of March.
> Thanks!
Best regards, Michael.
[Message part 2 (text/x-patch, attachment)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 18 Apr 2020 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 5 years and 141 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.