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
Related
Disclaimer: I know ruby since quite long as language and i am a experienced programmer from the Java corner, but haven't really dealt deeply with the whole eco - culture of Ruby. I always liked Ruby, but only now I am starting to use Rubygems with Bundler and i am impressed. So i am assuming there is an easy answer to my question , which proves my ignorance ;-)
One thing i really like about gems and bundler is that you can package and distribute libraries and applications or even both... neat.
Let's keep it simple. Let's say i have a script, which does something in a database and which want to package and distribute with bundler with enterprise specific gems server. For the configuration of this script i need a db url, a userid and a password. The password should likely be encrypted. This configuration should be externalized in a host resp. installation specific config file.
In the Java Spring Boot world, where i am coming from , they have this mechanism with application.properties which can be a mix of build time, installation and runtime parameters and can be accessed through a common api.
I saw in the bundler documentation that one pass the local configuration file upon installation time : https://bundler.io/v1.5/bundle_config.html. Neat. But i am not quite sure how this could/ should work in detail. Here real world examples would help...
Is there a canonical form to have and deal with installation specific configurations for ruby apps distributed with gems and bundler?
Any pointers , input , feedback is very welcome.
There is no universal setting storage system in Ruby applications.
dotenv is popular for plain Ruby applications. Rails has its own system.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am new to Ruby and trying to wrap my head around following concepts: bundler vs RVM vs gems vs RubyGems vs gemsets vs system rub and I'm confused.
Can someone please describe a 'best practice' of how I should manage all this on a fresh install of the latest version of Ubuntu? What should I install, and how should I use it all?
I'm guessing that doing a sudo apt-get install ruby is not be recommended, but I am not sure. I tried it on my system in addition to 'all the other Ruby stuff'. It's just adding to my confusion. I am not talking about Rails but just regular Ruby gems (e.g. Vagrant, Chef, scripts).
As per the previous answer, this is quite a lot to cover, so consider this a short introduction.
gems are the way Ruby libraries are packaged. They are to Ruby what jars are to Java. Inside a gem file, you find Ruby code (.rb files), but also tests, and a special file giving information on the gem itself, such as its name, dependencies and version (gemspec). Any Ruby project can define the gems it needs via a Gemfile that just need to declare dependencies. Rubygems is the name of the package manager - the tool used to install the packages (while the gems are the packages themselves). Rubygems is now part of Ruby.
Bundler is what makes managing gems bearable. Based on your Gemfile, a simple call to bundler using bundle install will download and install all the required gems. Using standard gem command, you would have to install each of them manually, using gem install <gem_name>. Bundler is not part of Ruby (it is itself packaged as a gem), but it a "de facto standard" for most applications (you will not find many people not using it, and no good reasons not to use it, actually).
RVM is a tool allowing you to install multiple versions of Ruby on a machine, switching between them when needed. This can be used to install both a Ruby 1.8 and 1.9, or even a "MRI" (Matz's Ruby, the default implementation) and alternatives (such as JRuby or Rubinius). Note that RVM is not alone in this field, see for instance rbenv.
A gemset in RVM is a set of gems specific to a given context, typically a project. This is useful if you are for example developing different applications, each with its own sets of gems, and want to keep them separate.
system Ruby is, when using RVM, the Ruby version installed on the machine (ie, not via RVM).
If you are just starting, gems and bundler are of interest to you. You can let RVM and gemsets aside for now.
You're asking for more information in one question than is in-scope for Stack Overflow. To cover it all would take a book.
On Ubuntu it's easy to install and remove gems to the "system" version of Ruby, so get used to installing and removing regular gems via sudo. (On Mac OS I'd give different advice because Apple bundles Ruby for their own use and it's not a great idea to mess with it.) Then, when you have an idea how the whole gem idea works, and you know you want multiple Ruby versions on your system, try "rbenv" or "RVM" and install a version or two in your sandbox.
Linux makes it easy to add/remove Ruby via a distribution, but we're limited to the versions the distro maintainers have packaged, so I usually install from source. But, that's a pain when managing several versions of Ruby for development, test and production systems, which is why rbenv and RVM were invented -- they handle the dirty detail allowing us to concentrate on programming.
I've used both rbenv and RVM, and have been using rbenv for the last six months or so, with good results. It's less complicated than RVM which I like. In either case they make it easy to have different versions installed, with separate sets of Gems. You can have different Ruby versions open in different terminal windows if you want, making it easy to test for compatibility.
Rule one when debugging is to make changes one at a time, which is true for learning to program or learning a new language. Don't be distracted, just keep it simple.
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.
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 )
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm not sure of all of them, but what are the commands to do things like update Ruby, download a new gem, or update an existing gem? What other important things are there?
Since it might matter, I'm running Windows.
By Ruby commands you probably mean the command line programs for Ruby. These are also called Ruby Helper programs. Here are a few:
ruby - The interpreter itself. Run Ruby scripts or statements.
gem - Ruby Package Manager. Great for automatically downloading or updating small Ruby modules like XML libraries, web servers, or even whole Ruby programs.
irb - Interactive Ruby Prompt. This is an entire Ruby shell that will let you execute any Ruby code you want. You can load libraries, test code directly, anything you can do with Ruby you can do in this shell. Believe me, there is quite a lot that you can do with it to improve your Ruby development workflow [1].
ri - Quick shell access to Ruby documentation. You can find the RDoc information on nearly any Ruby Class or method. The same kind of documentation that you would find on the online ruby-docs.
erb - Evaluates embedded Ruby in Ruby Templated documents. Embedded Ruby is just like embedding php into a document, and this is an interpreter for that kind of document. This is really more for the rails crowd. An alternative would be haml.
rdoc - Generate the standard Ruby documentation for one of your Ruby classes. Its like Javadocs. It parses the Ruby source files and generates the standard documentation from special comments.
testrb and rake. I'm not familiar enough with these. I'd love it if someone could fill these in!
Hopefully this was what you were looking for!
Useful command: Rake
In addition to the commands listed by Joseph Pecoraro, the 'rake' command is also pretty standard when working with Ruby. Rake makes it easy to automate (simple) tasks; like building a RubyGem or running your unit tests.
With rake, the only important command to remember is 'rake -T', which shows a list of rake tasks available in the current directory.
Updating a Ruby gem
To get back to your specific question:
To update a specific gem, you can do two things: simply update the gem:
gem update <gemname>
This will update the gem to the latest version.
Install a Ruby gem
If you want to update to a specific version, you must install it:
gem install <gemname> -v <gemversion>
You can leave out the -v options. Rubygems then installs the latest version.
How to help yourself
Two useful gem commands to remember are:
gem help
This shows how to get help with rubygems.
gem help commands
This shows all commands available to rubygems.
From here you can get more specific help on a command by using gem help:
gem help update
sudo gem install gemname
sudo gem update gemname
Okay. I see what you're going for but again try to go abstract because I know someone will give you a direct answer (which people should up-vote over this).
Everyone should get comfortable with man pages. But even if you are, you'll find that these commands lack decent man pages. However, those that do will point you to cmd --help and you will find some decent documentation there. I linked each of the commands above to a hopefully useful resource that will lead you to an answer if you're worried about command line switches. I see someone already posted the commands so I won't repeat those for gem. But I'd go further and say:
sudo gem update [gemname]
The default behavior will update all installed gems.
Also, as a bonus there is a neat gem called cheat. The idea is that instead of typing man cmd you will type cheat cmd and you can get a community editable man page for that command. Or better yet, it doesn't have to be a command, it can be an entire topic. Coincidentally to install cheat you would do:
sudo gem install cheat
And then:
cheat gem
That will list out a "man page" written by users like you about the gem command. The commands that you asked for are on that page. Anyone can add new pages, update existing pages, and contribute to the community. If you're interested here is a quick addition you can make to have autocompletion for the cheat command from the command line.
I know I have long winded answers ;)
Is there a similar command to update Ruby itself?
Alas, no there is not. I'm afraid that if you want to update Ruby itself you will have to either download an installer from the Ruby website, or compile it from source.
I should mention though that compiling from source is very easy and offers developers quite a bit of neat flexibility. You can add a suffix to the generated commands so that you can have standalone Ruby 1.8 and Ruby 1.9 builds both at the same time. That can be very helpful for testing.
Finally, its always a danger to update an operating systems built in commands unless it occurs through an official update. Installed applications may be expecting to a Ruby 1.8 in the standard location and crash if they meet an updated version. Any updates you make should just not overwrite one that came with an OS. (If any app crashes then its the fault of the app's developers for not specifying the absolute path to the OS version).
#John Topley: Thanks. Is there a
similar command to update Ruby itself?
Not really. You don't say which operating system you're using. I use Mac OS X and tend to build Ruby from source.