Hello there

The last few days I had lots of problems with drush. On last Thursday I downloaded Devel via drush and when i tried to install it but then i got the error

PHP : Parse error: syntax error, unexpected $end on line 120 in devel.drush.inc

and today I tried it with the download of "features" again and the same problem:

Drush command terminated abnormally due to an unrecoverable error.
Error: syntax error, unexpected $end in
/mnt/hgfs/sites/fit-in-it/master/sites/all/modules/features/includes/features.menu.inc, line 311

(see attached image)

The thing is, there is NO syntax error around. I opened it with Netbeans and there was no problem. As soon as I saved the file UNMODIFIED again, all was fine and error disappeared.

Either my Ubuntu VM or Drush causes that extreme problem.

Does anybody have a clue what causes this problem?

Comments

greg.1.anderson’s picture

Status: Active » Postponed (maintainer needs more info)

Tried to reproduce from the steps above, and found everything was working for me. Perhaps the problem is related to your configuration, or is caused by something other than Drush.

martinpe’s picture

my project files are mounted via a Samba mount. do you think that might cause the problem?

greg.1.anderson’s picture

I don't know. Maybe you could try copying them to a local disk, and see if the behavior changes.

richardrobinson’s picture

Category: support » bug

I can second this. It seems like every time I install a module, I'll get a syntax error. The syntax error is always on the last line of a file. It is usually a file associated with the newly installed file, but even that is inconsistent.

It sounds silly, but I thought I kept getting bad modules until I checked the source and found out where the errors were coming from. I figured out how to resolve the issue. I think it has something to do with encoding, because if I go to the line in the file specified in the error (it's ALWAYS the last line) and recreate the line, or make a new line and delete it, save it, and refresh, it will clear the error.

Note that sometimes it causes multiple files in the installed module to do this, so you might have to do this to every file it complains about. I'm not sure if this is the correct fix, but it works for me.

Also, I'm not 100% sure that this is Drush's fault... I usually install modules with Drush.

greg.1.anderson’s picture

It would be helpful if someone with a reproducible case could take a diff between a "broken" file (with the syntax error) and a "fixed" file (after "recreating" the last line). If diff shows no difference, perhaps hexdump both files, and compare the last few bytes to see if, perhaps, there is a spurious NUL or CR LF where there should only be an LF. I'm not even sure either of those situations would cause a syntax error, but I think you see what I am getting at.

On my system, a working file ends something like this:

$ hexdump -C local/drupal/drush/drush.php | tail -n 2
00001810  65 74 75 72 6e 20 46 41  4c 53 45 3b 0a 7d 0a     |eturn FALSE;.}.|
0000181f

The last three characters are LF closing-curley-brace LF. Check and see if there's anything "extra" in your broken files.

richardrobinson’s picture

I think I narrowed it down to the HGFS file system. Any time I downloaded a module using Drush into a shared VM folder, I had "invisible" lines appended to my files.

http://drupal.stackexchange.com/questions/64535/syntax-error-unexpected-...

I hope that helps and that it saves you some headache. This cost me a lot, although I don't think it's a Drush issue.

--richard

greg.1.anderson’s picture

Category: bug » support
Status: Postponed (maintainer needs more info) » Fixed

I'm going to presume, then, that this is not a Drush issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nathan573’s picture

I had an issue where I was upgrading a module from D6 to D7 and, while the site worked on my local XAMPP setup (bootstrapped and rendered in a browser properly), when I tried to use Drush on it I would get the following errors:

Error: syntax error, unexpected T_ELSE in G:\xampp\htdocs\localhost.d7-upgrade\sites\all\modules\custom\custom.module, line 2685

Error: syntax error, unexpected $end in G:\xampp\htdocs\localhost.d7-upgrade\sites\all\modules\custom\product.inc, line 2586

I realized that this was because the module was using the PHP tag shorthand - short_open_tag. Once I converted all instances of
<? to <?php
and
<?= to <?php print
Drush was able to complete operations once again.