Skip to content
ocx
install

Every version at once, nothing overwritten

Two projects on one laptop need different CMake versions: what a store that names each build by its digest keeps on disk, and why installing a version never switches to it.

Duration

Transcript

An upgrade can quietly take away the one version something on your machine still needed.

This is the OCX Podcast for engineers who install tools on laptops and in pipelines.

I'm Vera.

And I'm Max.

This episode assumes you've tried OCX, a package manager that installs your tools from a registry and picks each machine's build.

In episode two, we used it to put two versions of one tool side by side and to switch between them.

This time, it's a laptop with two projects that need different versions of the same tool and room for just one of them.

The package manager on this laptop holds one CMake, three point thirty-one, and both of its projects lean on it.

A routine upgrade moves it to four.

Now the newer project, which needs four, finally configures.

The older project stops on the first line of its build file, the line that asks for its minimum.

Version four won't take a minimum that old.

Put three point thirty-one back, and the newer project is the one that fails.

Whichever CMake the laptop keeps, one of its projects stops at the configure step.

Four arriving wasn't the whole of it.

The upgrade also made four the only CMake anyone on this laptop gets, and nobody asked for that part.

The upgrade itself was reasonable.

The newer project needed four, and four is what it got.

It also got the spot three point thirty-one had been sitting in, under the same name.

An upgrade only breaks what it overwrites.

Upgrading less often wouldn't have saved the older project.

Giving every version a place of its own would.

With that, four arrives beside three point thirty-one, not on top of it.

Old minimums are where CMake four drew its line.

It dropped support for build files that ask for a minimum older than three point five.

On four, those don't configure without a workaround.

And keeping anything below four around isn't what the laptop's package manager is for.

It carries one version of each name.

That's a design choice, not a defect.

And for managing an operating system, it's the right one.

Homebrew, apt, and DNF all treat CMake that way.

Each stock package is a single version, and Homebrew doesn't even have an older CMake formula to put beside it.

Neither project is wrong about what it needs.

The laptop just has room for one CMake, and they need different ones.

We rebuilt that situation on Linux, the same pair of projects with both CMakes installed side by side in OCX.

The older project's configure step runs through it, names three point thirty-one, and writes its build files.

The newer project names four instead and goes through as well.

Same machine, same install, and each command says which version it wants.

That's the part the laptop's package manager couldn't do.

There, the machine picks the CMake a project gets.

Here, the command picks.

We cross them over as well.

The newer project on three point thirty-one stops at its version check.

The older one on four stops right where it did on the laptop.

Each project needs its own CMake, and here both get theirs.

On disk, the packages you install with OCX all sit in one place, each in a directory of its own.

That place is the store.

Each directory is named by the package's digest, a checksum that identifies one exact build.

Which is how both CMakes share one install without colliding.

Neither directory is named after its version.

It isn't named after a tag either.

The digest is the name, and a tag is a label that points at one of those directories.

We tested that with the tags both CMakes carry: a short version, a full version, and a dated build tag, or latest.

We installed six of them.

The extra ones all pointed at builds already in the store, so installing them fetched nothing.

Six tags, two directories, and the disk usage doesn't move.

The store keeps a build once, even with several tags pointing at it.

Which would mean both CMakes share whatever files they have in common, so keeping the second one around costs very little.

That's one step further than the store goes.

Identical builds are stored once.

These are different builds, so they share no files at all, and each one costs its full size on disk.

Fair enough.

Keeping the second one around means paying for every byte of it, and by itself, CMake four comes to about two hundred megabytes.

Every tool gets one fixed place on disk, holding whichever version you chose.

Select is the step that changes which version that is.

We'd chosen three point thirty-one for CMake, and installing four didn't move it.

Only a select would.

Arriving and switching are separate steps here, where the laptop's upgrade did both at once.

Tags can move too from the other end.

A publisher can push a different build under the same tag, so we did that with a test package of our own.

Until our machine refreshed what that tag pointed at, it kept running the build we'd installed.

After the refresh, running that tag fetched the build pushed later, while our install still pointed at the one it started with.

Some packages need another package to run.

One public example is pipx, which pins the Python it needs by digest.

We built one for this episode to show how that works. It needs CMake four and asks for it by its tag.

When our package is built, the tag is turned into a digest.

The digest goes into the description that travels with the package Try to push it with only the tag written down and the push is refused.

It wants a digest.

The digest is the name here too.

Installing fetches CMake by that digest and never looks the tag up.

Tag 4 can keep moving, and this package still asks for the exact build it was made with.

Anyone who's used Nix is hearing something familiar by now.

Builds named by digest, versions side by side, dependencies pinned.

Isn't that the Nix store?

It's close, and none of it is new.

Even the OCX docs compare its store to the Nix store.

The differences are in where that store lives and who needs root to create it.

Nix's cache is keyed to its store directory. Pick a different directory and you're rebuilding.

With OCX, you pick its folder before you install.

Any path, any length, and the pre-built binaries still work.

Nix also needs root to create its store directory in the first place, where OCX installs as you, no sudo and no root-owned prefix.

The older project's build file still asks for its old minimum.

Its configure step goes through anyway because it now names 3.31 through OCX.

Meanwhile, the laptop's package manager still holds one CMake.

It's 4, just as the upgrade left it, and both projects now name their own version instead.

Nothing about that package manager changed, and nothing had to.

The versions the projects ask for sit outside it in a folder of their own.

What sits in CMake's fixed place is a choice now, not something an upgrade does to you.

Moving it to 4 takes one select.

For a tool installed this way, going back takes another.

With both CMakes installed, type the tool's name on its own.

Which one actually runs?

Neither of the two that OCX holds.

The shell finds the laptop's own CMake, the one its package manager put there.

Episode 4 picks that up.

Nothing on the path you did not ask for.

Everything's at ocx.sh.

Same toolchain on every laptop.

And in CI.

See you next episode.