[vim/vim] Netrw cannot write remote files (E382) (#2329)

274 views
Skip to first unread message

Joseph R. Nosie

unread,
Nov 12, 2017, 10:47:45 PM11/12/17
to vim/vim, Subscribed

When editing a remote file using :e scp://user@host/file, netrw sets buftype=nofile which causes error E382 to be raised when trying to write changes. According to :h buftype, instead of using bt=nofile, netrw should use bt=acwrite.

I can replicate the issue with a fresh built version of vim isolated from the system runtime launched with /opt/vim/bin/vim -u NORC --cmd 'set nocompatible' and an empty ~/.vim. The exact steps to reproduce are as follows:

  1. vim scp://<user>@<host>/<filepath> or :edit scp://<user>@<host>/<filepath>
  2. :write
  3. "E382: Cannot write, 'buftype' option is set"

A temporary workaround I have found is to manually :set bt=acwrite before any write or to write using :Nwrite. Note, that netrw will reset to bt=nofile as part of every write.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Rob Hoelz

unread,
Dec 5, 2017, 7:22:15 PM12/5/17
to vim/vim, Subscribed

I encountered this myself as well - it seems the culprit commit is b0d45e7, which bumped up the netrw runtime files.

tagwint

unread,
Dec 8, 2017, 10:42:33 AM12/8/17
to vim/vim, Subscribed

As a permanent workaround
autocmd BufRead scp://* :set bt=acwrite
can be added to vimrc

Melkster

unread,
Dec 9, 2017, 4:53:00 PM12/9/17
to vim/vim, Subscribed

@tagwint

autocmd BufRead scp://* :set bt=acwrite
can be added to vimrc

To me this only solves it for the first write, after that the same problem appears again.

protist

unread,
Dec 9, 2017, 9:23:34 PM12/9/17
to vim/vim, Subscribed

FWIW this workaround works indefinitely for me.

Rob Hoelz

unread,
Dec 10, 2017, 11:59:07 AM12/10/17
to vim/vim, Subscribed

I've been using set bt= with the BufWritePost event and that's worked for me.

Greg Mackey

unread,
Dec 11, 2017, 12:44:29 PM12/11/17
to vim/vim, Subscribed

For me it took the combination of using set bt= with both the BufRead and BufWritePost events. The BufRead takes care of when the file is opened and first read. The BufWritePost takes care of all writes.

Melkster

unread,
Dec 12, 2017, 2:31:20 AM12/12/17
to vim/vim, Subscribed

@gmackey

For me it took the combination of using set bt= with both the BufRead and BufWritePost events.

This did it for me, however the buffer closes after :w (which it also did before), which is sort of annoying.

依云

unread,
Dec 16, 2017, 4:54:59 AM12/16/17
to vim/vim, Subscribed

I encountered this too, and lost my edit. (I did :xa but the remote file wasn't saved like before.)

yipu

unread,
Jul 17, 2018, 9:00:47 AM7/17/18
to vim/vim, Subscribed

Encountered this too while editing files under a samba directory.

Thomas G Henry

unread,
Jul 30, 2018, 5:27:42 PM7/30/18
to vim/vim, Subscribed

+1

Tony Narlock

unread,
Nov 21, 2018, 8:53:54 PM11/21/18
to vim/vim, Subscribed

This has been driving me nuts.

Christian Brabandt

unread,
Nov 22, 2018, 2:49:16 AM11/22/18
to vim/vim, Subscribed

try to get the most recent netrw version from Charles page http://www.drchip.org/astronaut/vim/index.html#NETRW

If this still happens, have a look at :h netrw-debug

K.Takata

unread,
Nov 22, 2018, 2:57:19 AM11/22/18
to vim/vim, Subscribed

I think this was a bug of Netrw v162 and it had many troubles. So Bram reverted it and now v156 is included in the vim repository. (I'm not sure this is fixed in v163b.)

Bad Sir Brian

unread,
Mar 26, 2019, 6:18:14 PM3/26/19
to vim/vim, Subscribed

v165b seems to be working fine for me. I had some issues with the version packaged with vim 8.0.1283

Christian Brabandt

unread,
Mar 27, 2019, 2:50:11 AM3/27/19
to vim/vim, Subscribed

Okay, since this problem seems to be fixed upstream, I'll go ahead and close it. I suppose Charles will send an update soon, since netrw hasn't been updated in a while.

Christian Brabandt

unread,
Mar 27, 2019, 2:50:11 AM3/27/19
to vim/vim, Subscribed

Closed #2329.

M Imam Pratama

unread,
Mar 17, 2020, 2:32:11 AM3/17/20
to vim/vim, Subscribed

I face this problem when trying to save particular local files. If you are like me, you might only need to run :set bt= or :set buftype= command in vim to solve the problem once and for all for that particular file.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or unsubscribe.

Christian Brabandt

unread,
Mar 17, 2020, 3:25:13 AM3/17/20
to vim/vim, Subscribed

@imambungo
have you updated your netrw version and tested with that? http://www.drchip.org/astronaut/vim/index.html#NETRW


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or unsubscribe.

M Imam Pratama

unread,
Mar 17, 2020, 3:43:40 AM3/17/20
to vim/vim, Subscribed

@chrisbra I never updated netrw manually, but I do update vim regularly. My vim version:
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 01 2020 17:17:52)


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or unsubscribe.

Christian Brabandt

unread,
Mar 17, 2020, 3:45:20 AM3/17/20
to vim/vim, Subscribed

so please try with the latest development version, to provide feedback to the author @cecamp.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or unsubscribe.

M Imam Pratama

unread,
Mar 17, 2020, 4:45:52 AM3/17/20
to vim/vim, Subscribed

I've tried the latest development version, nothing happens. I think in my case the problem wasn't caused by netrw. For your information, I encountered the error (E382) when trying to save .vimrc and .bachrc, just these 2 files. I guess it was caused when I try to install some plugin, I don't know.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or unsubscribe.

M Imam Pratama

unread,
Apr 12, 2020, 1:18:52 AM4/12/20
to vim/vim, Subscribed

I face this problem when trying to save particular local files. If you are like me, you might only need to run :set bt= or :set buftype= command in vim to solve the problem once and for all for that particular file.

I think I just found the cause, it's related to #4738.

How to reproduce:

  1. Open a file that has some URLs in it.
  2. Try to save the file (it should work).
  3. Try to open a URL with gx, encounter this behavior.
  4. Open the file again, try to save it, encounter error E382.
  5. Fix the error with :set bt=.
  6. Repeat.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or unsubscribe.

Reply all
Reply to author
Forward
0 new messages