running Drupal 6.14 on GoDaddy hosting with php 5.2.8.

I have a stuck cron job which I don't know how to kill (I've deleted cron_semaphore and cron_last_run several times).
Thought drush might help.

Installed drush but when I run $ drush I get

Your PHP installation is too old. Drush requires at least PHP 5.2.0

Anybody?

Comments

pescetti’s picture

It may happen, especially on shared hosting, that the PHP module for Apache (used to serve pages) and the command-line PHP are two different versions.

Do you still see PHP 5.2.8 if you run the following?

$ php --version

austintnacious’s picture

Thanks!

At the command line php version is only 4.4.9.

moshe weitzman’s picture

Status: Active » Closed (works as designed)

I added a bit more info in the error msg - 'Your command line PHP installation is too old. Drush requires at least PHP ' . DRUSH_MINIMUM_PHP

bcruiksh’s picture

The server I'm using runs both php4 and php5, but it defaults to 4 at the command line. How can I get drush to use php5?

At the prompt "php5 --version" returns PHP 5.2.6

Thanks.

dman’s picture

This is common on many shared/hosted servers.
Look at the results of

which php
which php5

If you had root control of the server, you can fix it with symlinks. Unlikely.

I tried to alias php=php5 .. Which did work on the commandline and started giving me good results when I went php --version but drush did something wacky (with 'env') to bust that quick fix.

... so instead I just edited the drush shell file itself and replaced the last few lines with an EXPLICIT call to php5

  else
    # Alternatively we run with straight php, which works on most other systems.
    /usr/bin/env php5 $SCRIPT_PATH "$@"
  fi

Not a full fix, but got me to the point I could bootstrap my deployment on a remote, hosted site for someone.
There are probably many other shell tricks to solve this in many ways. This hack just worked, wish there was some cleaner way.

moshe weitzman’s picture

the readme recommends that you make a bash alias to drush.php. in your case the alias would look like:

drush = php5 /path/to/drush.php

bcruiksh’s picture

Thanks for the help. #6 seems to have worked.

bdornbush’s picture

#6 got me close but not quite.
There is a file in my home directory called .bash_profile There was no file called .profile or .bash_aliases There is also a file called .bashrc

I put the following in both .bash_profile and .bashrc:
alias drush='/usr/local/php5/bin/php /home/fumcsr/drush/drush'

I got the /usr/local/php5/bin/php from my hosting service info

I also put
export COLUMNS
in my .bash_profile file

I logged out of Putty and back in. When I type DRUSH and nothing else or anything else,
for example:
DRUSH
DRUSH DL TAC_LITE
DRUSH HELP
DRUSH CRON

I get

# $Id: drush,v 1.16 2010/03/17 13:34:17 weitzman Exp $
#
# This script is a simple wrapper that will run Drush with the most appropriate
# php executable it can find.
#

# Get the absolute path of this executable
ORIGDIR=$(pwd)
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")

# Resolve symlinks - this is the equivalent of "readlink -f", but also works with non-standard OS X readlink.
while [ -h $SELF_PATH ]; do
    # 1) cd to directory of the symlink
    # 2) cd to the directory of where the symlink points
    # 3) Get the pwd
    # 4) Append the basename
    DIR=$(dirname -- "$SELF_PATH")
    SYM=$(readlink $SELF_PATH)
    SELF_PATH=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
done
cd "$ORIGDIR"

# Build the path to drush.php.
SCRIPT_PATH=$(dirname $SELF_PATH)/drush.php
case $(uname -a) in
  CYGWIN*)
    SCRIPT_PATH=$(cygpath -w -a -- "$SCRIPT_PATH") ;;
esac

# If not exported and term is set determine and export the number of columns.
if [ -z $COLUMNS ] && [ -n "$TERM" ]; then
  export COLUMNS=$(tput cols)
fi

# Special case for *AMP installers, since they normally don't set themselves as the default cli php out of the box.
for php in /Applications/MAMP/bin/php5/bin/php /opt/lampp/bin/php /Applications/xampp/xamppfiles/bin/php ; do
  if [ -x $php ]; then
    exec $php $SCRIPT_PATH --php="$php" "$@"
  fi
