Cork icon indicating copy to clipboard operation
Cork copied to clipboard

Add support for linking/unlinking apps

Open dsXLII opened this issue 7 months ago • 6 comments

Suggestion type

The way Cork works

What is your idea about?

I would like Cork to support brew link and brew unlink commands. These are a bit niche, so the UI might need to be thought through carefully.

Why should this be added?

I work somewhat regularly with a few versioned formulae, most notably php, and have to switch between different versions for compatibility testing. (Also, brew update tends to re-link the latest version when there are updates.) At least once or twice a day, I have to brew unlink php then brew link [email protected] (or whatever other version).

I've actually automated this with CLI aliases, but that's beside the point :)

Keeping it real

  • [x] Adding suggestion idea is realistic

dsXLII avatar Jun 08 '25 22:06 dsXLII

I'm thinking of adding this in the next release, would you be willing to share how your CLI aliases work? Because I don't understand the Homebrew documentation 😅

buresdv avatar Sep 02 '25 08:09 buresdv

Really, all I'm doing is

function relink-php() {
  brew unlink php
  brew link php@${1}
}

So nothing especially helpful, from your point of view, sorry.

dsXLII avatar Sep 04 '25 15:09 dsXLII

Thanks, I'm more interested in what linking does conceptually, and what problems it helps solve for you. I've never linked anything, and the documentation is very confusing on this matter

buresdv avatar Sep 04 '25 15:09 buresdv

I have multiple versions of PHP installed, because the PHP ecosystem is messy. So I did a brew install [email protected]; brew install [email protected]; brew install [email protected]; brew install [email protected]. Boom, now I have four different versions of PHP, in different directories under /opt/homebrew/Cellar .

If you want to test something with a different version, you can do a brew unlink php (to remove the symlinks from the current version), then a brew link [email protected], to recreate those symlinks but now pointing to an older version. Adding a -v to either of those commands lists the ~25 symlinks it's creating and removing every time I switch versions of PHP.

Of course all the individual versions are available under /opt/homebrew/Cellar, but that's a long complicated path that changes periodically, when there's a new maintenance release (8.3.24 to 8.3.25, etc). Being able to just use "php" is a great convenience, and is what most apps expect anyway.

For me, the biggest annoyance is when there's an update to the current version (8.4.11 to 8.4.12), the CLI will "helpfully" automatically link this newest version. Last week there were updates to both PHP 8.3.x and PHP 8.4.x, and when I did a brew update, even though I was at that time using PHP 8.2, the update switched the default PHP to 8.4. (That may be a limitation of Homebrew, honestly not sure.)

In Cork, the GUI actually shows all four versions as separate packages:

Image

I think my ideal would be for that to just say 'php', with an accordion maybe to show the multiple different versions, and a context menu to switch between them.

dsXLII avatar Sep 04 '25 15:09 dsXLII

Thank you very much for the detailed response, I want to write my own implementation of the linking system for Cork, because the built-in one is just way too slow.

Do I understand it right that the links go to /opt/homebrew/opt, and that, while you can have any package in /opt/homebrew/Cellar, it needs to be linked by creating a symlink to it inside /opt/homebrew/opt?

It's okay if you don't know, I'm just asking because you use manual linking, and Homebrew developers are hostile to me, so I can't ask them…

buresdv avatar Sep 08 '25 16:09 buresdv

https://github.com/buresdv/Spirytus/issues/1

kutlukaraosmanoglu avatar Nov 10 '25 19:11 kutlukaraosmanoglu