VundleVim / Vundle.vim

Vundle, the plug-in manager for Vim
http://github.com/VundleVim/Vundle.Vim
MIT License
23.85k stars 2.56k forks source link

Error loading plugins with DOS formatting (^M problem) #6

Closed oryband closed 10 years ago

oryband commented 13 years ago

Hi.

I think there is a problem loading plugins with DOS formatting.

For example, add this bundle to your .vimrc and install it: Bundle "CSS3-Highlights"

Then, try to open a *.css file, and you will get the following errors:

Error detected while processing /Users/ory/Documents/dotfiles/vim/bundle/CSS3-Highlights/syntax/css.vim:

line    8: E492: Not an editor command: ^M
line   11: E15:  Invalid expression: !exists("main_syntax")^M
line  303: E488: Trailing characters
line  309: E171: Missing :endif

This happened on another plugin as well: Bundle "Better-CSS-Syntax-for-Vim"

I'm using both MacVim & Vim, OSX 10.6.6 Snow Leopard.

Thanks very much for your time! Your plugin is amazing! Ory

gmarik commented 13 years ago

Hey Ory! Thanks for reporting issue! I'll check what is causing those errors...

gmarik commented 13 years ago

So yeah, fileformat is dos, that's why sourcing fails. Need to dig a bit more for a workaround...

gmarik commented 13 years ago

Looks like the author recommends fixing this manually:

I wrote this script under Windows and different OS has different file formats, so do as following: Create a new empty css.vim file in syntax folder, and copy this code to the new one

Also i didn't find any "smart" workarounds :(

But i'd say: github-fork https://github.com/vim-scripts/Better-CSS-Syntax-for-Vim , fix ^Ms and use own repo like this:

Bundle https://github.com/oryband/Better-CSS-Syntax-for-Vim.git

in .vimrc

Other than that it's a good case to improve error handing in Vundle.

Let me know what you think.

Thanks!

oryband commented 13 years ago

This sounds like an acceptable solution.

But can't we remove the ^M on-the-fly? There's a way to do it with regex.

Perhaps we can load the script's content to a buffer, and do the search-and-replace on the buffer instead on the file itself. I am not a Vim script writer, so I don't have too much of an idea if this is even possible, though.

There must be a way...

Thank you very much for your time, any way. :)

Cheers!

gmarik commented 13 years ago

sure we can do that. You're 100% right: technically it's not an issue! But do you think it's the Vundle "responsibility" to "fix" scripts? :) Personally, at this point, I tend to think it's Vim's issue. Why would it treat files with dos filetype as invalid for sourceing? Even if we settle to implement this feature in Vundle it goes at the bottom of the TODO, because there are higher priority stuff, Ie error handling )

Let me know what you think...! ) Thanks!

oryband commented 13 years ago

Well, first of all, if I'm not wrong, Windows' VIm can handle Unix-style formatting, so doing this in Vundle as a default action won't really harm anything for the Windows users.

This is a Vim bug and thus a Vim responsibility, but I think Vundle should be able to cope with this kind of problem until it's fixed. This is because Vundle also handles plugin's updates.

Imagine the user having to manually remove the ^Ms from a random bundle/script.vim every new update. Really frustrating, and kinda kills the whole point of using Vundle in the first place.

Perhaps there's a solution for this. We should ask in some official Vim forum or something.

gmarik commented 13 years ago

I understand your point. You want this automated. I think there's a way Vundle can help you. But this will be implemented as part of another feature and will be configurable per user. Stay tuned! )

oryband commented 13 years ago

Awesome, thanks. :)

gmarik commented 13 years ago

Hey! Will you have some time to do testing...?! 8) I'll provide you with instructions if you're interested. Yes, it's related to this particular issue. (not yet releasing it as want to get some feedback first)

Please let me know...) Thank you!

oryband commented 13 years ago

Ill be glad to. I've even got a plugin i just found that causes this.

Lemme know what you need.

reply@reply.github.com wrote:

Hey! Will you have some time to do testing...?! 8) I'll provide you with instructions if you're interested. Yes, it's related to this particular issue. (not yet releasing it as want to get some feedback first)

Please let me know...) Thank you!

Reply to this email directly or view it on GitHub: https://github.com/gmarik/vundle/issues/6#comment_1120429

gmarik commented 13 years ago

Cool! Then what i'd like you to try out is:

  1. read this helpful gist
  2. put those hooks into your vimrc
  3. follow the instructions(from gist), checkout events branch, install bundles make sure all works )

After that - just let me know what you think and what needs to be improved.

oryband commented 13 years ago

Hey.

I didn't quite unserstand why I needed the hooks you mentioned. I just updated to the 0.9 preview (events) branch and tried the windows-encoded plugin that caused me these problems.

Unfortunately, I don't think the problem was fixed. Maybe I just skipped something and did it all wrong.

You can test the problematic plugin if you'd like to see what I mean - It's called QFixToggle, used for toggelling the quickfix window on and off.

This is the error I'm receiving:

Error detected while processing /Users/ory/Documents/dotfiles/vim/bundle/QFixToggle/plugin/qfixtoggle.vim:
line    8:   E15:  Invalid expression: exists('g:QFixToggle_Loaded')^M
line   54:   E171: Missing :endif

Just noting - If you edit the file and remove the ^Ms yourself, the errors are gone.

gmarik commented 13 years ago

Hooks are required, for now, just to test stuff. As u can see in the test/vimrc hook is used to fix newlines and it works fine.

The only issue is that those hooks should be incapsuled in Vundle, and just trigger when specified by option

oryband commented 13 years ago

Alrighty then.

One thing to note though - I think you linked to the wrong hook lines (specific lines in that vimrc link) - Check the links - They lead to installing these:

Bundle '~/Dropbox/.gitrepos/utilz.vim.git'
Bundle 'rstacruz/sparkup.git', {'rtp': 'vim/'}

Are you sure you didn't meant to install these and not something else? This looks more to the point:

