2

Does Ruby have a capability to archive all dependent gems and application code in a file like Python's PEX?

To implement Python PEX, Ruby needs a feature like python's zipimport, which the current version of Ruby doesn't seem to have. But PEX looks very interesting if we have for Rails and other usages.

So my question is "Does Ruby have PEX like feature?" If not how can i implement it?

Community
  • 1
  • 1
Yasushi Shoji
  • 4,028
  • 1
  • 26
  • 47
  • I don't quite get the connection between PEX and Ruby Ship. AFAICS, PEX is for distributing Python *apps*, under the assumption that there already is a Python execution engine installed on the system, whereas Ruby Ship is for packaging Ruby *execution engines* such that you don't need to install one. – Jörg W Mittag Dec 31 '14 at 15:26
  • thanks. I should have read more about it before mentioning it. – Yasushi Shoji Dec 31 '14 at 15:52
  • @Jorg You're correct. In practice, PEX and Ship are sometimes for similar purposes because many systems have adequate python runtimes (or it's easy to install them) and many systems have older Ruby versions (and it's harder to install new ones). Ship lets me package my own code plus the Ruby runtime, so I can send it to someone else to run it. – joelparkerhenderson Dec 31 '14 at 18:17
  • Do ruby gems not suffice? Is it because you need to package a runtime along with it? – Iron Savior Dec 31 '14 at 22:27
  • ruby gem compiles native gems on the fly, which requires working compilers. pex otoh seems to be architecture aware, meaning you can create pex for arm on x86, which is a win for embedded system or android development. – Yasushi Shoji Jan 03 '15 at 18:38
  • i'm not sure why it's off-topic. i'm not asking for recommendations, rather i'm asking a specific feature is available for ruby or not. anyway, i reworded a bit. tell me why if it still looks off-topic. – Yasushi Shoji Jan 03 '15 at 18:59

2 Answers2

1

Ruby has some tools similar to PEX.

JRuby Warbler packs files into a jar or war file, both of which are essentially zip files.

  • Warbler can package anything from a simple Ruby command-line script to an entire Rails app.

  • The jar or war contains your own files, plus optionally any gems you want, but does not contain a JRuby runtime, Ruby runtime, or JVM.

  • A typical use case is to package your app into a war file, then send the file to a remote server that already has a Java server installed, the the Java server runs your app. For example, I can use Warbler to package my Rails app to deploy to Google AppEngine.

  • Targets any typical JVM.

Traveling Ruby lets you create self-contained Ruby app packages.

  • An app packaged with Traveling Ruby is self-contained and doesn't require the user to install any further dependencies or runtimes.

  • The package contains your app, your app's gems, and a portable Ruby runtime. The package tends to be much larger than just your app's source code.

  • A typical use case is to send someone an app so they can run it on their own system. For example, I want to send someone my Rails app and have the him run it on his own server, without installing anything else.

  • Targets Linux or OSX.

Ruby Ship provides a portable Ruby runtime, and can also package your code.

  • Ruby Ship is an alternative to installing Ruby on a system.

  • You can send Ruby Ship as is, or you can include in your script folder, or app folder, so you can distribute your own Ruby script or app with a fully runnable Ruby environment.

  • A typical use case is to package Ruby for someone else. For example, I want to send a Ruby 2.2 runtime to someone who only has Ruby 2.0. I can use Ruby Ship, and I can optionally include my own scripts and apps in the package. For example, I have some data analytics scripts that I wrote using Ruby 2.2 features, and I want to send them to someone who has a system which runs an older Ruby 2.0; I can use Ruby Ship to build Ruby 2.2 on a similar system then send my scripts plus the ship.

  • Targets Linux, OSX, or Windows.

For zip file management:

  • You can use any JRuby Java zip tool, or a Ruby gem such as rubyzip

  • To require Ruby code from a zipfile, you can use ziprequire

joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119
  • thanks, but i was thinking about RMI, which i didn't make clear. Also, @Jörg W Mittag told me that ruby ship isn't for apps. – Yasushi Shoji Dec 31 '14 at 15:50
  • You're welcome. Can you write more in your question about what you're hoping to accomplish, i.e. your goals? (This will help people answer you better) – joelparkerhenderson Dec 31 '14 at 17:44
1

Please check Traveling Ruby, from the project description:

Traveling Ruby is a project which supplies self-contained, "portable" Ruby binaries: Ruby binaries that can run on any Linux distribution and any OS X machine. This allows Ruby app developers to bundle these binaries with their Ruby app, so that they can distribute a single package to end users, without needing end users to first install Ruby or gems.

The only downside is Windows is not supported, which is fine for most users.

Paulo Fidalgo
  • 21,709
  • 7
  • 99
  • 115