I just updated all of your text editor plugins. What’s your reaction? Something like this?

text editor lock file
It’s been years since you’ve updated all those plugins, hasn’t it? Who cares about those new features, bug fixes, or performance and security improvements? Just cross your fingers and hope your laptop doesn’t die forcing you to upgrade. Better yet, you’ve got a full image backup, right? That way you can keep those crusty old plugins forever.

It’s understandable to wince at the thought of updating those plugins. Most developers have been burned for one reason or another. Besides, who has time for that crap? After you update you run into some obscure conflict between plugins, or the author pushed a beta version. Even worse, that fancy new version of the plugin is a real performance bottleneck.

And of course the issues never seem to crop up immediately after doing the update but instead at the most inopportune time. It’s several days later and you’ve got a deadline approaching. You don’t have an easy way to revert your update. Heck you don’t even know which plugin is the culprit. Now you have to make a choice. Do you slog through debugging your editor or disable plugins, continuing your work with one hand tied behind your back?

Updating your plugins doesn’t have to be this painful though. Wouldn’t it be nice if your editor plugins had a lock file like your application dependencies do? (You lock your application dependencies, don’t you?) Then you could add that file to version control. Going back to your old setup would be like snapping your fingers. Just checkout the previous commit and run the install command. Sounds obvious in hindsight, right?

I’ve kept my plugins in a plugin.lock file for about a year now, and it has been wonderful. It works exactly like you would expect. I update my plugins every couple months. If I run into an issue and don’t feel like dealing with it immediately then I can quickly revert. For debugging, I can do a quick git diff to see which plugins were recently updated. If one plugin is misbehaving I pull the old version from my git history and continue on my way. If I’m desperate to determine which plugin is misbehaving I can even do a binary search (Recursively revert half the versions and check if the problem still exists).

Creating and using your very own plugin.lock file is really easy. I have a few examples below for popular editors.

VIM

Using the popular VIM plugin manager vim-plug

Create your lock file…
:PlugSnapshot plugin.lock

Restore from your lock file…
:source plugin.lock

Atom

Create your lock file…
apm list --installed --bare | xargs -L 1 echo apm install > plugin.lock

Restore from your lock file…
sh plugin.lock

VS Code

The insiders version of Visual Studio Code Supports this.

Disable auto extension updating (if you haven’t done so already)

text editor lock file
Create your lock file…
code-insiders --list-extensions --show-versions | xargs -L 1 echo code-insiders --install-extension > plugin.lock

Restore from your lock file…
sh plugin.lock

———————-

If you have instructions for creating a plugin.lock in other editors please let me know in the comments!

Leave a Reply

Your email address will not be published. Required fields are marked *