augroup user#css3-highlights
  au!
  au User BundleInstallPre  ! [ -d .git ] &&  git reset --hard
  au User BundleInstallPost ! vim **/*.vim  +'bufdo set fileformat=unix | wall | qall'
augroup end
gmarik commented 13 years ago

Oh, im so sorry for confusing you...( I should have locked url to the certain revision Yes, you're correct: the augroup is what you need to get css3-highlights fixed!

Sorry again! )

oryband commented 13 years ago

Thanks for pointing that out.

  1. I tried doing what you asked with my problematic plugin (QFix-Toggle), substituting the first line to augroup user#qfix-toggle , and the problem wasn't resolved. Note that I'm using a Mac, so in my case the fileformat should be =mac, I guess. In any case, =unix didn't work.
  2. Furthermore, it appears Vundle is pulling changes / updating twice. This is what I get when executing BundleInstall!:

    ...
    
    Installed python.vim--Vasiliev
    cd /Users/ory/.vim/bundle/indentpython.vim
    Already up-to-date.
    Already up-to-date.
    
    Installed indentpython.vim
    cd /Users/ory/.vim/bundle/syntastic
    Already up-to-date.
    Already up-to-date.
    
    Installed syntastic
    cd /Users/ory/.vim/bundle/nerdcommenter
    Already up-to-date.
    Already up-to-date.
    
    ...

It goes like this for every plugin I'm installing/updating.

gmarik commented 13 years ago

Ok, looks like now I have stuff to dig into! ) I'll get back to you once I find out what went wrong... Thanks for taking time to check it out!

oryband commented 13 years ago

Good luck mate. It's a great plugin you developed there. :)

gmarik commented 13 years ago

Ok, lets try other way. Could you please test test/vimrc config ? It works for me, so, i hope, it will work for you too...

Instructions:

1) clone vundle somewhere: git clone http://github.com/gmarik/vundle /tmp/vundle 2) cd /tmp/vundle && git checkout -b events origin/events 3) vim -u test/vimrc +BundleInstall

Will clone plugins to /tmp/vundle_bundles_events/ and launch vim with test configuration...

If everything goes ok, you should have css3-highlights with replaced newlines.

Also if you could please share config you've been testing css3-highlights with - that'd be great! Thanks!

oryband commented 13 years ago

Hmm.

That's kinda funny - I'm getting a segfault on my OS X Snow Leopard 10.6.7

Already Installed vundle
Cloning into /tmp/vundle_bundles_events/molokai...
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 11 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (11/11), done.

Installed molokai
Cloning into /tmp/vundle_bundles_events/ragtag.vim...
remote: Counting objects: 18, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 18 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (18/18), done.

Installed ragtag.vim
Cloning into /tmp/vundle_bundles_events/vim-colors-solarized...
remote: Counting objects: 336, done.
remote: Compressing objects: 100% (188/188), done.
remote: Total 336 (delta 102), reused 307 (delta 76)
Receiving objects: 100% (336/336), 89.66 KiB | 76 KiB/s, done.
Resolving deltas: 100% (102/102), done.

Installed vim-colors-solarized
Cloning into /tmp/vundle_bundles_events/vim-mac-classic-theme...
remote: Counting objects: 180, done.
remote: Compressing objects: 100% (84/84), done.
remote: Total 180 (delta 49), reused 175 (delta 48)
Receiving objects: 100% (180/180), 23.07 KiB, done.
Resolving deltas: 100% (49/49), done.

Installed vim-mac-classic-theme
Cloning into /tmp/vundle_bundles_events/snipmate.vim...
remote: Counting objects: 811, done.
remote: Compressing objects: 100% (320/320), done.
remote: Total 811 (delta 398), reused 749 (delta 362)
Receiving objects: 100% (811/811), 140.95 KiB | 100 KiB/s, done.
Resolving deltas: 100% (398/398), done.

Installed snipmate.vim
Cloning into /tmp/vundle_bundles_events/gist-vim...
remote: Counting objects: 647, done.
remote: Compressing objects: 100% (354/354), done.
remote: Total 647 (delta 276), reused 462 (delta 184)
Receiving objects: 100% (647/647), 78.12 KiB | 73 KiB/s, done.
Resolving deltas: 100% (276/276), done.

Installed gist-vim
fatal: repository '/Users/ory/Dropbox/.gitrepos/utilz.vim.git' does not exist

Installed utilz.vim
Cloning into /tmp/vundle_bundles_events/sparkup...
remote: Counting objects: 435, done.
remote: Compressing objects: 100% (194/194), done.
remote: Total 435 (delta 164), reused 417 (delta 154)
Receiving objects: 100% (435/435), 88.53 KiB | 71 KiB/s, done.
Resolving deltas: 100% (164/164), done.

Installed sparkup
Cloning into /tmp/vundle_bundles_events/RubySinatra...
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 17 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (17/17), done.

Installed RubySinatra
Installing Command-T
Cloning into /tmp/vundle_bundles_events/Command-T...
remote: Counting objects: 2248, done.
remote: Compressing objects: 100% (925/925), done.
remote: Total 2248 (delta 1219), reused 2148 (delta 1125)
Press ENTER or type command to continue

Receiving objects: 100% (2248/2248), 362.39 KiB | 174 KiB/s, done.
Resolving deltas: 100% (1219/1219), done.

No matching autocommands
Installed Command-T
Running command-t hooks
:!cd ruby/command-t && ruby extconf.rb && make clean && make
checking for ruby.h... yes
creating Makefile
/usr/bin/cc -I. -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1/x86_64-darwin10.7.0 -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1/ruby/backward -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1 -I. -DHAVE_RUBY_H -I/usr/local/Cellar/readline/6.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -O3 -march=core2 -msse4.1 -w -pipe -fno-common  -std=c99 -Wall -Wextra -Wno-unused-parameter -o ext.o -c ext.c
/usr/bin/cc -I. -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1/x86_64-darwin10.7.0 -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1/ruby/backward -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1 -I. -DHAVE_RUBY_H -I/usr/local/Cellar/readline/6.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -O3 -march=core2 -msse4.1 -w -pipe -fno-common  -std=c99 -Wall -Wextra -Wno-unused-parameter -o match.o -c match.c
/usr/bin/cc -I. -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1/x86_64-darwin10.7.0 -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1/ruby/backward -I/usr/local/Cellar/ruby/1.9.2-p180/include/ruby-1.9.1 -I. -DHAVE_RUBY_H -I/usr/local/Cellar/readline/6.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -O3 -march=core2 -msse4.1 -w -pipe -fno-common  -std=c99 -Wall -Wextra -Wno-unused-parameter -o matcher.o -c matcher.c
/usr/bin/cc -dynamic -bundle -o ext.bundle ext.o match.o matcher.o -L. -L/usr/local/Cellar/ruby/1.9.2-p180/lib -L. -L/usr/local/Cellar/readline/6.1/lib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace  -lruby.1.9.1  -lpthread -ldl -lobjc 
:![ -f doc/readme.txt -a -f doc/command-t.txt ] && rm doc/README.txt

shell returned 1
Please restart Vim for command-t to work
Installing CSS3-Highlights
:! [ -d .git ] &&  git reset --hard

shell returned 1
Cloning into /tmp/vundle_bundles_events/CSS3-Highlights...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
No matching autocommands
Installed CSS3-Highlights
:! vim **/*.vim  +'bufdo set fileformat=unix | wall | qall'
ShowMarks requires Vim to have +signs support.
Press ENTER or type command to continue
Already Installed test
Installing a_plugin
Installed a_plugin
Installing zzz
Vim: Caught deadly signal SEGV

