• Stars
    star
    1,559
  • Rank 30,018 (Top 0.6 %)
  • Language
    C
  • License
    MIT License
  • Created almost 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Packing your Ruby application into a single executable.

Ruby Packer

Packing your Ruby application into a single executable.

Windows macOS Linux

Features

It takes less than 5 minutes to compile any project with Ruby Packer.

You won't need to modify a single line of code in your application, no matter how you developed it as long as it works in plain Ruby!

  • Works on win Windows, macOS macOS and linux Linux
  • Windows is supported via the native Windows API; there are no MSYS2/MinGW/Cygwin dependencies
  • Creates a binary distribution of your Ruby and/or Rails application
  • Supports natively any form of require and load, including dynamic ones (e.g. load(my_path + '/x.rb'))
  • Ruby Packer is written in Ruby and is packed and distributed using Ruby Packer itself
  • Native C extensions are fully supported
  • Open Source, MIT Licensed

Known Limitations

  • Some gems that use C extensions that use libc IO to load files from your Rails application will not work with rubyc. Notably, bootsnap will not work with rubyc
  • On macOS and Linux, DTrace is currently disabled, see #114

Download

Stable Releases

Here is the latest stable Ruby Packer release:

OS Arch. Executable
Windows x64 https://gw.alipayobjects.com/os/rmsportal/WxwlPrUTTReYNVVxJMtR.zip
macOS x64 https://gw.alipayobjects.com/os/enclose-prod/b812fa0f-d52b-44f1-8233-65ab8707cf1f/rubyc-v0.4.0-darwin-x64.gz
Linux x64 https://gw.alipayobjects.com/os/enclose-prod/1fd23e6b-d48f-4ed0-94dd-f0f539960253/rubyc-v0.4.0-linux-x64.gz

Unstable Pre-release

Whenever the master branch CI succeeded, a Ruby Packer pre-release binary would be automatically generated. Here is the latest unstable pre-release build:

OS Arch. Executable
Windows x64 https://github.com/pmq20/ruby-packer/releases/download/windows-x64/rubyc.exe
macOS x64 https://github.com/pmq20/ruby-packer/releases/download/darwin-x64/rubyc
Linux x64 https://github.com/pmq20/ruby-packer/releases/download/linux-x64/rubyc

Install

win Install on Windows

First install the prerequisites:

Then download rubyc.exe from either Unstable Pre-release or Stable Releases. Optionally, put it under C:\Windows or any other PATH directories. Open Visual Studio's "x64 Native Tools Command Prompt" and execute rubyc --help therein.

macOS Install on macOS

First install the prerequisites:

  • SquashFS Tools: brew install squashfs
  • Xcode
    • You also need to install the Command Line Tools via Xcode. You can find this under the menu Xcode -> Preferences -> Downloads
    • This step will install gcc and the related toolchain containing make
  • Ruby

Then download rubyc from either Unstable Pre-release or Stable Releases. Run chmod +x to give it execution permissions and execute ./rubyc --help.

linux Install on Linux

First install the prerequisites:

  • SquashFS Tools
    • sudo yum install squashfs-tools
    • sudo apt install squashfs-tools
  • gcc or clang
  • GNU Make
  • Ruby

Then download rubyc from either Unstable Pre-release or Stable Releases. Run chmod +x to give it execution permissions and execute ./rubyc --help.

Usage

rubyc [OPTION]... [ENTRANCE_FILE]

ENTRANCE_FILE refers to the path of an executable ruby script from your project, e.g. "bin/rails".
If ENTRANCE_FILE was not provided, a single raw Ruby interpreter executable would be produced.

-r, --root=DIR                   The path to the root of your application
-o, --output=FILE                The path of the output file
-d, --tmpdir=DIR                 The directory for temporary files
    --keep-tmpdir                Keeps all temporary files that were generated last time
    --openssl-dir                The path to openssl
    --make-args=ARGS             Extra arguments to be passed to make
    --nmake-args=ARGS            Extra arguments to be passed to nmake
-i, --ignore-file=STRING         Ignore file(s) from build
    --debug                      Enable debug mode
    --quiet                      Enable quiet mode
-v, --version                    Prints the version of rubyc and exit
-V, --ruby-version               Prints the version of the Ruby runtime and exit
    --ruby-api-version           Prints the version of the Ruby API and exit
-h, --help                       Prints this help and exit

The --openssl-dir Option

rubyc compiles its own version of openssl without any certifications. To be able to use ssl with rubyc it should know where to find the certifications.

By default this path is set to /usr/local/etc/openssl/ but can be overridden using the --openssl-dir argument.

Keep in mind that users running your compiled package should have their certifications present in this directory as well.

The --ignore-file Option

If you don't want certain files included in the build you can ignore them from the command line using -i.

rubyc -i ignore.file -i ignore-2.file -i "ignore*"

Alternatively you can create a .rubycignore file in the root of your project to specify which files should be ignored.

Examples

Producing a Portable Ruby Interpreter Executable

I.e. packing the raw Ruby interpreter without packing any projects:

rubyc
./a.out (or a.exe on Windows)

Packing a CLI utility

Taking Ruby Packer itself as an example of the CLI utility to pack:

git clone --depth 1 https://github.com/pmq20/ruby-packer
cd ruby-packer
rubyc bin/rubyc
./a.out (or a.exe on Windows)

Packing a Rails Application

