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

Share this post

Comments (0)

Leave a comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
Enter the characters shown in the image.