Skip to content

Latest commit

 

History

History
146 lines (94 loc) · 6.06 KB

README.md

File metadata and controls

146 lines (94 loc) · 6.06 KB

Ruby Ship

Forked Changes

I am using ruby_ship to run my sinatra app, secretary, as an executable program. This means ruby_ship must come with the ruby interpreter and all dependencies pre-installed. I plan to wrap this executable in an Electron app and distribute it as a Desktop app. Right now it looks like ruby_ship supports OSX and linux but not Windows.

Notes:

  • hacky_bundler.rb is used in lieu of ./bin/ruby_ship_bundler.sh since the latter doesn't work.
  • ruby_ship executables are using ruby-2.6.6

Every time dependencies need to be compiled for a release of secretary, follow these steps:

  1. Copy over secretary's Gemfile and Gemfile.lock to ruby_ship/
  2. Run ruby hacky_bundler.rb to install the gems listed in Gemfile.lock
  3. Try running secretary using the ruby_ship executable, i.e. run ./bin/ruby_ship.sh path/to/secretary/secretary.rb
  4. Manually resolved gem version conflicts by uninstalling gems via ./bin/ruby_ship_gem.sh uninstall
  5. Repeat until all gem version conflicts are resolved and secretary can be run using the ruby ship executable.
  6. Relink dynamic libraries by running ruby /tools/auto_relink_dylibs.rb

Changes I made to the original ruby_ship in order to make it work (and run secretary):

  • Built a ruby-2.6.6 to replace the default ruby-2.1.0 in order to resolve openssl dylib issues when running ./bin/ruby_ship_gem.sh install
  • Wrote hacky_bundler.rb to install dependencies in Gemfile.lock since ./bin/ruby_ship_bundle.sh install doesn't work

Begin Original README

Join the chat at https://gitter.im/stephan-nordnes-eriksen/ruby_ship

Portable MRI Ruby environment on any platform, with any version of MRI Ruby! No need to install Ruby on a computer to use it any more!

The goal of Ruby Ship is to have a single folder containing Ruby, which is portable on all platforms. You can put this folder wherever you like and still be able to use the Ruby version on it. Put it on a USB stick if you like for all your Ruby-on-the-go needs!

This is very usefull when developing Ruby applications when your target audience do not have Ruby installed, and you do not want to bother with installing Ruby for them.

With Ruby Ship you can copy the entire folder into your project and use the wrappers supplied to make any ruby script run.

Ruby Ship comes with tools to compile your favourite Ruby version too! This way, you are not stuck with the binaries that Ruby Ship happens to come with.

Ruby Ship

Install:

  • Step 1: Download this repository

  • Step 2: Put the bin folder wherever you want it.

  • Step 3: Use the ruby_ship wrappers as you would use the normal ruby command.

  • Step 4: Party, Celebrate, and Contribute to Ruby Ship!

Usage:

In a command line environment:

path/to/bin/ruby_ship.sh [your normal ruby args]
path/to/bin/ruby_ship.bat [your normal ruby args]

Example

path/to/bin/ruby_ship.bat -e "puts 'Ruby Ship works!'"

To use gem command:

path/to/bin/ruby_ship_gem.sh [your normal gem args]

Example

path/to/bin/ruby_ship_gem.sh list

Current pre-bundled versions of Ruby:

  • Windows: 2.1.2p95 - Working
  • Darwin (aka. OSx): 2.3.1p112 - Working
  • Linux (Ubuntu): 2.1.2p95 - Working
  • More platforms coming.

Building other ruby version

Getting a new version of ruby is super-easy! Go to https://www.ruby-lang.org/en/downloads/ and download the tar.gz you desire. Then run the following command.

#For *nix
/tools/ruby_ship_build.sh path/to/source/ruby-X.Y.Z.tar.gz

(Windows build script is currently broken) Building for windows requires the use of ruby one click installer. See issue 3 for explanation and how to build other versions on windows.

::For windows
::CURRENTLY BROKEN *sad-face* /tools/ruby_ship_build.bat path/to/source/ruby-X.Y.Z.tar.gz

OSx specific: On OSx you have to relink quite a few dylibs to make it truly portable. This can be done by the supplied auto_relink_dylib.rb. This script will copy all needed dylibs into ruby_ship and then relink them, recursively adding any deeper dependencies. It is the only way to make ruby truly portable on the OSx platform. It is important that this script is run from the root of the directory, or else there will be mismatches of the directories.

ruby tools/auto_relink_dylibs.rb
#This can possibly be run with bin/ruby_ship.sh in stead of ruby, but I would advice against it as it will modify itself.

Thats it!

Now you can use your ruby_ship.sh/.bat with your newly compiled ruby version! The best part is: You can copy this environment (the entire folder) wherever you want, and it will still work! Ship it with your product, place it on a USB, or do whatever you want with it! No need to install ruby ever again!

Note: You must compile ruby using ruby_ship_build on the platform you want to use this on, but only once :)

Building requirements

To build on *nix you need to have the following:

  • Build tools
  • (Maybe others. TBA)

Darwin: brew install libffi

To build on windows you need to have the following:

Questions, suggestions, and general enquiries can be submitted as issues on the repo!

License:

MIT

TODO:

  • Binary for all platforms (compiling from source. Just run the ruby_ship_compiler on your platform)
  • Interactive build tool that prompts you with different ruby versions.
  • Online builder that downloads the ruby source and runs compile on it for you
  • Online repo of multiple binaries for download (so you can choose ruby version without building yourself, and not download all of them at once)
  • More awesome stuff