Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script leaves other php kegs left unlinked #14

Open
rot26 opened this issue Dec 6, 2015 · 3 comments
Open

script leaves other php kegs left unlinked #14

rot26 opened this issue Dec 6, 2015 · 3 comments

Comments

@rot26
Copy link

rot26 commented Dec 6, 2015

Hello, thanks for sharing!

I noticed that after running this script, my other php kegs are left unlinked.

How to recreate

Verified no link issues:

$ brew doctor
Your system is ready to brew.

On php version 5.6:

$ php -v
PHP 5.6.16 (cli) (built: Nov 27 2015 10:28:34)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

Now switch to 5.5:

$ brew-php-switcher 55
Switching to php55
Switching your shell
Unlinking /usr/local/Cellar/php54/5.4.45_3... 4 symlinks removed
Unlinking /usr/local/Cellar/php55/5.5.30... 4 symlinks removed
Unlinking /usr/local/Cellar/php56/5.6.16... 358 symlinks removed
Unlinking /usr/local/Cellar/php70/7.0.0... 22 symlinks removed
Linking /usr/local/Cellar/php55/5.5.30... 17 symlinks created
You will need sudo power from now on
Switching your apache conf
Password:
Restarting apache
All done!

Double check php versions:

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
    php54
    php56
    php70

My other remaining kegs of php are now left unlinked.

Proposed Solution

Can we make it so that this script does not leave those kegs unlinked? Usually I switch versions with this:

$ brew unlink php55 && brew link --overwrite php55

Thoughts?

@philcook
Copy link
Owner

philcook commented Dec 8, 2015

Hi @rot26,

Thanks for your idea and I would also like to be able to not have unlinked kegs for brew.

However I have never managed to find a way other than uninstalling to not have these unlinked kegs. The reason behind unlinking the other kegs is to make sure that on the CLI its the correct version of php running that a user intended.

Your proposed solution I tried out and unfortunately didnt work for me, here is what I did.

brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
    php55
    php56
    php70
brew unlink php55; brew link --overwrite php55
Unlinking /usr/local/Cellar/php55/5.5.30... 0 symlinks removed
Linking /usr/local/Cellar/php55/5.5.30... 18 symlinks created

brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
    php56
    php70

If you find some other way of getting this to work I would love to hear more on it.

@rot26
Copy link
Author

rot26 commented Dec 9, 2015

Hi @philcook,

Re:

The reason behind unlinking the other kegs is to make sure that on the CLI its the correct version of php running that a user intended.

I agree, but I think that when you brew link, it overwrites all the links it needs for that keg. For example, when php55 is the last keg you link, calling php will point to the brew php55 bin. However, if I want to switch to php56, I can use brew link to overwrite all the symlinks to point to the php56 bin.

It looks like you did relink php55, but you would have to re-link php56 and php70 also. Whichever one you linked last will be the active version of php.

I was thinking about this last night. I think we can just overwrite the symlinks instead of unlinking the other libraries.

I can open a PR, but I wanted to hear your thoughts first?
...

First, I verify that there are no issues

$ brew doctor
Your system is ready to brew.

I am currently linked to php56.

$ php -v
PHP 5.6.16 (cli) (built: Nov 27 2015 10:28:34)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

I want to switch back to php55, but I cannot simply "relink" php55 as the main version of php I want to use

$ brew link --overwrite php55
Warning: Already linked: /usr/local/Cellar/php55/5.5.30
To relink: brew unlink php55 && brew link php55

So first I unlink php55, and then force an overwrite of php55

$ brew unlink php55; brew link --overwrite php55;
Unlinking /usr/local/Cellar/php55/5.5.30... 4 symlinks removed
Linking /usr/local/Cellar/php55/5.5.30... 320 symlinks created

Now I verify that php55 is infact the php version I have linked.

$ php -v
PHP 5.5.30 (cli) (built: Oct  3 2015 23:48:03)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

And I verify that I have no unlinked kegs.

$ brew doctor
Your system is ready to brew.

@rot26
Copy link
Author

rot26 commented Dec 9, 2015

Note: you should make sure that you do not have unlinked kegs when running

$ brew doctor
Your system is ready to brew.

@philcook let me know if you see any problems with PR #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants