I have an ansible script that transfers a production database to my devel server, then runs a few Drush commands to prepare it (e.g. updating the filesystem settings, clearing the cache).
A more complex task is updating a nested configuration value like the following one.
mail_system: default-system: SmtpMailSystem maillog: MaillogMailSystem
Supposedly I ought to be able to do this with
drush ev (aka php-eval) and
variable_set() as with
drush7 ev '$v = variable_get("file_public_path")', but I get this error message.
Error: Call to undefined function variable_get() in /usr/local/bin/drush7.4.0/commands/core/core.drush.inc(1122): eval()'d code, line 1
It does work correctly when I use the interactive shell.
drush7 core-cli self> variable_get('mail_system'); array:2 [ "default-system" => "SmtpMailSystem" "maillog" => "MaillogMailSystem" ]
I can work-around it by reading the content of
$conf easily enough.
drush7 ev 'global $conf; echo $conf["mail_system"]["default-system"];'
Writing involves a database query and clearly
variable_set() is in core.
Why cannot I use
I am using Drush 7.4.0 and Drupal 7.59.
(I also have Drush 8.1.16 available, but that's much use for this, Drush 8's cget and cset require Drupal 8, and Drush 8 doesn't have Drush 7's vget and vset.)