done

# We check for a command line (cli) version of php, and if found use that.
which php-cli >/dev/null 2>&1
if [ "$?" = 0 ] ; then
  exec php-cli $SCRIPT_PATH --php="php-cli" "$@"
else
  # Alternatively we run with straight php, which works on most other systems.
  # The --php=`which php` is for Dreamhost, which behaves oddly.  See http://drupal.org/node/662926
  exec php $SCRIPT_PATH --php=`which php` "$@"
fi

What am I doing wrong?

bdornbush’s picture

re #8
I put the following in both my .bash_profile and .bashrc files (this is probably not necessary or even right, but it worked):

export COLUMNS
alias drush='/usr/local/php5/bin/php /home/fumcsr/drush/drush.php'
alias php='/usr/local/php5/bin/php'

Note that the key difference from above is the ".php" at the end of the alias drush. In the readme file, there is one example with the .php, and one without. I guess I just got them mixed up.

I also ran
dos2unix .bash_profile
dos2unix .bashrc

Again, I don't know if this was needed, but I have had to do it before, as I edit on a Windows PC and upload using WinSCP (an SFTP client).

Now all works properly.

Perhaps someone who know more about Linux and Bash can comment about the need for .bash_profile vs. .bashrc, and using dos2unix.

dman’s picture

FYI
The need for dos2unix depends on your choice of text editor - not the upload method.
If you use something (almost anything) less brain-dead than windows 'notepad', then the newlines should be retained in their original format - either 'dos' or 'unix' depending. Which format you start with depends on the editors preference.
Most of these text editors will also have an option to switch for you - often in the 'file properties' menu.

bdornbush’s picture

I set up another site's drush, so I put the 3 lines shown in #9 into .bash_profile, and didn't run dos2unix (I used EditPad Lite as the editor) and it worked fine.

tars16’s picture

I'm having an issue with this as well. I've got drush working with the following 2 methods:

from the command line I create an alias alias drush='/usr/local/php5/bin/php ~/private/drush/drush.php'

in the .bash_profile I've added the following lines as suggested above:

export COLUMNS
alias drush='/usr/local/php5/bin/php ~/private/drush/drush.php'
alias php='/usr/local/php5/bin/php'

Drush help lists all the commands I need, but when I run drush up xmlsitemap (or any module) I get the following error:

Code updates will be made to the following projects:
XML sitemap [xmlsitemap-5.x-1.7]

Note: Updated projects can potentially break your site. It is NOT recommended to update production sites without prior testing.
Note: A backup of your package will be stored to backups directory if it is not managed by a supported version control system.
Note: If you have made any modifications to any file that belongs to one of these projects, you will have to migrate those modifications after updating.
Do you really want to continue? (y/n): y
Project xmlsitemap was updated successfully. Installed version is now 5.x-1.7.
Backups were saved into the directory                                                     [ok]
/home/usr/domain/backup/modules/20100511110225/xmlsitemap.
Cache cleared.
You have pending database updates. Please run `drush updatedb` or visit update.php in your[warning]
browser.
The command could not be executed successfully (returned: Your command line PHP           [error]
installation is too old. Drush requires at least PHP 5.2.0
, code: <em>0</em>)
An error occurred at function : drush_pm_post_pm_update                                   [error]

The module code gets updated as refreshing the status report shows it was successful.

Any idea whats going on here?

This particular site is running on Drupal 5.18, update_status module has been upgraded to 2.5 (also ran into an issue there) and it is hosted on Dreamhost.

fuzzy_texan’s picture

Having the same problem as #12 on my shared hosting. A lot works, but several commands still seem to switch out to another shell / session which is causing the wrong PHP version errors.

bdornbush’s picture

I am having the same problem as #12. I just saw it when I tried to run DRUSH UP. DRUSH DL works fine. I am also using DreamHost, with the three lines I noted in #9.

