PHP versions listing doesn't seem to work
Closed this issue · 17 comments
ZSH
: 5.0.2
brew-php
installed: 5.4.20
& 5.5.4
php-version
installed via homebrew, version 0.9.10
.
However, executing php-version
shows nothing!
- What is the output of
command -v php-version
? - What is the output of
echo $(find $(brew --cellar) -maxdepth 1 -type d | grep -E 'php[0-9]+$')
Here you go.
~ command -v php-version
php-version
~ echo $(find $(brew --cellar) -maxdepth 1 -type d | grep -E 'php[0-9]+$')
/usr/local/Cellar/php54 /usr/local/Cellar/php55
Please excuse the delay.
Please try running the master branch and paste the output of the "bug-report" script. Instructions are listed here:
https://github.com/wilmoore/php-version/wiki/Troubleshooting
Hi,
Below is the output of the "bug-report".
## System
Darwin Ngoc-rMBP.local 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
## Script
VERSION: php-version
TYPE: php-version is a shell function
## Environment
SHELL: /usr/local/bin/zsh
PATH: /Users/ngocpham/.rbenv/shims:/usr/local/bin:/usr/local/sbin:/Users/ngocpham/.gem/ruby/1.8/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/bin:/bin:/usr/sbin:/sbin
PHPS:
PHP_VERSIONS:
## Homebrew
VERSION: 0.9.5
PATH: /usr/local/bin/brew
PHPS: /usr/local/Cellar/php54
/usr/local/Cellar/php55
## PHP
VERSION: 5.4.20
I've recently realized that you've got to unlink the brewed formulas; perhaps that will help in this case:
brew unlink php54
brew unlink php55
php55
hasn't been linked yet because php54
is in-use. Just unlink php54
but nothing changes.
~ php-version
~ brew unlink php54
Unlinking /usr/local/Cellar/php54/5.4.20... 576 links removed
~ php-version
EDITED: It works with the master code, I think.
Not quite sure if it's actually works. Installed version from homebrew
still shows nothing.
Do the steps noted in here and trigger php-version
, I get:
5.4.20
5.5.4
Yes, there's a space before 5.4.20
.
This seems to work regardless I have linked or unlinked the php54
brew. I can now use php-version 5
to switch to php55
, or php-version 5.4
to switch to php54
. php -v
shows that it has been switched.
However, the php-version
command solely still doesn't show the current "active" version.
What I've noticed is that the switching will work regardless of linking or unlinking; however, the "current" version detection gets confused if you have a linked PHP. This is because homebrew-php links the php binary to the $HOMEBRW_PREFIX/bin directory which effectively makes it the first php found even if you haven't actually told php-version
that you want to switch to a particular version. So, it's better to always unlink even if it seems like it is working without unlinking.
So, I would try to unlink, then start a new shell, type php-version
and see if it shows a *
next to any version (it should if you've added php-version 5
to your shell profile). BTW, there should always be two spaces before the version when you type php-version
. The first spot is reserved for the current version *
and the second space is always blank, then there is the version.
Should look something like this:
* 5.4.20
5.5.4
I'm going to install a second version of php to see if I can replicate what you are seeing. In the meantime, let me know if unlinking helps.
What I said above is when I both tried to unlink the php54
and relink it. In both cases, triggering php-version
(the temporary from master
) always shows the output I posted.
To be more clear about this, I will tell you my steps.
- Clone git to get latest changes from
master
into/tmp
brew unlink php54
- Open new iTerm tab
php -v
report system version, which is5.3.x
source php-version/php-version.sh
php-version 5
php -v
shows5.5.4
, so the latest script works on switching PHP versionphp-version
still show 2 versions without any*
indicating current active version
Am I getting it wrong or what?
Thank you for your support.
@ngocphamm: thanks for the info...yes, I see what may be going wrong. Since I have never had more than one homebrew php version installed at once (I generally compile on my own), I didn't notice this issue.
You are definitely seeing a bug. I'm heading to the gym now but tonight I will be able to check into and correct this issue.
Thanks for hanging in there...this should be corrected soon.
@wilmoore Thanks for your confirmation. I just thought that it would be my wrong usage of it. Have a good day!
@ngocphamm, no problem.
This is resolved by de8331d. To verify, please try against the latest in mater.
It's okay now. I can switch and see my current "active" version. Thank you very much for it. Waiting for a release and a pull request on homebrew
for this update.
Excellent. I'll close this since all you need now is this to be merged: josegonzalez/homebrew-php/pull/775
BTW, it doesn't actually have to be merged for you to install it. You can install version 0.10.3
with a direct link to the commit:
% brew remove php-version
% brew install https://raw.github.com/wilmoore/homebrew-php/1fe5bdf389e8ad19fb816d3d093c26faa834203c/Formula/php-version.rb
Cool! Thanks a lot!
Anytime 👍