2

I need to use some tools, but I have some problems when I try use PHP Artisan in Laravel and Cordova, I need to comment some lines, because the $PATH is not working fine. I am a noob working with Unix :)

To be more specific in my question, I need that these lines work fine together, without need to uncomment and comment depending of the tool I need to use:

export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH" export PATH=~/.composer/vendor/bin:$PATH 

Errors I have when I uncommented each one:

Case 1: Cordova can only run in Xcode version 4.6 or greater.

Case 2: Mcrypt PHP extension required.

EDIT: I've added the complete bash profile:

# The next line updates PATH for the Google Cloud SDK. source /Users/chema/google-cloud-sdk/path.bash.inc # The next line enables bash completion for gcloud. source /Users/chema/google-cloud-sdk/completion.bash.inc #Comment this line make Cordova works fine #export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH" export PATH=${PATH}:/Users/chema/sdk-android/sdk/platform-tools:/Users/chema/sd$ #Comment this line make PHP Artisan with Laravel works fine export PATH=~/.composer/vendor/bin:$PATH export ANDROID_HOME=/Users/chema/sdk-android/sdk export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools 

If I uncomment the two lines, just works PHP Artisan Laravel.

echo PATH when Cordova it's working and PHP Artisan doesn't:

which xcodebuild /usr/bin/xcodebuild

/Users/chema/.composer/vendor/bin:/Users/chema/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/chema/sdk-android/sdk/platform-tools:/Users/chema/sdk-android/sdk$:/Users/chema/sdk-android/sdk/tools:/Users/chema/sdk-android/sdk/platform-tools

echo PATH when PHP Artisan it's working and Cordova doesn't:

/Applications/XAMPP/xamppfiles/bin:/Users/chema/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/chema/sdk-android/sdk/platform-tools:/Users/chema/sdk-android/sdk$:/Users/chema/sdk-android/sdk/tools:/Users/chema/sdk-android/sdk/platform-tools

which xcodebuild /usr/bin/xcodebuild

Thanks!!

14
  • instead of PATH=${PATH}:... try doing: export PATH=$PATH:... Commented Nov 19, 2014 at 13:44
  • @sircapsalot What difference will that make? Commented Nov 19, 2014 at 13:48
  • Who knows... i'm still sort of new to bash, give me a break :) just offering a potential solution. hence why i didn't make it an answer Commented Nov 19, 2014 at 13:49
  • @sircapsalot Fine. The { } characters can be used to delimit an environment variable reference; so you can do something like echo ${HOME}hello where echo $HOMEhello would obviously fail. The ( ) characters, on the other hand, are a different story. Commented Nov 19, 2014 at 13:51
  • and putting PATH=/Applications/XAMPP/xamppfiles/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:~/.composer/vendor/bin:$PATH ; export PATH as the last line (and commenting the others out? doesn't work Commented Nov 19, 2014 at 14:04

1 Answer 1

2

ok after some digging. I think I've figured this out

What is happening is that head command that Cordova needs which normally lives in /usr/bin/head on OSX, is being overshawdowed by a version supplied by XAMPP. So the path order needs to be adjusted. A which head when XAMPP is uncommented should probably give you /Applications/XAMPP/xamppfiles/bin/head as opposed to /usr/bin/head

That being said try making your path as follows.

export ANDROID_HOME=/Users/chema/sdk-android/sdk export PATH=~/.composer/vendor/bin:$PATH export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH export PATH=$PATH:/Applications/XAMPP/xamppfiles/bin 

This should put the xampp version of head at the end of your path. But this might cause other name collisions that cause XAMPP not to work (I don't have either installed so cannot test) (also removed the the export PATH=${PATH}:/Users/chema/sdk-android/sdk/platform-tools:/Users/chema/sd$ which was adding what looked like redundant /wrong paths into your path)

IF this still doesn't work, your best bet might be to create a wrapper script to run cordova, something that sets the path to one you know works and then just passes the command line options along

--edit--

on OSX path is built up by the path_helper which builds up the path from /etc/paths && /etc/manpaths This is run from you shells init code /etc/profile, /etc/zshenv, etc.. and sets up the base PATH

based on your comment of head still being the one in /Applications/XAMPP/xamppfiles/bin it appears that this line export PATH=$PATH:/Applications/XAMPP/xamppfiles/bin is either not being executed, or /Applications/XAMPP/xamppfiles/bin was already in the PATH from somewhere else (IE you keep sourcing your .bashrc, or the like as opposed to creating a new shell, etc.. )

So try this. put the following in reset_paths.sh

#!/bin/sh export PATH= if [ -x /usr/libexec/path_helper ]; then eval `/usr/libexec/path_helper -s` fi PATH=~/.composer/vendor/bin:$PATH PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH PATH=$PATH:/Applications/XAMPP/xamppfiles/bin export PATH 

what this will do is reset your path, execute path_helper to set the paths from the OS, and then tack on so we are starting fresh..

then in your shell do source ./reset_paths.sh

then try to run Cordova from that shell and see if it works.

Sign up to request clarification or add additional context in comments.

6 Comments

Ok, I will test later, at home!! ;)
Sorry @Doon, it's not working... :( I have created a bounty... thanks
what is error message with above? and what does which head show
This is my head:/Applications/XAMPP/xamppfiles/bin/head
can you tell me more details about create a wrapper script to run cordova? Thx!
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.