MarcWeber / vim-addon-manager

manage and install vim plugins (including their dependencies) in a sane way. If you have any trouble contact me. Usually I reply within 24 hours
Other
660 stars 59 forks source link

E605: Exception not caught: Failed to read json file "vimorgsources.json" #80

Closed qmmr closed 11 years ago

qmmr commented 12 years ago

Hi,

I got an error when trying to run VAM for the first time. After downloading via git known resources repo, unzipping it I get this error. I'm working on Windows 7 32. Could you help me with this problem?

The printscreen of the error is here https://www.evernote.com/shard/s24/res/5cbbdebb-3d8f-49ba-b735-1ab20d72f17f/vam_error.png

MarcWeber commented 12 years ago

Give this a try: http://mawercer.de/~marc/vam/index.php It should fetch both VAM and VAM-kr using linux additionally to the plugins you want. If this works for you we can try narrowing it down. Most of us use Windows seldomly. THere is a ^M in your log which makes me think that a "\r\n" windows line ending might be causing trouble.

The code reading the json can be found in autoload/vamkr.vim "eval(join(readfile(file, 'b'), ''))" (line 21)

Minimal code for testing:

 call vam#install#LoadKnownRepos()
 echo len(vamkr#LoadDBFile('vimorgsources.json'))

should show 4097 or such. Can you experiment with

dropping the 'b' flag
setting file format of that json file to unix? (set ff=unix)

? Thanks for helping to improve the windows installation :)

qmmr commented 12 years ago

The link you provided helped. However I tried to experiment with your ideas, but they do not work.

try
    set ff=unix
    return eval(join(readfile(file), ''))
catch /.*/
    throw 'Failed to read json file “'.file.'”: '.v:exception
endtry

Do you have any other ideas?

MarcWeber commented 12 years ago

I meant ensure that the json file has linux endings. Try this code: it first splits and opens the file, sets ff to unix, then writes and closes the split before before trying to read it. This is for testing only.

exec 'sp '. fnameescape(file) set ff=unix wq

qmmr commented 12 years ago
try
    exec 'sp ' . fnameescape(file)
    set ff=unix
    wq
    return eval(join(readfile(file), ''))
catch /.*/
    throw 'Failed to read json file “'.file.'”: '.v:exception
endtry

This does not work.

<addons\vim-addon-manager-known-repositories\db\vimorgsources.json
" 

<er-known-repositories\db\vimorgsources.json" [noeol] 4101L, 802106C

<addons\vim-addon-manager-known-repositories\db\vimorgsources.json
" 

<n-repositories\db\vimorgsources.json" [unix] 4101L, 798007C written

Error detected while processing function SetupVAM..vam#ActivateAddons..
vam#ActivateRecursively..vam#install#Install..vam#install#GetRepo..vam#i
nstall#LoadPool..vam#install#Pool..vam_known_repositories#Pool..vamkr#
GetSCMSources..vamkr#LoadDBFile..<SNR>15_Vim:

line   62:

E492: Not an editor command: ^M

Error detected while processing function SetupVAM..vam#ActivateAddons..
vam#ActivateRecursively..vam#install#Install..vam#install#GetRepo..vam#i
nstall#LoadPool..vam#install#Pool:

I tried to convert line endings of json file to unix style via Notepad++ but it produces other error

Error detected while processing function SetupVAM..vam#ActivateAddons..
vam#ActivateRecursively..vam#install#Install..vam#install#GetRepo..vam#i
nstall#LoadPool..vam#install#Pool..vam_known_repositories#Pool..vamkr#
GetSCMSources..vamkr#LoadDBFile..<SNR>15_Vim:

line   62:

E492: Not an editor command: ^M

Error detected while processing function SetupVAM..vam#ActivateAddons..
vam#ActivateRecursively..vam#install#Install..vam#install#GetRepo..vam#i
nstall#LoadPool..vam#install#Pool:
MarcWeber commented 12 years ago