rails new yours
cd yours
rubyc bin/rails
./a.out server (or a.exe server on Windows)

Building rubyc from Source

To build rubyc you must have a C compiler and the necessary toolchain to build ruby and the libraries stuffed inside rubyc which include at least:

  • gdbm
  • libffi
  • ncurses
  • openssl
  • readline
  • yaml
  • zlib

If you are unsure if your toolchain is complete then trying to build rubyc will let you know you are missing something. Unfortunately it may tell you with some unfamiliar message. Please file an issue here if this occurs.

Once your toolchain is set up run bundle. To compile your own rubyc run:

bundle exec rake rubyc

Or (if you want to compile with debug symbols):

ENCLOSE_IO_RUBYC_ADDTIONAL_ARGS=--debug bundle exec rake rubyc

This will produce a single rubyc executable, which can be put inside any of your PATH locations, so that it can be directly called from the command prompt. For example:

mv rubyc /usr/local/bin

Remember that rubyc includes all the files from the current directory in the built executable. You must delete the prior rubyc or your squashfs will continually grow larger and the embedded squashfs compile time will be very, very long.

Authors

Minqi Pan et al.

License

MIT

See Also

More Repositories

1

node-packer

Packing your Node.js application into a single executable.
C++
3,067
star
2

libautoupdate

Cross-platform C library that enables your application to auto-update itself in place.
C
152
star
3

libsquash

Portable, user-land SquashFS that can be easily linked and embedded within your application.
C
135
star
4

mathjax-rails

Simple gem to integrate MathJax with Rails and maintains MathJax at a system-wide directory.
Ruby
65
star
5

ssh2http

Delegating git ssh requests to git http backends.
Ruby
34
star
6

disclose

Pack your Node.js project into an executable without recompiling Node.js
C
26
star
7

FormCore

.NET + React + Ant Design infrastructure for inheritable dynamic forms
JavaScript
12
star
8

fast-hessian

High-performance C++ implementation of Hessian 2.0 Serialization Protocol for Node.js.
JavaScript
11
star
9

grape-rails-routes

Add routes printing for Grape with Rails
Ruby
9
star
10

thebooks

่ฏ•้ชŒไธ€ไธ‹steak BDD
Ruby
3
star
11

CNUKejian

Courseware Sharing System
Ruby
3
star
12

spreadtheword

Automatically generate a release-note document based on git commit messages.
Ruby
3
star
13

git2

git commands implemented on libgit2
C
2
star
14

kaokaodianping

่€ƒ่€ƒ็‚น่ฏ„โ€”โ€”ๆŒ‘้€‰ๆœ€้€‚ๅˆไฝ ็š„ๅŸน่ฎญๆœบๆž„
JavaScript
2
star
15

BLOG-OF-P.S.V.R

P.S.V.R's old blog
C
2
star
16

redis-search-amplifier

Amplifies the effectiveness of redis-search via the aid of remote search engines
Ruby
2
star
17

nodejs-experiments

1
star
18

cnudenglu

็™ป้™†CNUๆœ‰็บฟๅฑ€ๅŸŸ็ฝ‘ๅ’Œๆ— ็บฟๅฑ€ๅŸŸ็ฝ‘็š„ๅฟซ้€Ÿ่„šๆœฌ
1
star
19

homeland-pm

adds Personal Message service to Homeland
Ruby
1
star
20

cnucamp

cnucamp.org
Ruby
1
star
21

ruby-toolbox-best-gems

list best gems pulled from ruby-toolbox.com
Ruby
1
star
22

rails3-mongoid-devise-and-goodies

a skeleton rails 3.1 app featuring mongoid and devise and other good gems
1
star
23

duanfault

ๆฎต้”™่ฏฏ
1
star
24

tmp_csharp

tmp_csharp
1
star
25

edu_sphere

digged up the first rails app that I made, very old indeed
JavaScript
1
star
26

ruby-packer-tests

Performing download-and-run tests on the single binaries generated by Ruby Packer.
PowerShell
1
star
27

bio

DNAๅบๅˆ—ไธ‰็ปดๆ‹Ÿๅˆ
Ruby
1
star
28

jgdianping

Evaluation Website for Training institutions
1
star
29

pmq20.github.io

https://www.minqi-pan.com
TeX
1
star
30

cssImagePeeler

Peel Off images From a CSS file and Save them onto disk
Ruby
1
star
31

silver-data

1
star
32

rails-diff-track

tracks the diff of the default directory structure generated by `rails new`
Ruby
1
star
33

ie_isolation

Isolate a set of views specially for IE and deprecated browsers for Ruby on Rails.
1
star
34

active_record_dump

dumps your database to active record statements and then can be easily transferred to other databases
1
star
35

rng2sql

A tool to convert RELAX NG to SQL tables, or, put in another way, creating SQL tables according to RELAX NG
1
star
36

rails-redis-cache

Redis-based query cache for rails models, like get_name_via_id, get_address_via_name, etc.
1
star
37

tracing-a-memory-leak-in-a-long-running-eventmachine-application-en

Presentation: In Huanteng Smart we manufacture smart household gadgets which all connect to a single long running eventmachine application to receive and send instructions with the server. This eventmachine application is a single Linux process holding all TCP connections never closes them. One day, we found that this process was leaking memory, and here is how we managed to trace its cause.
R
1
star
38

ios_hello_world

Simple iOS prj as a team Run-in
Objective-C
1
star