I’m trying to find a thing, and I’m not turning up anything in my web searches so I figure I’d ask the cool people for help.

I’ve got several projects, tracked in Git, that rely on having a set of command line tools installed to work on locally - as an example, one requires Helm, Helmfile, sops, several Helm plugins, Pluto, Kubeval and the Kubernetes CLI. Because I don’t hate future me, I want to ensure that I’m installing specific versions of these tools rather than just grabbing whatever happens to be the latest version. I also want to ensure that my CI runner grabs the same versions, so I can be reasonably sure that what I’ve tried locally will actually work when I go to deploy it.

My current solution to this is a big ol’ Bash script, which works, but is kind of a pain to maintain. What I’m trying to find is a tool where I:

  • Can write a definition, ideally somewhere shared between projects, of what it means to “install tool X”
  • Include a file in my project that lists the tools and versions I want
  • Run the tool on my machine and let it go grab the platform- and architecture- specific binaries from wherever, and install them somewhere that I can add to my $PATH for this specific project
  • Run the tool in CI and do the same - if it can cache stuff then awesome

Linux support is a must, other platforms would be nice as well.

Basically I’m looking for Pythons’ pip + virtualenv workflow, but for prebuilt tools like helm, terraform, sops, etc. Anyone know of anything? I’ve looked at homebrew (seems to want to install system-wide), and VSCode dev containers (doesn’t solve the CI need, and I’d still need to solve installing the tools myself)

  • bigredgiraffe@lemmy.world
    link
    fedilink
    arrow-up
    13
    ·
    9 months ago

    I think what you are looking for can be found in rtx or asdf, I have used both for what you are describing, even those same tools hah. I’m currently using rtx more than asdf though for newer projects. I have been tempted by nix though, might take that plunge soon.

    • metacat@programming.dev
      link
      fedilink
      arrow-up
      5
      ·
      9 months ago

      I recently started using rtx and I’m a big fan.

      Works for a long list of tools and makes it very easy to remove lots of install commands and just do “rtx install” in any directory to install and switch to right versions of a set of tools. Also works great on CI using same configuration files.

      • neidu@feddit.nl
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        9 months ago

        Rtx on/off meme template;

        “Off” is a greyscale picture of metacat struggling with manual dependencies. Possibly combined with “Isn’t there a better way?” from ye olde shopping channel ads.

        “On” Is a HDR image of a smiling metacat having no such issues. In the background a rainbow can be seen over a flowery garden, in which people are holding hands with rabbits frolicking in the grass.

        Yeah yeah, I know, I’ll go to bed now…

  • snowe@programming.devM
    link
    fedilink
    arrow-up
    8
    ·
    9 months ago

    Asdf is what you’re looking for. We use it in every repo and it manages every tool version with no issues.

  • jeffhykin@lemm.ee
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    9 months ago
    • Pkgx (formerly Tea) from the creator of homebrew
      • it’s adsf but professional instead of crappy (yes, shots fired, I’ve used asdf for a long time)
    • devbox for better reproduciblity than Pkgx
    • And yes Nix (obligatory; BTW I use nix btw btw). Nix is supposed to be exactly what you’re asking for and has unbeatable reproducability. But it’s simply not ergonomic enough yet. I’ve been deep diving into it for 3 years and it’s still painful to setup a project with it. Devbox uses nix under the hood but kinda of abuses nix. So it looses some of the guarantees but gains being usable/ergonomic today.

    Full disclosure, I use nix (not devbox) for all my stuff cause I care about hardcore reproduciblity.

      • jeffhykin@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        9 months ago

        It has random side effects that break cli tools (tools that are not even installed with ASDF)

        The more versions you add, the slower it gets. And it can get really slow (that issue was opened in 2018, and it is fixable).

        It’s got many “well it works on my machine” problems. And the author said that’s a “wontfix” design choice. That’s fine for the author, it’s FOSS. But it means my workflow is going to randomly break and I just can’t have that when it’s my job.

        Pkgx, Devbox and nix avoid all these things.

      • Andy@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        9 months ago

        I’m not who you asked, and not a user of pkgx, but one of the reasons I prefer rtx (which supports asdf plugins) to asdf is that by default it doesn’t use shims, but updates the PATH instead.

        So for example, running which python will show me a clearly versioned python executable path, rather than a mysterious shim that represents a different realpath at different times.

  • RegalPotoo@lemmy.worldOP
    link
    fedilink
    English
    arrow-up
    2
    ·
    9 months ago

    Thanks for the suggestions. As an update:

    • I spent a few hours playing about with Nix; it’s really cool, definitely a very interesting idea but the “time required to learn the tool” to “time saved by using the tool” to “time spent fixing things when it turns out you don’t know the tool as well as you thought” ratio isn’t looking great right now
    • I’ve reworked one of my repos to use rtx - it’s not perfect, but it’s doing what I want without much fuss, so probably going to go with this for now
      • RegalPotoo@lemmy.worldOP
        link
        fedilink
        English
        arrow-up
        2
        ·
        9 months ago

        Tbh, I think my issues are less with rtx itself and more the plugins I’m using and the constraints imposed by the asdf plugin structure.

        I ran into issues where poorly written plugins could fail to install, but rtx wouldn’t recognise the issue and if I re-ran “rtx install” a second time it would tell me that the runtimes were all up to date. I’ll see if I can put together a GitHub issue describing it in more detail.

        It’d be nice if there was a simple way to reference a local directory as a plugin for a project rather than having to publish a separate git repo.

        Generally it’s a really well built tool and the docs are excellent, my complaints are nitpicks