I've confirmed that getting the vimfiles directory via http://mawercer.de/~marc/vam/index.php using the defaults shown there works fine, also :ActivateAddons completion works then. ^M is \r (windows style). Write me an email, or contact me by irc so that we can get this fixed

bjornfor commented 11 years ago

I'm affected by this too (Windows 7 64-bit). I tried http://mawercer.de/~marc/vam/index.php but after a long time I got Server error 500. I have a long list of plugins :-) I also changed vimorgsources.json to unix newlines and got one step further. That is, I got the same error as 'qmmr' above. So it seems that it's more than one file that causes VAM to blow up if running on a platform with CRLF lineendings.

ZyX-I commented 11 years ago

@bjornfor You should be sure all files in db/ have LF line endings. The errors you see come from some .vim file from there, most likely scmsources.vim.

bjornfor commented 11 years ago

Thanks, It works now! I took another look at it and it seems that dos2unix.exe toggles lineendings. (I messed around a bit the first time and might have switched some files back to DOS lineendings...). Now I told dos2unix to explicitly convert to unix and it works. If others experience this, the workaround is: "dos2unix.exe -U *.json" in vim-addon-manager-known-repositories/db/. Or don't use core.autocrlf=true when installing VAM :-)

ZyX-I commented 11 years ago

@bjornfor Wondering two things:

  1. How you can download via git and then unzip?
  2. Does the following VAM-kr commit fix the issue (possibly after recloning the repository)
bjornfor commented 11 years ago

Sorry, I don't understand the first question.

I think your commit fixed it!

However, there was a little "glitch" the first time I tried to activate my plugins. I started with a fresh new clone of VAM and it started to download and clone my plugins. But it stopped after just a few of them had been processed:

Error detected while processing function vam#ActivateAddons..vam#Activa teRecursively..vam#install#Install..vam#install#Checkout..vam#utils#Unpac k..vam#utils#Unpack..vam#utils#ExecInDir..5_Cmd:

line 11:

E605: Exception not caught: Command “tar -xf "C:\Users\bjfo\vim-addo ns/gtk-mode/archive/gtk-mode-0.1.tar"” exited with error code 2

Error detected while processing function vam#ActivateAddons..vam#Activa teRecursively..vam#install#Install..vam#install#Checkout..vam#utils#Unpac k..vam#utils#Unpack:

line 80:

E171: Missing :endif

Error detected while processing function vam#ActivateAddons..vam#Activa teRecursively..vam#install#Install..vam#install#Checkout..vam#utils#Unpac k:

line 68:

E171: Missing :endif

Error detected while processing function vam#ActivateAddons..vam#Activa teRecursively..vam#install#Install..vam#install#Checkout:

line 24:

E171: Missing :endif

Error detected while processing function vam#ActivateAddons..vam#Activa teRecursively..vam#install#Install:

line 46:

E171: Missing :endif

Error detected while processing function vam#ActivateAddons..vam#Activa teRecursively:

line 10:

E171: Missing :endif

I find these error messages rather difficult to parse/understand. Which file is missing an ":endif"? It seemed to be working on the "gtk-mode" plugin, but that's not much of a lead...

Anyway, I closed Vim and opened it again. This time all plugins installed OK (AFAIK, I haven't tested the gtk-mode plugin).

ZyX-I commented 11 years ago

@bjornfor From my point of view “download via git” means

git clone git://github.com/MarcWeber/vim-addon-manager-known-repositories

. In this case there is nothing to “unzip” as you end up with directory and not archive.

About the errors: it means unpacking gtk-mode plugin failed which is stated in the first error message. Missing endifs are vim own bugs appearing when exception is not caught. They should be simply ignored.

bjornfor commented 11 years ago

I was just puzzled by the fact that the "gtk-mode" error was transient; it disappeared the next time I opened Vim. But it's not important to me now. I think this issue can be closed :-)

ZyX-I commented 11 years ago

@bjornfor Of course it disappeared, VAM considered this plugin installed next time vim was run even besides unpack failed. It is a separate issue though.