drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.33k stars 1.08k forks source link

drush site-install fails with "Error: Call to a member function getPath() on null in install_tasks()" #2712

Open ahwebd opened 7 years ago

ahwebd commented 7 years ago

Using drush site-install fails with Error: Call to a member function getPath() on null in install_tasks()

After little investigation I found that in function drush_core_site_install() in file drush/commands/core/site_install.drush.inc the $profile is the second argument not the first (second element of $args) So changing:

  if ($args) {
    // The first argument is the profile.
    $profile = array_shift($args);
    // Subsequent arguments are additional form values.
    foreach ($args as $arg) {

to

  if ($args) {
    // The first argument is the profile.
    $profile = array_shift($args);
    $profile = array_shift($args);
    // Subsequent arguments are additional form values.
    foreach ($args as $arg) {

(shifting $args 2 times) solves the issue

Running on: docker image based on image drupal:8.3.0-apache with mariadb-client installed (php --version: PHP 7.1.3 (cli) (built: Mar 21 2017 23:15:20) ( NTS ))

Aquaplast commented 7 years ago

Got the same problem. It helps. Thx a lot!

weitzman commented 7 years ago

Please paste the command you are executing with --debug output. $profile is usually first arg.

ahwebd commented 7 years ago

Command:

drush site-install --debug \
  --root=/var/www/dp/$WEB_ENV/web \
  --sites-subdir=$SITE \
  --config-dir=/var/www/dp/$WEB_ENV/config \
  --db-su=root \
  --db-su-pw=$(cat /run/secrets/mariadb_root_pass) \
  --db-url=mysql://$DB_USER:$(openssl rand -base64 12)@dbserver:3306/$DB_NAME \
  --account-name=$ADMIN_NAME \
  --account-pass=$ADMIN_PASSWORD \
  --account-mail=$ADMIN_EMAIL \
  --site-name=$SITE_NAME \
  --site-mail=$SITE_EMAIL

truncated output:

...
Returned from hook drush_core_pre_site_install [4.05 sec, 2.05 MB]       [debug]
Calling hook drush_core_site_install [4.05 sec, 2.06 MB]                 [debug]
Starting Drupal installation. This takes a while. Consider using the [ok]
--notify global option. [4.05 sec, 2.07 MB]
Calling install_drupal(Object, Array) [4.05 sec, 2.07 MB]                [debug]
Error: Call to a member function getPath() on null in /var/www/dp/sb/web/core/includes/install.core.inc on line 795 #0 /var/www/dp/sb/web/core/includes/install.core.inc(681): install_tasks(Array)
#1 /var/www/dp/sb/web/core/includes/install.core.inc(533): install_tasks_to_perform(Array)
#2 /var/www/dp/sb/web/core/includes/install.core.inc(117): install_run_tasks(Array)
#3 /var/www/dp/sb/vendor/drush/drush/includes/drush.inc(726): install_drupal(Object(Composer\Autoload\ClassLoader), Array)
#4 /var/www/dp/sb/vendor/drush/drush/includes/drush.inc(711): drush_call_user_func_array('install_drupal', Array)
#5 /var/www/dp/sb/vendor/drush/drush/commands/core/drupal/site_install.inc(84): drush_op('install_drupal', Object(Composer\Autoload\ClassLoader), Array)
#6 /var/www/dp/sb/vendor/drush/drush/commands/core/site_install.drush.inc(254): drush_core_site_install_version('Site', Array)
#7 /var/www/dp/sb/vendor/drush/drush/includes/command.inc(422): drush_core_site_install('Site')
#8 /var/www/dp/sb/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#9 /var/www/dp/sb/vendor/drush/drush/includes/command.inc(199): drush_command('Site')
#10 /var/www/dp/sb/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#11 /var/www/dp/sb/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#12 /var/www/dp/sb/vendor/drush/drush/drush.php(12): drush_main()
#13 {main}
Error: Call to a member function getPath() on null in install_tasks() (line 795 of /var/www/dp/sb/web/core/includes/install.core.inc).
Drush command terminated abnormally due to an unrecoverable error.   [error]
[4.25 sec, 7.34 MB]
bleen commented 5 years ago

I am having the same issue when creating a vanilla D8 site with Lando. I followed these steps:

mkdir d8-contrib
cd d8-contrib
lando init \
  --source remote \
  --remote-url https://www.drupal.org/download-latest/tar.gz \
  --remote-options="--strip-components 1" \
  --recipe drupal8 \
  --webroot . \
  --name my-first-drupal8-app
lando start

Once this completes I ran through the drupal install in the GUI with no issue. Later I wanted to start the site fresh so I ran this:

lando drush site-install default \
    --site-name=Drupal8 \
    --db-url=mysql://drupal8:drupal8@database/drupal8 \
    --account-name=admin \
    --account-pass=12345 \
    --account-mail=email@email.com

and I get the following error:

Error: Call to a member function getPath() on null in /app/core/includes/install.core.inc on line 863 #0 /app/core/includes/install.core.inc(728): install_tasks(Array)
#1 /app/core/includes/install.core.inc(577): install_tasks_to_perform(Array)
#2 /app/core/includes/install.core.inc(125): install_run_tasks(Array, NULL)
#3 phar:///usr/local/bin/drush/includes/drush.inc(727): install_drupal(Object(Composer\Autoload\ClassLoader), Array)
#4 phar:///usr/local/bin/drush/includes/drush.inc(712): drush_call_user_func_array('install_drupal', Array)
#5 phar:///usr/local/bin/drush/commands/core/drupal/site_install.inc(82): drush_op('install_drupal', Object(Composer\Autoload\ClassLoader), Array)
#6 phar:///usr/local/bin/drush/commands/core/site_install.drush.inc(271): drush_core_site_install_version('default', Array)
#7 phar:///usr/local/bin/drush/includes/command.inc(422): drush_core_site_install('default')
#8 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#9 phar:///usr/local/bin/drush/includes/command.inc(199): drush_command('default')
#10 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#11 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#12 phar:///usr/local/bin/drush/includes/startup.inc(465): drush_main()
#13 phar:///usr/local/bin/drush/includes/startup.inc(369): drush_run_main(false, '/', 'Phar detected. ...')
#14 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#15 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#16 {main}
Error: Call to a member function getPath() on null in install_tasks() (line 863 of /app/core/includes/install.core.inc).

For reference, after I installed the site via the GUI I ran lando drush status:

 Drupal version                  :  8.6.9
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  database
 Database port                   :
 Database username               :  drupal8
 Database name                   :  drupal8
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :
 Default theme                   :  bartik
 Administration theme            :  seven
 PHP configuration               :
 PHP OS                          :  Linux
 Drush script                    :  /usr/local/bin/drush
 Drush version                   :  8.1.18
 Drush temp directory            :  /tmp
 Drush configuration             :
 Drush alias files               :
 Install profile                 :  standard
 Drupal root                     :  /app
 Drupal Settings File            :  sites/default/settings.php
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Temporary file directory path   :  /tmp
 Sync config path                :  sites/default/files/config_2-VN7kNGFnIpOxCiOvztd4P7PaaO8Eu3GNI5-JA5Up_aWVD5s_HtIegwZ6mDJkPFHVpAjW3lyA/sync

Also, running lando info give me this:

lando info                                                           6.7s  Wed Feb 13 10:30:21 2019
[
  {
    service: 'appserver',
    urls: [
      'https://localhost:32771',
      'http://localhost:32772',
      'http://d8-contrib.lndo.site',
      'https://d8-contrib.lndo.site'
    ],
    type: 'php',
    via: 'apache',
    webroot: '.',
    config: {
      php: '/Users/bleen/.lando/config/drupal8/php.ini'
    },
    version: '7.2',
    meUser: 'www-data',
    hostnames: [
      'appserver.d8contrib.internal'
    ]
  },
  {
    service: 'database',
    urls: [],
    type: 'mysql',
    internal_connection: {
      host: 'database',
      port: '3306'
    },
    external_connection: {
      host: 'localhost',
      port: '32769'
    },
    creds: {
      database: 'drupal8',
      password: 'drupal8',
      user: 'drupal8'
    },
    config: {
      database: '/Users/bleen/.lando/config/drupal8/mysql.cnf'
    },
    version: '5.7',
    meUser: 'www-data',
    hostnames: [
      'database.d8contrib.internal'
    ]
  },
  {
    service: 'pma',
    urls: [
      'http://localhost:32773',
      'http://pma-d8-contrib.lndo.site',
      'https://pma-d8-contrib.lndo.site'
    ],
    type: 'phpmyadmin',
    backends: [
      'database'
    ],
    config: {},
    version: '4.7',
    meUser: 'www-data',
    hostnames: [
      'pma.d8contrib.internal'
    ]
  }
]

and finally, for reference, my .lando.yml looks like this:

name: d8-contrib
recipe: drupal8
env_file:
  - .env
config:
  webroot: .
  php: "7.2"
  drush: "*"
  xdebug: false
proxy:
  pma:
  - pma-d8-contrib.lndo.site
services:
  pma:
    type: phpmyadmin
    hosts:
    - database
bleen commented 5 years ago

You can ignore my comment above ... after several days I found my issue. I was calling

lando drush site-install default \
    --site-name=Drupal8 \
    --db-url=mysql://drupal8:drupal8@database/drupal8 \
    --account-name=admin \
    --account-pass=12345 \
    --account-mail=email@email.com

and I should have been calling

lando drush site-install standard \
    --site-name=Drupal8 \
    --db-url=mysql://drupal8:drupal8@database/drupal8 \
    --account-name=admin \
    --account-pass=12345 \
    --account-mail=email@email.com

note the use of "standard" instead of "default"

sigh

Vagelis-Prokopiou commented 4 years ago

I also resolved the issue by adding the standard profile in the command.