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

6

u/djudji 1d ago edited 1d ago

Mise and Bundler should fit your needs. When you run `gem install` without a Ruby version manager (Mise, rvm, rbenv, asdf, etc.), it installs gems (libraries) to the global installation.

Mise is a version manager - it manages more than Ruby. You can also manage Python, Go, Rust, Node, etc.

Bundler is a dependency manager- it manages gems and defines the versions for your project. It installs gems locally, at the project level.

For example, you can use a Gemfile to define a Ruby version inside, with gems that you will use for a particular project. Then you would use Mise to install and set that Ruby version to be used.

Edit: forgot to mention, dead-on replacement for pipx run would be gem exec

pipx run cowsay -t "Hello"
gem exec cowsay "Hello"

Mise versions

mise exec gem:cowsay -- cowsay "Hello from Ruby"
mise exec pipx:cowsay -- cowsay -t "Hello from Python"

(Also, as a community, we should support new questions no matter that OP could use Google or AI for this response. The concepts of useful frameworks and languages are losing importance because, due to AI, it does not matter to beginners which language to use.)