The drush boilerplate command uses drush_locate_root() to determine the path for drupal's root. Unfortunately drush_locate_root() is only able to return a valid path when drush is invoked from within the drupal tree:

cd /usr/local/www/drupal7/sites/foobar.com
drush bp foobar_theme 

If instead one invokes it thusly from some random point in the filesystem:

drush @foobar bp foobar_theme

where @foobar is a site alias with values defined for drupal root and URI, then bp starts copying files in very strange places.

Comments

ericxb’s picture

StatusFileSize
new1.49 KB

So here's a patch. It does 3 things:

  • Replaces call to drush_locate_root() with drush_get_context(). The contexts are set by the bootstrap. Note that the boot strap calls drush_locate_root() if root path is not otherwise provided by a param.
  • Adds a call to system_rebuild_theme_data() before attempting drupal_get_path(). This is helpful because drupal_get_path() won't actually return the path to boilerplate if it has just been downloaded and the theme data has not been tickled. Without it, then
    drush @foobar dl boilerplate
    drush @foobar bp foobar_theme
    

    will fail.

  • Saves the new theme in themes/custom/[newTheme] if themes is subdivided into themes/contrib and themes/custom

I'm not really a competent drush geek. I just browsed thru the API and the source looking for likely solutions. Please ask thems that knows to take a look.

AaronA’s picture

Assigned: Unassigned » AaronA
Status: Active » Postponed (maintainer needs more info)

Wow, that's really interesting. We weren't necessarily planning on that level of drush support when we decided to add it (and if you take a look at Zen's drush.inc they could use help with the same issue), but I'll take a look and see if we can get it into a near future release. I just always liked the ease that Zen provides through drush and wanted to pass that on. Thanks for the patch.

ericxb’s picture

This comes up on my dev machine. For my development staging all my projects end up in /usr/local/www/src.[whatever]. To make that easier to live with, my .drush/aliases.drushrc.php has an entry for each dev site. I don't know how commonly used drush aliases are; but I can't live without them.

Thanks for considering it.

danlinn’s picture

Status: Postponed (maintainer needs more info) » Needs review
webkenny’s picture

I don't want to derail this issue but is anyone finding that when you run the drush bp command (even from within the site tree) that it creates an entirely new Drupal core in the folder? Wondering if any of this is related somehow.

twardnw’s picture

Version: 7.x-1.5 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.29 KB

Not sure what was used to generated that patch, but I couldn't apply it...

Tested this out on my local environ by:

  • Using drush bp from inside the drupal tree
  • Set up a site alias file for the site and was able to use drush bp @alias from anywhere on my system

In both cases, I also tested against there being a standard drupal path (sites/all/themes) and paths for custom and contrib (sites/all/themes/contrib sites/all/themes/custom). The command was able to place the new theme in the correct folder.

Attached is a patch generated by git.

twardnw’s picture

Status: Reviewed & tested by the community » Fixed

committed to -dev, authorship to ericxb

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.