Reputation: 14937
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!!
Upvotes: 2
Views: 1487
Reputation: 20232
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.
Upvotes: 2