Skip to main content

How to lock a Drupal module or theme from being upgraded with Drush

If you use Drush for Drupal code updates, and find that the latest version of a module or theme is causing issues on your site, you can freeze that module from being upgraded until the issue is resolved with the following simple command:

drush up module_name --lock=module_name

A file named .drush-lock-update will be placed in the root module or theme directory. You can also lock a module or theme by navigating to its root directory and creating either an empty file or a file with a basic one-line message called .drush-lock-update. If you leave it empty, the message will be "Locked." When you lock using the Drush command above, the measage automatically added to the file is "Locked via drush." You can add any message you like to the .drush-lock-update file, but should consider keeping it short because the message is displayed on subsequent runs of "drush up", as can be seen in the image below for the Code per Node and Reference option limit modules.

To unlock the module or theme, you can either delete the lock file, or run the following command: 

drush up module_name --unlock=module_name