firenvim icon indicating copy to clipboard operation
firenvim copied to clipboard

one-byte file exists before it is saved

Open mcepl opened this issue 3 years ago • 7 comments

  • OS Version: Linux/openSUSE/Tumbleweed (i.e., a rolling distro as of 2022-07-29)
  • Browser Version: MozillaFirefox-102.0.1-1.1.x86_64 (from the distro package)
  • Browser Addon Version: 0.2.13
  • Neovim Plugin Version: commit f679455c294c62eddee86959cfc9f1b1f79fe97d

What I tried to do

Save buffer edited in neovim.

What happened

I got message “E13: File exists” (loosely back-translated from Czech).

Additional data

When I open the buffer in neovim (without saving anything), firenvim actually creates the edited file in question and it is non-empty:

stitny:/run/user/1000/firenvim # stat bugzilla.suse.com_attachment-cgi_TEXTAREA-id-comment_2022-07-29T15-15-45-469Z.txt
  File: bugzilla.suse.com_attachment-cgi_TEXTAREA-id-comment_2022-07-29T15-15-45-469Z.txt
  Size: 1         	Blocks: 8          IO Block: 4096   regular file
Device: 0,87	Inode: 1022        Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   matej)   Gid: (  100/   users)
Context: system_u:object_r:user_tmp_t:s0
Access: 2022-07-29 17:15:45.480109271 +0200
Modify: 2022-07-29 17:15:45.468109091 +0200
Change: 2022-07-29 17:15:45.468109091 +0200
 Birth: 2022-07-29 17:15:45.468109091 +0200
stitny:/run/user/1000/firenvim # cat bugzilla.suse.com_attachment-cgi_TEXTAREA-id-comment_2022-07-29T15-15-45-469Z.txt |od -x
0000000 000a
0000001
stitny:/run/user/1000/firenvim # 

mcepl avatar Jul 29 '22 15:07 mcepl

Does this also happen when you remove all of your plugins (including the ones loaded automatically loaded by neovim, e.g. those in ~/.config/nvim/pack) except firenvim?

glacambre avatar Jul 30 '22 12:07 glacambre

Everything is commented out:

stitny~/.c/n/plugin (master *)$ rg -v -- '--' plugins.lua
2:
4:vim.cmd [[packadd packer.nvim]]
5:
6:return require('packer').startup(function(use)
8:  use {'wbthomason/packer.nvim'}
24:  use {'glacambre/firenvim'}
88:end)
stitny~/.c/n/plugin (master *)$ cat firenvim.lua 
if vim.fn.exists('g:started_by_firenvim') == 1 then
    vim.g.fzf_layout = { down = "~40%" }
    vim.opt.textwidth = 0
end
vim.g.firenvim_config = {
    localSettings = {
        [".*"] = { selector = "textarea", priority = 0 },
        ["translate.google.com"] = { selector = "" },
        -- [".*reddit.com"] = { selector = "div.DraftEditor-root span[data-text='true']" },
        [".*twitter.com"] = { selector = "" },
        ["trello.com"] = { selector = "" },
        ["chat.suse.de"] = { selector = "" },
        ["jira.suse.com"] = { selector = "" },
        ["stackoverflow.com"] = { selector = "" },
        [".*.stackexchange.com"] = { selector = "" },
        ["floss.social"] = { selector = "" },
        ["https://www.openstreetmap.org/edit"] = { selector = "" },
        ["https://build.opensuse.org/package/view_file/"] = { selector = "" }
    }
}
vim.api.nvim_create_autocmd({"BufNewFile", "BufRead"}, {
    pattern="/run/user/*/firenvim/*",
    command="set ft=markdown wrap spell nonu nornu spelllang=en_gb tw=0 fo-=a \\| :let g:fzf_layout = { 'down': '40%' }",
})
stitny~/.c/n/plugin (master *)$ 

And I get exactly the same error in this very text comment box (and yes, I have restarted Firefox and rerun :PackerSync multiple times).

mcepl avatar Jul 30 '22 15:07 mcepl

I started having this problem across all my systems with a previously working config a month or so ago. I decided to bite the bullet and covert my aging vimrc setup to Lua before I tried to figure out what was wrong here. That's done now and the Lua is much saner, but this problem didn't go away. I still have to :w! when first opening a Firenvim client or it will throw an error.

alerque avatar Mar 07 '23 18:03 alerque

@alerque could you try the following steps:

  • Update the firenvim neovim plugin to its latest version
  • Run firenvim#install() again
  • Then, edit $XDG_DATA_HOME/.local/share/firenvim/firenvim to add --clean and -u /tmp/tmp.vim to the line that starts with exec , ideally before the --headless argument.
  • Finally, create /tmp/tmp.vim with the following content:
if !isdirectory('/tmp/firenvim')
  !git clone https://github.com/glacambre/firenvim /tmp/firenvim
endif

set rtp+=/tmp/firenvim

Afterwards, try using Firenvim on Github or txti.es. Does the problem still happen?

glacambre avatar Mar 07 '23 19:03 glacambre

  • Currently on 0.2.14 extension, HEAD for VIM plugin
  • Reran install, got: Installed native manifest for firefox.
  • Edited
  • Added

No, now the problem doesn't still happen.

alerque avatar Mar 07 '23 19:03 alerque

Great, thank you! So this must be a bad interaction with another plugin. Could you try to perform a binary search to find out which one is causing this?

From looking at your list of plugins, I see a few I feel could be responsible (ale, telescope, noice...) but that's mostly because they're complex beasts, not because I know what could be going wrong :/

glacambre avatar Mar 07 '23 20:03 glacambre

Ale I have commented out locally even though the dotfiles repo doesn't reflect that, but yes I'll poke through some of the others and see if I can find any clues.

alerque avatar Mar 07 '23 21:03 alerque