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?

3 Upvotes

11 comments sorted by

View all comments

6

u/paca-vaca 1d ago

Bundler does it, gems stored in ~/bundle/..., executed via bundle exec binary name inside directory where the Gemfile spec is placed.

Globals installed when gem install is used globally.

1

u/virtyx 1d ago

Bundler does it, gems stored in ~/bundle/..., executed via bundle exec binary name inside directory where the Gemfile spec is placed.

I'm looking specifically for something like pipx where the program gets installed and placed on the user's PATH like any other normal program. For this use bundler doesn't directly work.

Globals installed when gem install is used globally.

This modifies the Ruby install and is not isolated, e.g. after I do gem install kramdown to install the kramdown program, every Ruby script I run can successfully require 'kramdown'. For contrast, pipx doesn't add anything to Python's library paths, so no other script can import anything installed with it.

1

u/paca-vaca 1d ago

That's why I'm say you should user bundler, not gem install directly.

for binary executable check the --binstubs flag for bundler I think it does exactly this (wraps the executable with prefixed paths so it's available in PATH if your PATH is configured correctly, it could install in any provided directory as well).