Pergunta

I have multiple versions of PHP installed, and for my normal development I always use PHP 5.5.x installed via homebrew.

In the fish shell

 which php & php --version
=> /usr/local/bin/php
=> PHP 5.5.8 (cli) (built: Jan 16 2014 15:58:25)

The path is correct.

My problem is that when I have to develop with Drupal I use MAMP as a bundled lamp stack, and MAMP has its own php version included. My problem is that when using Drush with Drupal I cannot set the PHP executable path as I normally would in bash. I only want drush to use the bundled PHP version/executable.

In bash I can do this:

# Set Drush root to MAMP PHP
export DRUSH_PHP=/Applications/MAMP/bin/php/php5.5.3/bin/php

But this wont work in fish-shell, I tried with this (no success):

fish config location: ~/.config/fish/config.fish

set -x DRUSH_PHP=/Applications/MAMP/bin/php/php5.5.3/bin/php

If I run the fishshell with drush statusi always get this:

 Drupal version         :  7.26
 Site URI               :  http://default
 Database driver        :  mysql
 Database username      :  root
 Database name          :  dev-db
 Default theme          :  garland
 Administration theme   :  garland
 PHP executable         :  /usr/local/bin/php
 PHP configuration      :  /usr/local/etc/php/5.5/php.ini
 PHP OS                 :  Darwin
 Drush version          :  6.2.0
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /Applications/MAMP/htdocs/Sandbox/dev
 Site path              :  sites/default
 File directory path    :  sites/default/files

And when I run the same command in bourne shell I get the correct settings:

  Drupal version                  :  7.26                                        
  Site URI                        :  http://default                              
  Database driver                 :  mysql                                       
  Database username               :  root                                        
  Database name                   :  dev-db                                      
  Database                        :  Connected                                   
  Drupal bootstrap                :  Successful                                  
  Drupal user                     :  Anonymous                                   
  Default theme                   :  bartik                                      
  Administration theme            :  seven                                       
  PHP executable                  :  /Applications/MAMP/bin/php/php5.5.3/bin/php 
  PHP configuration               :  /Applications/MAMP/bin/php/php5.5.3/conf/php.ini                                       
  PHP OS                          :  Darwin                                      
  Drush version                   :  6.2.0                                       
  Drush configuration             :                                              
  Drush alias files               :                                              
  Drupal root                     :  /Applications/MAMP/htdocs/Sandbox/dev       
  Site path                       :  sites/default                               
  File directory path             :  sites/default/files                         
  Temporary file directory path   :  /Applications/MAMP/tmp/php   

So, how to set the export path to the DRUSH_PHP in fish?

Foi útil?

Solução

Derp.

The syntax was a little different, but I figured it out. Anyone having this issue, you can set an export as this:

set -x DRUSH_PHP /Applications/MAMP/bin/php/php5.5.3/bin/php

and drush gets the correct PHP exec path.

See the set documentation to understand how set works in Fish as opposed to other shells. Basically:

set variable value

Outras dicas

In case you want to emulate the export command in your fish shell, just create the following file:

~/.config/fish/functions/export.fish

function export
    if [ $argv ] 
        set var (echo $argv | cut -f1 -d=)
        set val (echo $argv | cut -f2 -d=)
        set -g -x $var $val
    else
        echo 'export var=value'
    end
end

Launch a new terminal and then run export from your fish shell as expected:

export foo=123
echo $foo
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top