Skip to content

Tip: Apply many patches to MRI source one liner

zhando edited this page Jul 6, 2013 · 2 revisions

First: much praise to Postmodern for ruby-install. Yet another tiny-LOC, ruby ecosystem, wonder tool!

In the past, using ruby-build I would have to work up a "recipe" for a specialized ruby build..

With ruby-install, to apply a patch, you must use the -p option followed by the path to the patch..

What if you need to apply a bunch of patches? No problem. Repeat -p followed by the path to each patch as many times as needed as in

ruby-install -p ~/path_to/patch1 -p ~/path_to/patch2....

Here's the most DRY way to do that I've found using bash parameter substitution:

First collect all the patches you want to apply under one directory, like rvm does and..

pfiles=(~/.rvm/patches/ruby/1.9.3/p385/railsexpress/*); IFS=,; ruby-install -s /tmp -i ~/.rubies/ruby-1.9.3-p385-patched/ "${pfiles[@]/#/-p }" ruby 1.9.3-p385

This particular example blows up for me at the configure stage. (Some issue with the latest bash, sed on latest arch linux?), but the patches all apply cleanly.. Beware of patch file names with embedded whitespace. I'd remove it/substitute it out first.

Clone this wiki locally