-
Notifications
You must be signed in to change notification settings - Fork 0
Fail fast if our python dependencies aren't installed – closes #236 #368
Conversation
e9facef to
10896bc
Compare
We were jumping through some weird hoops to avoid early imports that might have prevented the plugin from loading entirely, with bad error messaging. But that resulted in the plugin getting a lot further into execution than it should (including starting the server), since it can't do anything useful without these deps installed. I came up with a way to validate the deps before our Python modules load, so now we can import normally in our code. Closes #236
10896bc to
ef161ff
Compare
| self.ensime_server = gconfig["ensime_server"].format(port, uri) | ||
| with catch(Exception, disable_completely): | ||
| from websocket import create_connection | ||
| with catch(websocket.WebSocketException, disable_completely): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bonus benefit: we can catch properly scoped exceptions now in several places, this one should only be a WebSocketException and not also ImportError.
ktonga
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done!
I think it's perfectly acceptable, this will help newcomers way more than "restless" users who do weird stuff with their environments :)
On the same page, I have been thinking we could implement a Neovim Health Checker. What you reckon?
That's pretty nifty, I didn't even know the ability for plugins to hook into that got implemented. Too much stuff happening in Neovim for me to keep up with 😄 Okay cool, I'll merge this then because it's going to conflict with #367 so I'll rebase it. |
|
For future nvim users, who may experience problems after this update and google for traceback. After updating all plugins I started to see following warning after Problem was in Sorry if this is irrelevant, but it took some time for me to figure out problem and culprit plugin. |
|
@chuwy That's interesting, this should be compatible with standard Vim's Python interface as well, not Neovim-specific. Can you report the |
|
Hey @ches, sure. This is standard Mac OS El Capitan vim, placed in Obviously this also fails on simple |
|
Okay thanks, I tried on the stock |
Closes #369, refs #368 (1b32e85) There are other uses of Vim 7.4+ Python API in our code, this does not attempt to fix all of them. This just avoids a particularly bad failure mode during Vim startup.
We were jumping through some weird hoops to avoid early imports that might have prevented the plugin from loading entirely, with bad error messaging. But that resulted in the plugin getting a lot further into execution than it should (including starting the server), since it can't do anything useful without these deps installed.
I came up with a way to validate the deps before our Python modules load, so now we can import normally in our code. This works in Vim and Neovim, prompting the user with a message when starting up if a dependency is missing.
There is one edge case: if a Neovim user has already used ensime-vim before and has generated the rplugin manifest, Neovim is going to load it. In the case that they've inadvertently removed one of the deps or their Python environment changed or whatever, they'll first be shown the message at startup as usual about missing deps (pausing for them to hit Enter), but then Neovim will start reporting errors about the autocmd handlers not working.
I think this is acceptable, the user still gets the helpful error message first and just needs to quit the editor and fix it. Plus it's a fairly unusual case. What do you think? I can't see a way to avoid this except to have every function in the rplugin do an
ImportErrorcheck before callingsuper, or something gross like that. This is an unfortunate consequence of the whole:UpdateRemotePluginscached manifest system.