1
0
Fork
You've already forked backpack-ruby
0
(M)Ruby-based toolchain for scripting and development on and for tool-poor environments
  • Ruby 83.7%
  • Shell 10.5%
  • Dockerfile 5.8%
2025年11月15日 09:41:37 -05:00
container_builds/docker-linux Initial release, copied from another (messy, private) repo. 2025年09月25日 13:23:09 -04:00
docsrc Initial release, copied from another (messy, private) repo. 2025年09月25日 13:23:09 -04:00
AUTHORS Initial release, copied from another (messy, private) repo. 2025年09月25日 13:23:09 -04:00
build_config.rb Initial release, copied from another (messy, private) repo. 2025年09月25日 13:23:09 -04:00
build_config.rb.lock Initial release, copied from another (messy, private) repo. 2025年09月25日 13:23:09 -04:00
LICENSE Initial release, copied from another (messy, private) repo. 2025年09月25日 13:23:09 -04:00
QUIRKS_and_DEV.md Initial release, copied from another (messy, private) repo. 2025年09月25日 13:23:09 -04:00
Rakefile Initial release, copied from another (messy, private) repo. 2025年09月25日 13:23:09 -04:00
README.md Initial release, copied from another (messy, private) repo. 2025年09月25日 13:23:09 -04:00

Backpack Ruby

A Ruby toolkit that you can keep in your backpack in case you need to automate something out in the digital wilderness far away from any kind of package manager.

More precisely, Backpack Ruby is a Ruby-based toolchain contained in a small number of files with very few dependencies on the surrounding operating system. It can be used to develop software on any system with a text editor but it can also produce self-contained single-file executables.

Less Hype, More Details

This repository is really just a set of scripts that will build full-featured MRuby binaries (interpreter, REPL, bytecode compiler, debugger) plus monolith, a tool that abuses the COFF and ELF formats to create standalone MRuby executables.

In addition, there are a number of useful third party gems, including a lot of the usual Ruby staples (e.g. regexps, optparse, JSON and YAML, and Marshal), a simple testing framework, and the SQLite3 database engine.

This, along with all of the available documentation, is packed into a small(ish) tarball that you can unzip somewhere and add or symlink into your path.

The build process and gem choices have been carefully tweaked to produce binaries that are either completely static or depend only on core system shared objects. If you have Backpack Ruby binaries for a given OS and CPU architecture (and ABI), there's a good chance it will work out of the box.

Using It

After obtaining binaries (or building with rake dist), unzip them somewhere and add bin/ to your PATH. This gives you the usual MRuby tools:

$ echo 'def foo() ; puts "foo"; end' > foo.rb
$ echo 'def bar() ; foo(); puts "bar"; end' > bar.rb
$ echo 'bar()' > main.rb
# Interpreter...
$ mruby -r foo.rb -r bar.rb main.rb 
foo
bar
# Bytecode compiler
$ mrbc -g -o main.mrb foo.rb bar.rb main.rb
$ mruby main.mrb 
foo
bar
# Interactive debugger
$ mrdb -b main.mrb 
(foo.rb:1) n
bar.rb:1
1 def bar() ; foo(); puts "bar"; end
(bar.rb:1)

You also get monolith; this creates self-contained standalone binaries:

$ monolith main.mrb -o main.bin
$ ./main.bin 
foo
bar

Caveat

MRuby is a subset of Ruby. You won't get all of the features available to you if you use mainline Ruby (or even JRuby), nor will you be able to use gems. Backpack Ruby is intended to be a better-than-nothing alternative when you can't use actual Ruby.