5 ms·
Ruby Packer – Distribute Ruby code as a compiled binary
- rgbrgb 5y agoLooks very cool. Know anyone who’s using it?
- p4rkr22 5y agohttps://www.getmotoradmin.com/ https://www.getmotoradmin.com/ uses it
- mberning 5y agoCool 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.
- mikepurvis 5y agoAgree. 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.
- Tistron 5y agoThis 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?
- blackfawn 5y agoI 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.
- SilverRed 5y agoThe 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.
- Lio 5y agoI 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-compiler https://sorbet.org/blog/2021/07/30/open-sourcing-sorbet-comp...
- pmontra 5y agoI'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_executables https://www.ruby-toolbox.com/categories/packaging_to_executa...
- mattjaynes 5y agoI 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 https://github.com/FooBarWidget/traveling-ruby
- sordina 5y agoAround 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.
- hkt 5y agoDid you ever find out what it was for?
- sordina 5y agoYep! 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.
- pizza234 5y agoThe 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).
- ultrarunner 5y agoI 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)
- brigandish 5y agoNo 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.
- rashil2000 5y agoI've had more success with a similar tool, called ocra [1] [1] https://github.com/larsch/ocra https://github.com/larsch/ocra
- stavros 5y agoThis 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.
- lifthrasiir 5y ago> 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.
- stavros 5y agoWell 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!
- lifthrasiir 5y agoI 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.html#bundling-to-one-file https://pyinstaller.readthedocs.io/en/stable/operating-mode....
- stavros 5y agoHmm, that makes sense, thank you!
- joelbluminator 5y agoA 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?
- ksec 5y ago>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.
- joelbluminator 5y agoThats a one giant executable though no?
- BenjiWiebe 5y agoAn 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...
- fxtentacle 5y agoThe submission title says "compiled" but actually this will just package Ruby code together with an interpreter.
- burlesona 5y agoGood point, and my mistake. Can't edit it now.
- p4rkr22 5y agoThe project is quite broken indeed but it works after some tweaking. https://www.getmotoradmin.com/ 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).
- mattjaynes 5y agoAnother 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) http://foobarwidget.github.io/traveling-ruby http://foobarwidget.github.io/traveling-ruby
- fundamental 5y agoIt's more on the embedded end of the spectrum, but https://github.com/mruby/mruby https://github.com/mruby/mruby is another option in compiling ruby code and c extensions down to a single binary.