Hacker News new | past | comments | ask | show | jobs | submit login
Ruby Packer – Distribute Ruby code as a compiled binary (github.com/pmq20)
153 points by burlesona 35 days ago | hide | past | favorite | 33 comments

The project is broken and the author is ignoring fixes, while at the same time not acknowledging the fact that the project is dead.

Regardless the idea itself: it does work, and I think it's good for those who want to distribute (small) programs that for one reason or another can't be written in compiled languages.

I think a difficulty was certificates, but there was a strategy to make them work (that is, to pack the ones from the current O/S).

I'd love to try it out to deploy applications. Unfortunately this and the other projects in this category [1] are not actively developed: many open issues, some of them very important, and no commits in the last years or months.

[1] https://www.ruby-toolbox.com/categories/packaging_to_executa...

I didn't see Traveling Ruby in the linked list. Not sure how active its development is, but it's had activity in the last year: https://github.com/FooBarWidget/traveling-ruby

I've had more success with a similar tool, called ocra [1]

[1] https://github.com/larsch/ocra

Around a decade ago I used a script called ruby2exe and diving into that was a truly magical journey of discovery - finding an embedded Pascal compiler was... Interesting.

Did you ever find out what it was for?

Yep! The script was essentially:

* Invoke ruby program * Find all in-memory dependencies * Statically link ruby and the discovered dependencies * Compile with an args interface with the Pascal compiler * Spit out exe

This was for windows only if I recall correctly.

The submission title says "compiled" but actually this will just package Ruby code together with an interpreter.

Good point, and my mistake. Can't edit it now.

It's more on the embedded end of the spectrum, but https://github.com/mruby/mruby is another option in compiling ruby code and c extensions down to a single binary.

The project is quite broken indeed but it works after some tweaking. https://www.getmotoradmin.com/ uses ruby-packer to make it easy and fast to deploy an app (executable binaries are faster and easier to deploy than docker, also heroku deployment takes about 20-30 seconds).

This looks great, though if it's anything like my Python experience, it's basically impossible to produce an executable that works on a system that doesn't have Python installed.

Does anyone know of a project that'll do that? I tried 4-5 projects (IIRC Nuitka, py2exe, pyinstaller, shiv and some others) with no success.

> it's basically impossible to produce an executable that works on a system that doesn't have Python installed.

Really? I think many of solutions you've tried (including Nutika, py2exe and pyinstaller) do produce an executable with an embedded Python runtime [1]. I guess you were rather unable to produce a working executable, which can happen mainly due to peculiar dependency requirements. A list of dependencies you needed would help.

[1] (Added later:) see the following reply for what this exactly means.

Well the execution finished successfully in most cases, but the resulting binary had a dependency on libpython.so that it couldn't find. I'll try again, thanks!

I think some of them does require libpython.so/dll to be bundled together. In some cases like pyinstaller [1] you can alternatively choose to embed that DLL file into the final executable; in that case the executable would first extract itself into a temporary folder. The point is that you don't need the full Python installation to run that executable.

[1] https://pyinstaller.readthedocs.io/en/stable/operating-mode....

Hmm, that makes sense, thank you!

not used it myself, but here's a relatively new entrant to the space: https://pyoxidizer.readthedocs.io/en/stable/index.html

Oh I don't think I tried that one, thanks!

Another option in this space is Traveling Ruby by Hongli Lai (well-known in the Ruby world as the co-founder of Phusion and developer of Passenger and Enterprise Ruby)


Cool idea. I have written quite a few command line utilities over the years for certain tasks and this would be nice for distributing it to people, especially less technical or people unfamiliar with the ruby ecosystem.

Agree. As a Python person, I’ve been bummed out a few times in the past when there’s some tool I want to use and the first step to installing it is something something rvm that seems to make a huge mess I don’t know how to untangle.

Looking at you, old “hub” CLI from Github.

This seems really great! Reading it I didn't see anything about the size of the binary. How big is the resulting binary for a hello world type application?

I can't speak to the Ruby details but I used to use the same author's node-packer, which was the same concept for Node.js. It uses libsquash to store the script source and replaces the REPL entrypoint to run the embedded source from the internal squashfs.

The node.js binaries were about 50 MB which sounds large for hello world but the size would stay practically the same for a full featured application since everything is baked in already. I'd imagine the Ruby version is relatively similar in size but cannot say for sure.

The ruby 3.0 binary is 19MB so I would assume at least that big. I don't think there would be really any downsides to packing it in since the chance of the user having two ruby programs using the same ruby version are close to 0 anyway.

I wonder if this could be combined with something like Sorbet Compiler[1] to help with final size?

Personally I think I’d favour small static builds over linked binaries.

1. https://sorbet.org/blog/2021/07/30/open-sourcing-sorbet-comp...

A bit ignorant of me but could someone tell me what the use case is? Is it for faster deploys or something? And also how does it work with gems?

>A bit ignorant of me but could someone tell me what the use case is?

You want to send a simple script / program to someone without telling them to install Ruby. For 99% of people around they world, including programmers, they will much prefer to double click on an executable rather than yet another instruction set to install and run the program.

Thats a one giant executable though no?

An above comment mentioned that the ruby binary was 19MB. There would be other runtime included, but it's probably under 50MB. Yes it's large, but some Android apps do very little and are much larger...

I have a future use case for this, but as the code hasn’t been (entirely) written yet, I wonder about the feasibility of porting to Crystal and simply shipping the resulting binaries. Having struggled through Ruby2Exe years ago I wonder if this isn’t the more practical way forward. I have not done a thorough analysis of this issue yet, though, so it could go other ways.

(At issue here is library reuse where Ruby to Crystal, while not 1:1, would be close)

No word on how large the binary will be? No benchmarks? I would run it myself to find out but I've largely left Ruby behind for Crystal, I can already get the benefits of a binary "Ruby", far easier interop with C, and a community that isn't wedded to Rails and all that brings with it.

Looks very cool. Know anyone who’s using it?

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact