Skip to content

Feature Request: Ability to pack gems into a single file #7578

@risen

Description

@risen

Distributing ruby apps is currently more difficult than it needs to be.

It usually involves a set of instructions telling the end-user how to get the right ruby version, to regenerate or use an existing Gemfile.lock, maybe deal with uninstallable gems (because of dependency issues), etc. The alternative is dealing with Docker, but that comes with its own difficulties.

It would reduce a lot of friction and make ruby more attractive if the tooling enabled compiling and distributing a single-file static binary, or something as close to it as possible.

There's been projects in the past that tried to solve this, like:

These solutions usually end up slightly outdated, and would benefit from a bundler integrated solution.

I think it's important to distinguish different levels of "packing".

  1. Just the gem dependencies (ruby)
    Basically storing everything in the bundle path in a zip, SquashFS or DwarFS read-only image, and ensuring load, require, etc do the right thing. Maybe using a ruby shebang argument, a bundler/inline-like statement, and/or something like a __END__ hack to actually inline the image.
  2. All (file) resources
    This would require implementing ruby's File API to be able to read the bundle image. Useful for things like assets and other ancillary files.
  3. All (file) resources accessible through gem extensions
    This would require linking some C libc/vfs overrides, which would probably make things like bootsnap work. I believe wasi-vfs takes a similar approach.
  4. Everything including the ruby interpreter
    Even better if we could statically compile the whole thing.

I believe an official bundler-supported solution for even just 1. or 2. would be a big help.

Maybe the solution is just to rely on ruby.wasm, ruvy and wasi-vfs, even if depending on wasm would limit the applicability. But even then it'd still be nice to ensure the tooling around bundler would make it very easy to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions