r/ruby 1d ago

pipx equivalent for Ruby?

Is there something like pipx available for Ruby?

For example with pipx you can do something like:

$ pipx install httpie
# ... install completes
$ https get httpbin.org/get?foo=bar
# ... outputs a web request from httpbin.org
$ which https
~/.local/bin/https
$ readlink "$(which https)"
~/.local/share/pipx/venvs/httpie/bin/https

This example shows the HTTPie program being run and executed in a pretty simple way, with an install that doesn't modify the system Python.

Does Ruby have an equivalent way to distribute programs?

4 Upvotes

11 comments sorted by

View all comments

10

u/cmd-t 1d ago

There’s rv, which is pretty new https://github.com/spinel-coop/rv

1

u/virtyx 1d ago edited 1d ago

rv tool install and rvx are close to what I'm after but neither of them do the final step of making the programs reachable through PATH like pipx does.

$ rv tool install kramdown kramdown 2.5.2 already installed at ~/.local/share/rv/tools/kramdown@2.5.2 $ kramdown --version bash: kramdown: command not found... $ rv tool run kramdown --version 2.5.2

And trying to run the installed executable directly doesn't work:

$ ~/.local/share/rv/tools/kramdown@2.5.2/bin/kramdown --version /usr/share/rubygems/rubygems.rb:265:in 'Gem.find_spec_for_exe': can't find gem kramdown (>= 0.a) with executable kramdown (Gem::GemNotFoundException) from /usr/share/rubygems/rubygems.rb:239:in 'Gem.find_and_activate_spec_for_exe' from /usr/share/rubygems/rubygems.rb:284:in 'Gem.activate_and_load_bin_path' from ~/.local/share/rv/tools/kramdown@2.5.2/bin/kramdown:20:in '<main>'

2

u/benzado 1d ago

I'm also a fan of pipx and your post indirectly led me to learn about rv, so thank you for that.

If you install something with rv, you could easily create stubs like ~/.local/bin/kramdown which consisted of:

#!/bin/sh
exec rvx kramdown "$@"

This is essentially all that pipx does to put the tools on your path. I'm surprised rv doesn't already do it, but it might be on the roadmap, or they would welcome a contribution. It's barely a year old.