Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I just updated Drush from 4.5 to 5.8 and even though it appears to work fine, I get this notice after every command: "php-cli: not found". My OS is FreeBSD, so there is no PHP extension php-cli (or PHP5-cli) as there is in Linux. Php-cli is included when PHP is compiled from ports.
If Drush isn't using php cli, what is it using, and how can I get rid of this notice? I didn't have it with Drush 4.5, though it's been a while and I vaguely remember dealing with this before and don't recall what I did to fix it (if I did) - maybe something to do with the environment variable?
Thanks, Jeff
Comments
Comment #1
greg.1.anderson CreditAttribution: greg.1.anderson commentedDrush uses php-cli if it is available; it tests for availability by running
php-cli -v >/dev/null 2>&1
. The output redirection should cause stdout and stderr to be redirected; this suppresses the error message on Linux when using Bash.Are you using Bash, or some other shell? Try typing the command above, and see if you get the same error message that you do when running Drush. (You should.) Try other variants, such as
php-cli -v >/dev/null 2>/dev/null
, and see which suppress the error message, but still set $?.Comment #2
druplicate CreditAttribution: druplicate commentedBoth commands resulted in: "Ambiguous output redirect."
I'm using C shell on FreeBSD, not Linux.
Surely there must be a more universal way to test the availability of PHP CLI that works for all flavors of Unix.
There is no separate CLI add-on for PHP in FreeBSD - it's just a compilation option at build time.
If Drush can't find the extension, how does it use PHP?
Why wasn't this a problem with Drush 4.5?
Thanks,
Jeff
Comment #3
greg.1.anderson CreditAttribution: greg.1.anderson commentedOpen up the 'drush' script in Drush 4.5 and see. Maybe it used some other technique such as 'which drush'.
In general, though, Drush does not support the C shell. Would it work for you to use Bash with Drush? We could, of course, consider any patches you might submit for C shell compatibility, but they would also have to work on Bash.
Comment #4
druplicate CreditAttribution: druplicate commentedFreeBSD defaults to the tcsh shell, but bash is available, just not in the same place it is in Linux.
I just changed the script's first line from: #!/usr/bin/env sh
to: #!/usr/local/bin/bash
and the annoying error message went away.
I pointed this out to the port maintainer - hopefully he'll patch the script.
Maybe you could also make the script smarter by searching for the location of bash.
...Jeff
Comment #5
druplicate CreditAttribution: druplicate commentedComment #6
RedRat CreditAttribution: RedRat commentedOr you can just put this line in .cshrc:
setenv DRUSH_PHP /usr/local/bin/php
Comment #7
greg.1.anderson CreditAttribution: greg.1.anderson commentedSee also #1939982: drush launcher reports `php-cli: not found` by default, which provides a good resolution to this problem. The fix there is already committed to 8.x-6.x and 7.x-5.x; please re-open if you have any further problems with the Drush script on FreeBSD on the dev version of Drush 6 or Drush 5.