0

Using Drush 5.8 contrib modules are not available if executed externally.

E.g. Drush Entity is not available if executed on a Django view via a check_output:

check_output("drush -l example.com -r /var/www/my/example/site/ entity-read node", shell=True)

Any command regarding Drush Entity return an error specifying that the command "could not be found. Run drush cache-clear drush to clear the commandfile cache if you have installed new extensions."

The same command is available if executed via an interactive python shell or via ssh.

I've installed Drush Entity in this way:

drush dl drush_entity

This command on my system put drush_entity into /home/admin/.drush directory. This directory seems to be ignored, since site-alias too are ignored if i put them inside that directory.

1 Answer 1

1

The solution is to pass the environment variable $HOME to check_output, in this case /home/admin:

check_output("drush -l example.com -r /var/www/my/example/site/ entity-read node", shell=True, env={'HOME': "/home/admin"})

This force the /home/admin/.drush directory to be read. If everything is fine this command:

drush ev 'print(drush_server_home());'

should return /home/admin. If drush_server_home() returns an empty string, contrib modules installed inside .drush on home directory will not be available.

Ensure to install contrib modules with the same user controlling the /home/admin directory.

Read the documentation of the language you're using to pass the $HOME variable on command execution.

2
  • 1
    If you don't want to set up your environment, you can also use the Drush --include option to point at your drush resources folder, or use --config to point directly at a drushrc.php file. Commented Dec 18, 2013 at 16:35
  • Nice suggestion greg! It would be the right choice if multiple Linux users have different drush installations with different drush modules versions.
    – chirale
    Commented Dec 20, 2013 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.