r/cpp • • Apr 26 '26

Is there a C++ "venv" equivalent?

Python have venv, Rust have cargo, Node have nvm. You clone a repo, run one command, you're in a reproducible environment.

Is there a viable alternative for C++? I don't think standard will ever bother with this and to their defence, not sure if that is even possible.

I've tried Conan, vcpkg, various CMake setups. They're not bad tools, but there's no standard "activation" ritual. No isolated-per-project environment that pins compiler + deps + toolchain together. No single lockfile that means the same thing on my machine, my colleague's machine, and CI. What I keep wanting is something like: "cppenv activate" and suddenly I'm in a clean, isolated, reproducible build environment for that project. Exit it, and my system is untouched. Share a lockfile, and a teammate gets the exact same thing.

How are you handling reproducible build/development environments?

107 Upvotes

132 comments sorted by

View all comments

Show parent comment

1

u/Electronic_Tap_8052 Apr 26 '26

Is that any good? I heard about it and looked it up and people said it kinda sucked

3

u/sol_runner Apr 26 '26 edited Apr 26 '26

It's got a learning curve. And it can be steep. Almost as much as moving from Windows -> Linux.

There's a whole functional programming language (nix) that you use to configure it. You can get by with basic understanding (I treated it almost like json for a long while). But then you get to version control it, and you can just use the same nix config on other PCs to port around what applications are installed etc.

If a project has a default.nix / flake.nix then I can just say 'nix-shell' / nix develop and it'll load all the toolchain/tools/libraries needed. (And with direnv I don't even need to use any commands; enter the folder to activate)