1

UPDATE: I have managed to update Drush using Wim Mostrey's help as seen below. Drush is now at version 8, and continues to work with my Drupal 7 sites, but when I try to use it on my Drupal 8 site, I get this:

Drush command terminated abnormally due to an unrecoverable error.  
Error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home1/[uname]/public_html/_d8/core/lib/Drupal/Component/Ser‌​ialization/Yaml.php, line 54 Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home1/[uname]/public_html/_d8/core/lib/Drupal/Component/Ser‌​ialization/Yaml.php

Does anyone know what this issue is?


Original Question: I want to upgrade from Drush 6.5 to 8, even though current Drush is ver 9 because I want to keep backwards compat. I'm not understanding the instructions on github very well, and concerned about it getting gummed up. Is there a clear, simple guide for this?

  • Could you include in your answer how you installed Drush 6.5 in the first place? The answer on how to upgrade will depend on how you installed it. – Wim Mostrey Jan 24 '17 at 18:59
  • My recollection is that I began by installing Composer, which looks to be in place - in ~/.composer on my hosting. – nitrospectide Jan 24 '17 at 19:04
  • I found my notes from the install: curl -sS getcomposer.org/installer | php them move composer.phar into /composer/composer (the second is the renamed .phar file) add to bash path: PATH=$PATH:$HOME/composer Then install drush: composer global require drush/drush:6.* (see drush link above for different versions) add to bash path: PATH=$PATH:$HOME/.composer/vendor/drush/drush – nitrospectide Jan 24 '17 at 19:05
  • Run drush --debug version in the D6 and D8 folder. Is Drush using the same Drush script? See first line of the output. – hansfn Jan 25 '17 at 17:41
  • To clarify: They are Drupal 7 and Drupal 8 installs. I ran this, and both are using the same version. – nitrospectide Jan 25 '17 at 22:49
1

Looks like the version of PHP you are using does not meet the minimum requirements for Drush and/or Drupal. Check your PHP version, and compare against the Drush supported versions matrix.

| improve this answer | |
  • I'm running PHP 5.4 at the CLI, and 5.5 on the web server. – nitrospectide Jan 26 '17 at 18:22
  • From the symptom, it looks like maybe the webserver is running php-cgi 5.5, and php-cli 5.3. Version 5.4 recent enough for Drupal 8 and Drush 8; I wouldn't expect to see syntax errors like those shown under that version. – greg_1_anderson Jan 27 '17 at 4:30
  • php -v gets me: PHP 5.4.45 (cli) (built: Oct 5 2015 15:35:12) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies with the ionCube PHP Loader v4.7.4, Copyright (c) 2002-2014, by ionCube Ltd., and with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies – nitrospectide Feb 14 '17 at 16:49
0

Since you installed Drush using Composer, you will now be fine by running the following command:

composer global require drush/drush:8.*
| improve this answer | |
  • Thank you. I needed to do "composer self-update" first, since attempting to update Drush directly told me my Composer was out of date. After Composer, I ran you command, and all went smoothly. But now I am in my Drupal * install, and when I try to get a drush status, I get: Error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home1/[username]/public_html/_d8/core/lib/Drupal/Component/Serialization/Yaml.php, line 54 – nitrospectide Jan 24 '17 at 19:16
  • And the Drupal site in question is running okay? I can't find any reference to such an error online. Do you have another Drupal site that you can test drush status on? And if you try drush --version or drush status from outside a Drupal directory? – Wim Mostrey Jan 24 '17 at 19:23
  • If I move ver to another site install (Drupal 7), then drush status works. If I step up to the home dir, I get an abbreviated response to drush status since there is no site to target. drush version works everywhere. – nitrospectide Jan 24 '17 at 19:30
  • I am trying to make my comments more readable, but adding two spaces at the end of a line to create a line break (as the instructions say) is not working. How do I not have everything mash together? – nitrospectide Jan 24 '17 at 19:31
  • It seems to be a problem with only your _d8 site then. It is installed properly and you can see it in your browser? – Wim Mostrey Jan 24 '17 at 19:31
0

Firstly, remove drush 6.5 version using

sudo apt-get autoremove drush

then, follow these commands -

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer global require drush/drush:8.0*
export PATH="$HOME/.composer/vendor/bin:$PATH"

Then you can check the update has been successful by executing:

$ drush --version
| improve this answer | |
  • I already ran Wim's command, and it seems to have updated according to drush status. I see no indication of what happened to the old drush version. – nitrospectide Jan 24 '17 at 19:21
0

After much pain and frustration on this, I finally found the answer and have it working. The info on drush.org (http://docs.drush.org/en/master/install/) about Drush version + PHP compatibility is completely misleading if not simply wrong. I went through a lot of careful testing, teardown and rebuild... and Drush 8 does NOT work with Drupal 8(.2) under CLI PHP 5.4 as the chart at the bottom of the linked page plainly indicates it should.

Drush.org says Drush 8 will work under CLI PHP 5.4, and technically, it does - if you are using a Drupal 6 or 7 site. Drupal 8 was running just fine - it had its required PHP 5.5 running on the webserver. But apparently, when I use Drush, the REAL required version of PHP at the CLI is defined by Drupal, NOT some minimum requirement set by Drush itself. This distinction - Drush's real PHP version requirement being defined by the Drupal PHP requirement - that is not at all explained. I was under the impression that if Drupal was happily running, and Drush had met its own PHP requirement, then the problem must lie elsewhere. Hence all of my wasted time. Hopefully, someone else finds this and saves him/herself a bunch of headache.

So there you have it. I set DRUSH_PHP to point to PHP 5.5 or greater, and everything is happy. I went to see how I could comment on drush.org to let them know to correct this, but can't find a way to, and after burning so much time already on this, I am not willing to burn more looking. I'm posting the answer here, in hopes it will help people, and that someone else will tell them their reqs page is very misleading.

| improve this answer | |

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.