alfredodeza/khuno.vim

khuno work well on Ubuntu, but an error occurred when used on opensuse system.

oiuww09fn opened this issue · 23 comments

khuno

after i click enter to continue, khuno can work well until click Esc after the file contents changed.

I had checked all the permissions are right.

I guess I am not expecting to have permission errors on temporary directories... At the very least, Khuno should report this better, rather than giving back a traceback.

You say that if you continue everything works right, but does that mean that errors get parsed correctly? That would be odd because the plugin relies on being able to read back from tmp files.

Does that directory exist? You mention that you checked permissions and they are right, but can you share the permissions from that path?

the permissions are just the same as ubuntu`s:
tmp/vSpcQmd/7
777 / 700 / 644

The error also occurred when I click Esc as long as there are changes to the file.

And I am wondering why the tmpfile not be created before click Enter but after?

The reason why is because it is assumed that there where some changes made after hitting escape.

Oh, this looks like it is not permissions related, it looks like there is a race condition somewhere where that file does not exist anymore (some how)

Can you please describe the exact way to replicate this issue? From the time you first open Vim until you hit the error, step by step?

When you hit this problem, can you also include the output of :Khuno debug ?

  1. vi hello.py
    1
  2. After click Enter
    2
  3. then i edit the py file.
    3
  4. and click Esc
    4
  5. and after click Enter again
    6

The output of Khuno debug may be something like that:
7

I think this may be a race condition when removing old tmp files. Can you try to comment (or remove) this block:

  " Attempt to remove previous run temporary files
  if has_key(b:khuno_debug, 'temp_file')
    call delete(b:khuno_debug.temp_file)
  endif
  if has_key(b:khuno_debug, 'temp_python_file')
    call delete(b:khuno_debug.temp_python_file)
  endif
  if has_key(b:khuno_debug, 'temp_error')
    call delete(b:khuno_debug.temp_error)
  endif

It is in the s:Flake() function. And then try again?

Same Error.

i think i`d better working on ubuntu.

Oh, same error occurred on Ubuntu. But not common.

Ugh, that is terrible. I really want to get to the bottom of this. At least we are narrowing it down to not having to do with the removal of temporary files.

Would you be able to debug a bit more looking at what the code is doing?

Everything starts when the s:Flake() function gets called and the files get created.

The thing here is that I cannot (and have not ever been able to) replicate this problem so I need to rely on you looking into it so I can attempt a fix.

Hi folks, I've also had this problem, it was on a Gentoo system. On Ubuntu it works fine for me as well. I may have some time tonight to check whether it's still happening on the Gentoo machine and maybe do some debugging!

Was able to replicate, it all looks like tempname() from Vim fails to create the containing directory (for whatever reason).

I should get this fixed soon.

@QuentinJi @reinhardt can you guys try this fix? It seems that it gets rid of the problem:

if !exists(tempname())
  let temp_location = fnamemodify(tempname(),":p:h:")
  execute ":! mkdir " . temp_location
endif

At the very top after the if exists("g:loaded_khuno") block.

What is happening here is that the OS is removing temporary directories and Vim is unaware of it and assumed the directory is still there. So any calls to tempname() will return a broken path.

If you guys can confirm that this also works for you I will make a patch and release.

vim_error

if exists('g:loaded_mark') || (v:version == 701 && ! exists('*matchadd')) || (v:version < 701)
  finish
endif

if exists("g:loaded_khuno") || &cp
  finish
endif

if !exists(tempname())
  let temp_location = fnamemodify(tempname(),":p:h:")
  execute ":! mkdir " . temp_location
endif

let g:loaded_khuno = 1

is that right? did no work!

@QuentinJi what happens if you manually create that missing directory? The problem here is that the OS is messing up how Vim uses temporary directories.

Say if it complains it can't open file /tmp/FOO/3 then try and do :! mkdir /tmp/FOO and see if you can move on.

It might be that I just need to add a check in more places

When it complains the file /tmp/FOO/3 already been there.
Why the file already been created but it compalins it can't open?

I can't reproduce this any further. You will need to debug this a bit more so I can attempt a better solution

@QuentinJi can you try the latest changes to see if they address your problem?

Great job! Now works fine for me! @alfredodeza Thanks a lot!

I am still getting this error. Every .py file the first time I open it, or change into it's tab.

@aarcro Please check the version of vim. if it`s <=7.3, you could update to vim7.4. And then have a try.

Thanks, it does seem to work better on 7.4. But I know it was working for awhile on 12.04's Vim 7.3-429

@aarcro if you have a way to replicate your problem reliably, please open a new issue, don't hijack this one. The Vim versions should not be a problem, this specific issue was fixed with c2ad032