Drupal was updated to the latest 6 release so everything seems OK.

What am I missing if drush_pm_post_pm_update does not run?

andywalters’s picture

FYI, #6 worked for me as well.

benklocek’s picture

I'm using MediaTemple Grid service and have everything running fine using those aliases *if I'm ssh'ed in*. (MT uses php4 as the default, so I've aliased drush to use php5.)

If I try to run "$ drush @rjlive en module" from my local machine, I get the "Your command line PHP installation is too old" error.

Is there a way to make drush use the .bashrc or .bash_profile when using a remote alias?

dman’s picture

@benklocek - I know what you mean.
See the README

     NOTE FOR ADVANCED USERS
     - If you want to run drush with a specific version of php, rather than the
       one found by the drush command, you can instead create an alias that
       executes the drush.php file directly:
       $ alias drush='/path/to/php/php5 /path/to/drush/drush.php'
       If you do this, to allow Drush to detect the number of available columns,
       you need to add the line 'export COLUMNS' to the .profile file in your
       home folder.

Use 'which php' when ssh-ed in to find the correct php path.

Forcing the non-shell login to see your normal PATH and .bashrc can be tricky when you have limited control of the system.
... hm, actually it won't pick up your .aliases file either, so that may not work.
Um, maybe create a small shell script that invokes drush, then set that as 'path-aliases' => [ '%drush-script' => '/path/to/drush/drush', ] in your site-aliases settings.

#!/bin/bash
/usr/bin/php5  /full/path/to/drush/drush.php $1 $2 $3 $4 $5 $6

... messy, there are other ways to correctly get non-interactive shells to read your .profile, but I can't recall them right now.

arton’s picture

Component: Interoperability » PM (dl, en, up ...)

Thought I'd include this link to change the command line php version for mediatemple users. Fixed the issue for me.
http://wiki.mediatemple.net/w/Set_specific_PHP_version_for_command_line_on_(gs)_Grid-Service

Alexander Allen’s picture

In my case even when trying all the above recommendations I was still getting the same error message. I was using Drush with remote aliases, and putting alias php='/user/local/php5/bin/php' in .bashrc wasn't doing the trick. I made sure the PATH variable in .bashrc was pointing to PHP5 as well.

When running $ php -v bash returned PHP 5.2.11.

However when executing the $ which -a php command I would get two versions of PHP:

/usr/local/bin/php
/usr/local/php5/bin/php

While using Drush with remote aliases (i.e. drush @myremotealias info), Drush would always find the first PHP location, which is PHP version 4.

To fix this (using my root login), I had to go to /usr/local/bin and move PHP4 to another location (/usr/local/php4/bin).

This removed PHP4 from the PATH's variable scope, and when running $which php I would only get the PHP5 version. After that Drush began using the correct PHP 5 version (while still using remote aliases).

Also, when placing export COLUMNS in .bashrc, log out and log back in. If when you log back in and run the command $ echo COLUMNS you get COLUMNS as a response, you should consider putting export COLUMNS=80 in .bashrc instead.

And for all the questions about the difference between .bash_profile and .bashrc, bashrc stands for bash-remote-console. Meaning when you do a non-interactive remote login, whatever you put in .bashrc is what will get loaded (instead of .profile or .bash_profile).

Anonymous’s picture

Issue tags: +PHP, +drush, +version

I'm a bit late, but in case someone has the same problem again:

drush (v4+) tries to find the most appropriate php version. And at first it checks the DRUSH_PHP enviromnment variable. If you set it in your ~.bashrc like

export DRUSH_PHP=/usr/local/bin/php5.3.5

then drush uses this version of php instead of `which php`.

lord_of_freaks’s picture

Try this .. works for me

http://mytwocents.karit.geek.nz/2010/03/path-to-php5-cli-on-godaddy.html

The problem is the path try with: "'/usr/local/php5/bin/php"
.bashrc example

Export COLUMNS
alias  drush='/usr/local/php5/bin/php ~/drush/drush.php'
alias  php='/usr/local/php5/bin/php'