Ruby question: solution for dependency version specs?

Austin Ziegler halostatue at
Sat Mar 16 22:09:19 UTC 2024

On Sat, Mar 16, 2024 at 3:29 PM Sergio Had <vital.had at> wrote:

> On Mar 17, 2024, at 12:57 AM, Austin Ziegler <halostatue at> wrote:
> I am most definitely a Ruby expert, but I have yet to run any version of
> Ruby from MacPorts (because I use `ruby-build` and `mise` to build versions
> of Ruby that I require), and I almost exclusively install Ruby packages via
> `gem install`.
> You could perhaps try sudo port install ruby33 or whatever needed?
> I have no idea what is going on with archaic versions, but Ruby 3.1+
> through ruby-devel (3.4) should work on every system.

I could, but I think you misunderstand: as someone who has done a lot of
Ruby development and have responsibility for a couple of 100M+ downloaded
gems (both mime-types and diff-lcs are mine), I *choose* not to use system
Ruby installations, including those of MacPorts. Much of it has to do with
why systems like chruby, rbenv, and rvm exist — Debian maintainers made an
absolute hash of Ruby packaging in the early 2000s and often frequently did
a poor job of packaging the few gems that they did.

> Many gemspecs contain information about the minimum Ruby that they require
> to run (mime-types 3 requires Ruby 2+,
> diff-lcs advertises compatibility with Ruby 1.8+; app_identity advertises
> Ruby 2.7+, but not Ruby 4,
> ).
> What I mean is that gemspec files often require a version of some another
> gem using ~> instead of >= like
> That prevents gems from running if a dependency is newer. For example,
> rb-launchy is at 3.0.0:
> Then I need to do something like this:
> Problem is that this is quite painful to deal with for every relevant case.

While not all Ruby gems follow strong semver, what you are doing here is
inadvisable at best. Ruby *permits* (through RubyGems) the installation of
multiple versions of the same gems—and as Ruby versions are released, more
of the standard library is being shifted into "default gems", meaning that
applications can choose to use later versions that may have new features or
possible bug fixes that are not included in the shipped version of Ruby.

Ruby packages would be much better served by installing gems *as gems*
(this can be done offline with `gem install --local foo-version.gem` once
downloaded) than trying to repackage all of the gems as ports with only a
single version available. I have (extremely vague) plans at some point for
mime-types 4 and diff-lcs 2 that will drop support for any version of Ruby
less than 3.0, but that will not stop mime-types 3 and diff-lcs 1 from
working on older versions of Ruby.

I reiterate that Ruby application ports (like sup or t) should *probably*
be set up more like Go or Rust ports and that a tool like `go2port` or
`cargo2port` (`gemspec2port, bundler2port`) which ultimately downloads the
gemfiles and uses `gem install --local …` will be better than blindly
modifying the *intentional* use of `~> 3.0` or installing `rb33-launch 3.0`.

Austin Ziegler • halostatue at gmail.comaustin at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the macports-dev mailing list