Vim: Finished.
Segmentation fault
gmarik commented 13 years ago

wow! 0_0

oryband commented 13 years ago

The primary data is in the last lines. I just pasted the whole thing, thought it might be useful.

I guess you're speechless. :)

Did you test this on other macs besides your own? Perhaps it'll be easier to identify the problem this way.

gmarik commented 13 years ago

Yeah totally unexpected result! I am speechless ) I've tested on 2 macs running 10.6.7 and had no problems...

What Vim version do you have?

And thanks for taking time to report on this, definitely requires more digging...

oryband commented 13 years ago

Don't be angry at another terminal print-out:

~$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Apr  5 2011 13:25:35)
MacOS X (unix) version
Included patches: 1-107
Compiled by ory@Ory.local
Huge version with MacVim GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+conceal +cryptv -cscope +cursorbind +cursorshape +dialog_con_gui +diff 
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi 
+file_in_path +find_in_path +float +folding -footer +fork() +fullscreen 
-gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap 
+libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession 
+modify_fname +mouse +mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm 
+mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme 
+netbeans_intg +odbeditor -osfiletype +path_extra +perl +persistent_undo 
+postscript +printer +profile +python -python3 +quickfix +reltime +rightleft 
+ruby +scrollbind +signs +smartindent -sniff +startuptime +statusline 
-sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white +tcl +terminfo
 +termresponse +textobjects +title +toolbar +transparency +user_commands 
+vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore 
+wildmenu +windows +writebackup -X11 -xfontset +xim -xsmp -xterm_clipboard 
-xterm_save 
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X_UNIX -no-cpp-precomp  -g -O2 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -arch x86_64 -D_FORTIFY_SOURCE=1    -I/System/Library/Frameworks/Tcl.framework/Headers  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_DARWIN_C_SOURCE=1  
Linking: gcc   -L.   -L.        -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -arch x86_64 -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon      -lncurses  -liconv -framework Cocoa    -L/usr/local/lib  -L/System/Library/Perl/5.10.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -framework Python  -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -framework Ruby

