How to package a Ruby application? - ruby

I've got an application in Ruby that uses the Qt 4 bindings. I want to be able to package and release it.
I've looked at other applications such as rake and puppet to see how they're packaged. Both rake and puppet are packaged as gems. I started going down this route when I realized that both rake and puppet are more system level tools rather than user-level applications.
I also looked at orca, but it's windows only.
Are there other options available for packaging a Ruby GUI app other than gem or orca? I'd like something that's cross platform.

Take a look at the platform specification for gems. You can package up a gem for each platform that your code supports.
Some gems consist of pre-compiled code (“binary gems”). It’s especially important that they set the platform attribute appropriately.

Related

Rubymine use local gem configuration

I'm running Ruby mine 7.1.2 on Windows and I'm having difficulty with it because it seems to want to use its own gems and version of fun where. My application works fine from the command line if I do bundle install or bundle exec rails script but when I try to run from the IDE it complains about missing gems.
I could just try to reinstall all the gems via ruby mine but some of the gems require special customization in Windows and doing that from the command line is much easier. Is there anyway I can have ruby mine just use the gems which are already installed?
Rubymine will usually bundle your ruby SDK (i.e. ruby itself) and all it's associated gems so that you don't end up with weird configuration dependencies.
If you want to circumvent that then follow an official guide. In addition to that guide, be aware that there are also per-run SDK settings. These kick in when running or debugging a RubyMine project and need to be configured in the run -> configuration settings dialog.
My (unsolicited) additional advice is that I'd recommend figuring out what aspects of your global ruby installation are causing issues with RubyMine's bundle installer. The reason RubyMine sandboxes several SDKs is to reduce major headaches when you go to deploy your applications. Without it, you might encounter dependency hell when you deploy your application. From my personal (and extremely annoying) experience, rushing these initial set-up steps tend to come back with vengeance when you want to run ruby apps elsewhere.

Does Ruby have anything like Python PEX [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
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?
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.
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

'deploying' a ruby script with gems

i've written several Ruby scripts that work together to from a console application.
These scripts are written on an Ubuntu platform, but I want to be able to run them from a Windows platform as well.
The problem I'm currently facing is porting over all the gems. I've downloaded sources of most gems and made some bug fixes on them, but is it possible to package them for example with my scripts so they're available?
I'm thinking a bit DLL like here as Windows does.
I can probably add a readme file, stating which gems are required and where/how to obtain them, but it would be easier if I could package them.
Maybe you could look at http://www.erikveen.dds.nl/rubyscript2exe/index.html which does some packaging for ruby application (including the ruby interpreter, too)
You could also build a gem with your script in it along with all needed gems directly inside the gem. Provided their licences allow you to do that, it could be a reasonable solution ( Gem supports platform flavoured gems http://docs.rubygems.org/read/chapter/20#platform )

How to distribute a Ruby application with the required gems

I've developed a Ruby application (a small game), and I would like to 'distribute' it to other people.
However, I am not sure what to do about the required gems. If I just send my application to someone who have ruby installed, but not the required gems, I assume it will blow up. Can I package the gems locally? If so, would it conflict if the other person has a different version of the gem?
So, what is the smart/proper/good way of doing this?
The best way would probably be to just package your game as a gem as well, that way rubygems will take care of installing the dependencies. Here's the documentation explaining how to create your own gems.
If you'd rather not package your game as a gem, you could investigate the Bundler, which will be integrated into Rails 3.
In your environment.rb you can express your gem dependencies, eg.
config.gem "activemerchant", :lib => "active_merchant", :version => "1.4.1"
This isn't as automatic as gem dependencies, but it certainly usable. User must sudo rake gems:install to get your app to start.
If you're looking for a way to create OSX .dmg's and Windows Installers, there's a gem called releasy that will do all of that for you, and it is specifically tailored for releasing GUI apps written in Ruby. It bundles up Ruby and all your gem dependencies in to a single executable so that your end user doesn't have to install anything extra.
You will need access to a Windows/OSX environment to make the installers.

Packaging precompiled binaries inside of a gem

I've got a ruby web app that uses lilypond to generate sheet music based on user input. I'd like to move the hosting to heroku (I've recently used heroku on a few projects and really liked it, plus my traffic is low enough that it'd be free host it on heroku, for a while at least). However, heroku's dyno architecture doesn't allow you to ssh in and install whatever packages you want...instead, you give it a gems manifest, and it will install the gems for you.
So, if I'm going to deploy to heroku, I'm going to need to package lilypond as a gem. I've released a few pure-ruby gems, but haven't dealt with native extensions or precompiled binaries, or anything like that.
Is it possible to take some precompiled binaries and package it inside a gem? Ideally, this would include binaries for OS X (which I develop on) and debian linux (which is what's running on heroku), and would install the proper binary when the gem was installed.
it is possible, since precompiled binary gems for windows are the norm. Take a look at rake compiler, perhaps.
also https://github.com/rdp/ruby_tutorials_core/wiki/gem (https://en.wikibooks.org/wiki/Ruby_Programming/RubyGems) might help
-r
I think you've got a few options here:
You could get the Lilypond source and package it into a gem with a native C extension. There are some useful guides on how to do that at http://guides.rubygems.org/c-extensions/ and http://patshaughnessy.net/2011/10/31/dont-be-terrified-of-building-native-extensions
There's also a gem called gitara but I haven't been able to find any information about using it on Heroku. It might be worth emailing the author and asking if he knows anything about that.
You could create a Heroku buildpack that installs Lilypond as part of your deployment. I wasn't able to find any for Lilypond, but there are plenty of examples that do similar things - for example, this one installs Imagemagick (which is included by default on Heroku, so probably not necessary anymore - but hopefully the code is helpful). More documentation at https://devcenter.heroku.com/articles/buildpack-api and https://devcenter.heroku.com/articles/buildpack-binaries
Based on my reading, I think the buildpack option is the best way to go.
Hopefully this helps!
Instead of precompiling, you should be able to just list the gem in your .gems file, see the Heroku documentation. Of course, this requires your gem builds the native code correctly - this is still a task, but hopefully an easier one.

Resources