syntastic icon indicating copy to clipboard operation
syntastic copied to clipboard

Fun with shellslash (was: Errors when using python/python syntax checker)

Open arecarn opened this issue 10 years ago • 11 comments

Using:

  • Windows 7
  • python 2.7.5
  • gVim 7.4.27 or 7.4.50
  • Current version of Syntastic (master HEAD) as of this posting

When using SyntasticCheck python on a python file I get the following error. This error causes no syntax errors to be reported.

Error detected while processing function <SNR>63_UpdateErrors..<SNR>63_CacheErrors..47..SyntaxCheckers_python_python_GetLocList..SyntasticMake:
line   28:
E484: Can't open file C:/Users/arecarn/AppData/Local/Temp/VIoB307.tmp
Error detected while processing function <SNR>63_UpdateErrors..<SNR>63_CacheErrors:
line   25:
E170: Missing :endfor
Error detected while processing function <SNR>63_UpdateErrors:
line   10:
E171: Missing :endif

It also appears that this error may have also been reported, by @TypedLambda here

Like @TypedLambda's comment the file *.tmp file is writable, but does not exist.

P.S. Thanks for making Syntastic awesome!

arecarn avatar Oct 09 '13 06:10 arecarn

Please set g:syntastic_debug, run the checker, and post the output of :mes.

lcd047 avatar Oct 09 '13 06:10 lcd047

As you requested:

syntastic: debug: CacheErrors: g:syntastic_aggregate_errors = 0                                                                                                                                            
syntastic: debug: CacheErrors: Invoking checker: python                                                                                                                                                    
syntastic: debug: SyntasticMake: called with options: {'errorformat': '%E  File "%f"\, line %l,%C    %p^,%C    %.%#,%Z%m,%-G%.%#', 'makeprg': 'python -c ''compile(open(''\''''catAnimation.py''\'''').rea~
d(), ''\''''catAnimation.py''\'''', ''\''''exec''\'''')''  '}                                                                                                                                            
Error detected while processing function <SNR>63_UpdateErrors..<SNR>63_CacheErrors..47..SyntaxCheckers_python_python_GetLocList..SyntasticMake:                                                            
line   28:                                                                                                                                                                                                 
E484: Can't open file C:/Users/arecarn/AppData/Local/Temp/VIo99CE.tmp                                                                                                                                      
Error detected while processing function <SNR>63_UpdateErrors..<SNR>63_CacheErrors:                                                                                                                        
line   25:                                                                                                                                                                                                 
E170: Missing :endfor                                                                                                                                                                                      
Error detected while processing function <SNR>63_UpdateErrors:                                                                                                                                             
line    8:                                                                                                                                                                                                 
E171: Missing :endif                                                                                                                                                                                       

arecarn avatar Oct 09 '13 06:10 arecarn

Please post your settings of shell, shellcmdflag, shellquote, shellxquote, and shellredir.

lcd047 avatar Oct 09 '13 07:10 lcd047

    shell = "C:\Windows\system32\cmd.exe"                                                           
    shellcmdflag = "/c"                                                                             
    shellquote = ""                                                                                 
    shellxquote = "("                                                                               
    shellredir = ">%s 2>&1"                                                                         

arecarn avatar Oct 09 '13 08:10 arecarn

Please post your setting of shellslash.

lcd047 avatar Oct 09 '13 08:10 lcd047

shellslash is set!

switching to noshellslash fixes the problem....

TypedLambda avatar Oct 09 '13 13:10 TypedLambda

Right: what seems to be going on here is that when shellslash is set, Vim function shellescape() won't escape single quotes in a way suitable for cmd.exe. Ideally this should be fixed in Vim, but I suppose there are already a zillion plugins that depend on the current behaviour. :) On the other hand, I don't know enough about Windows quoting rules to fix it in syntastic, and (having dealt almost exclusively with UNIX for the past ~25 years) I don't really care enough to find out how others are doing it. shrug

So, what I'm saying here is, if anybody has a fix for this, please step forward and post a pull request. Otherwise don't mix shellslash with cmd.exe. Or just stay away from Windows. :)

lcd047 avatar Oct 09 '13 16:10 lcd047

I can confirm that the problem was escaping filenames in windows, which fails on certain cases when shellslash is set... @lcd047 - thanks for the help! Besides setting noshellslash for particular bad filenames in windows, is there any other recommended solution you can think of?

I know that Shougou handles this somehow in NeoBundle so it must be possible?

pgilad avatar Apr 07 '14 09:04 pgilad

Besides setting noshellslash for particular bad filenames in windows, is there any other recommended solution you can think of?

Besides what I wrote above? Well, I'm afraid my knowledge about Windows hasn't improved dramatically in the mean time. Sorry about that. shrug

I know that Shougou handles this somehow in NeoBundle so it must be possible?

I'm not sure I'm following you:

$ git clone https://github.com/Shougo/neobundle.vim.git
[...]
$ cd neobundle.vim
$ fgrep -rw shellslash . | wc -l
0
$ fgrep -rw ssl . | wc -l
0

But, if you have reasons to believe Shougo has a solution, perhaps ask him?

lcd047 avatar Apr 07 '14 10:04 lcd047

Hmm, I looked for it too now, and couldn't find where he worked it out. I found a patch he added to Vundle that handles shellslash: https://github.com/Shougo/Vundle.vim/commit/726ee0915a45d8f03b30605b01433bfc8ed529af

Can you point me to where Syntastic handles the escaping for the filename? I'll try to workout a PR if I can fix it...

pgilad avatar Apr 07 '14 10:04 pgilad

If you're serious about trying to fix it, I'd suggest you to start by reading this survery. It isn't the entire story, as a lot of details are actually hidden in the context of the call, and in the difference between system() and :!. Syntastic's escape function is actually copied from vim-dispatch, but hoping for a drop-in replacement seems naive.

lcd047 avatar Apr 07 '14 14:04 lcd047