I've installed it using Homebrew, which is one of the most popular ways to install MacVim nowadays.

gmarik commented 13 years ago

I actually enjoy terminal print-outs ;)) The most weird thing from first print-out is ShowMarks requires Vim to have +signs support.

which means that :! vim **/*.vim +'bufdo set fileformat=unix | wall | qall' is picking up your configuration, which is totally unnecessary

But still I have no idea how that would make vim crash...

itwars commented 12 years ago

I got the same issue with many plugin ... Anyway for the moment I solved it by editing the DOS file, :set ff=unix and :w An automatic OS detection by vundle could be great ;)

Regards

Taverius commented 12 years ago

You should probably be using the git CRLF settings to do auto-conversion on pull, as appropriate for the host system.

The settings are core.safecrlf, core.autocrlf, core.eol ...

These can be set per-repo, so Vundle should be able to set them on clone, without affecting the global value - or so I understand; since I'm on windows myself, DOS-formatted syntax files don''t give me any issues, so I've never untangled that ball of string myself.

gmarik commented 12 years ago

@Taverius good idea! I'll play with that! Thx!

technogeeky commented 12 years ago

Just started dealing with this issue myself.

Part of the complication is this:

I'm going to try using the CRLF auto-conversion trick.

technogeeky commented 12 years ago

Evidently git 1.7.5 doesn't have git clone --config or git clone -c options.

technogeeky commented 12 years ago

Augmenting /etc/gitconfig with:

[core]
    autocrlf = false
    safecrlf = true
    eol       = lf

worked fine. No more noise, works in vim.exe (msys) and gvim.exe (Windows native).

gmarik commented 12 years ago

So I believe setting

[core]
    autocrlf = false
    safecrlf = true
    eol       = lf

per bundle fixes this issue.

Thanks for digging into, @technogeeky!

oryband commented 12 years ago

@gmarik: So... are we sure this solution fixes the issue?

gmarik commented 12 years ago

@oryband, i've not played with this solution myself yet... will keep you posted!

MarcWeber commented 10 years ago

dup of #333

Zenexer commented 10 years ago

Wouldn't the easiest solution be to force LF line endings in .gitattributes? That file would be committed to the repository and would instruct clients to clone certain files with LF line endings. That would need to be done for all bundles, too, but it's a "proper" fix.

starcraftman commented 10 years ago

@Zenexer You have pointed out why it isn't really a solution to put the git attributes. It'd only affect Vundle. All other plugins would be equally broken likely with all their bash/vim files being wrong (they'd have to also do it). I think it might be better to add an entry to the FAQ regarding cygwin and dos line endings. Strictly speaking, it's more of a user config thing as the repos never should have dos formatting committed.

Zenexer commented 10 years ago

@starcraftman Would the be any harm in forcing it with .gitattributes though? It seems like a simple fix that would at least solve some problems and set an example for other repositories.

It's not really a user configuration issue. Programs should be able to handle native line endings. If they can't, it's the repository's job to mark files for such programs as being sensitive to particular line endings. This is not the user's job.

jdevera commented 10 years ago

This can be controlled globally with git configuration. See core.eol setting and core.autocrlf.

Closing, nothing to do with Vundle.

EnriqueBet commented 7 years ago

Hi! I have the same problem with lots of vim plugins that had been written in Windows. First I tried to change my my terminal config to be compatible with .vim files written in Windows, but I wasn't successful.

So I wrote a small code on python that I think might work for most linux users. It depends on dos2unix which is already installed in most linux distros. The code will assume that your .vim directory is under /home/userName/.vim and it will find all .vim files under that directory and then run dos2unix -f file.vim. It works pretty good for me, hope this helps :D

vimfix.py: https://github.com/PajaroImitador/zsh_config/blob/master/vimfix.py