9

I am following the instructions to install Drush that are listed on this page: https://github.com/drush-ops/drush/blob/master/docs/install.md

I seem to be getting a syntax error within the code:

[user@localhost ~]$ wget https://github.com/drush-ops/drush/releases/download/8.0.0-rc4/drush.phar
--2015-11-16 16:23:02--  https://github.com/drush-ops/drush/releases/download/8.0.0-rc4/drush.phar
Resolving github.com (github.com)... 192.30.252.131
Connecting to github.com (github.com)|192.30.252.131|:443... connected.
HTTP request sent, awaiting response... 302 Found
2015-11-16 16:23:05 (1.47 MB/s) - drush.phar saved [3496991/3496991]

[user@localhost ~]$ php drush.phar core-status

Parse error: syntax error, unexpected '[' in phar:///home/user/drush.phar/includes/output.inc on line 188

I am not seeing this error on Google. Any idea how to fix it?

  • Which version of PHP are you using? – kiamlaluno Nov 16 '15 at 17:16
  • Are you running drush inside the Drupal directory? – No Sssweat Nov 16 '15 at 17:33
  • PHP 5.3.29 (cli) (built: Nov 3 2015 15:43:40) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies – Richard of Essex Nov 16 '15 at 17:45
  • It happens when I run in a Drupal directory and when I do not. Regardless, I don't think this is how Drush normally reacts to not finding an installation. Other versions have gracefully exited. – Richard of Essex Nov 16 '15 at 17:46
  • 1
    I will add to make sure you check if you have the DRUSH_PHP environment variable set. I spent way too long trying to figure out why drush wasn't using php 5.6 even though that was what was configured in my path. Turns out I had DRUSH_PHP set to my php 5.3 path from a long time ago. unset DRUSH_PHP fixed the issue for me. – User Dec 26 '15 at 13:37
17

You're using Drush 8, which requires a minimum PHP version of 5.4.5 (http://docs.drush.org/en/master/install/).

Your current version (5.3) doesn't understand short array syntax, hence the error you're seeing.

To fix, either upgrade PHP, or switch to an older branch of Drush.

  • I am having the same issue. I have PHP 5.3.29, Drupal 6 (installed php using phpbrew on Ubuntu 14.04 and then switched to version 5.3.29). When I run command drush status I am getting: Warning: Module 'json' already loaded in Unknown on line 0 PHP Parse error: syntax error, unexpected '[' in phar:///usr/local/bin/drush/includes/startup.inc on line 63 Parse error: syntax error, unexpected '[' in phar:///usr/local/bin/drush/includes/startup.inc on line 63 – Niladri Sarkar Jun 22 '16 at 4:39
0

If your system has more than one php versions installed you can define an alias in your .bashrc or .bash_profile or /etc/profile.d/global_aliases.sh (or any part of your system that you can define an alias). The alias would run drush with appropriate php version.

For example in a plesk system you can probably do something like this

alias drush='/opt/plesk/php/5.6/bin/php /usr/local/drush'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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