cool tech graphics

Drush pm-download and pm-update: When and Why to Use Each

Filed under:

Drush is a Drupal developers Swiss-army knife. Of course there are the favorite commands that you probably use every day: drush sql-cli, drush pm-enable. Drush pm-download and drush pm-update are probably pretty commonly used as well. I'm going to use their aliases for the rest of this blog post: drush dl and drush up. drush up is actually a combination of drush pm-updatecode (drush upc) and drush updatedb (drush updb). In my examples I'll be using the Views module, but the same applies for any module or theme.

Running `drush dl views` will download the latest recommended version of views to the default location (sites/all/modules/contrib if it exists or sites/all/modules). If you already have views installed `drush upc views` will download an updated version to the same location that it is already installed. There are a few scenarios where problems can come in:

You have a module installed in a different location

Say you are using an install profile that installed views in profiles/myprofile/modules/views. Using `drush dl views` will just install another version of views in sites/all/modules. This isn't really desired because it can confuse the registry (or at least confuse other developers) on which views is being used. It can also mean that if you were using a version of views that isn't recommended (i.e. a dev or beta release) that you may not actually be updating but downgrading.

In this scenario `drush upc views` is preferred (and you can save another step by just using `drush up views`).

You are using a dev release

Generally I'd recommend against using dev releases because they are just that and can be unstable. Even so, sometimes you start on a project and need a feature that is only in dev and you expect a full release by the time the project is ready for launch. When that day comes and there is a full release, if you run `drush up views`; what happens? It doesn't update to the full release but updates to the latest dev release.

In this scenario `drush dl views --destination=profiles/myprofile/modules/views` would be preferred.

The project has multiple versions

Sometimes there are multiple versions of modules and only one can be recommended. For example, the media module. Currently the releases look like:

If you had installed 7.x-2.x-dev several months ago before 7.x-2.0-unstable7 was released; and you want to update to that release (assuming it is more stable then the latest dev):
`drush up media` would give you the latest dev
`drush dl media` would downgrade you to 7.x-1.2 (and create all sorts of problems)

In this scenario you would use `drush dl media --select` and then at the prompt enter the number corresponding to 7.x-2.0-unstable7. Then don't forget to run `drush updb` afterwards to check for database updates.

Date posted: February 18, 2013


drush has been a developers' dream for us. drush archive-dump, drush archive-restore, drush sql-sync, and even the occational drush user-login. Great article!

Add new 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>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <cpp>, <java>, <php>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Metal Toad is an Advanced AWS Consulting Partner. Learn more about our AWS Managed Services

Have questions?