Question

I am trying to install the ibm_db gem so that I can access DB2 from Ruby. When I try:

sudo gem install ibm_db

I get the following request for clarification:

Select which gem to install for your platform (i486-linux)
 1. ibm_db 0.10.0 (ruby)
 2. ibm_db 0.10.0 (mswin32)
 3. ibm_db 0.9.5 (mswin32)
 4. ibm_db 0.9.5 (ruby)
 5. Skip this gem
 6. Cancel installation

I am always going to be installing the linux version (which I assume is the "ruby" version), so is there a way to pick which one I will install straight from the gem install command?

The reason this is a problem is that I need to automate this install via a bash script, so I would like to select that I want the "ruby" version ahead of time.

Was it helpful?

Solution

You can use a 'here document'. That is:

sudo gem install ibm_db <<heredoc
  1
heredoc

What's between the \<\<\SOMETHING and SOMETHING gets inputted as entry to the previous command (somewhat like ruby's own heredocuments). The 1 there alone, of course, is the selection of the "ibm_db 0.10.0 (ruby)" platform.

Hope it's enough.

OTHER TIPS

Try this:

sudo gem install --platform ruby ibm_db

Note that you can get help on the install command using:

gem help install

UPDATE: Looks like this option only works for RubyGems 0.9.5 or above.

Try this, I think it only works on Bash though

sudo gem install ibm_db < <(echo 1)

@John Topley

I already tried gem help install, and --platform is not an option, both in help and in practice:

$ sudo gem install ibm_db --platform ruby
ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --platform

UPDATE: The Ubuntu repos have 0.9.4 version of rubygems, which doesn't have the --platform option. It appears it may be a new feature in 0.9.5, but there is still no online documentation for it, and regardless, it won't work on Ubuntu which is the platform I need it to work on.

Versions of Rubygems from 1.0 and up automatically detect the platform you are running and thus do not ask that question. Are you able to update your gems to the latest?

$ sudo gem update --system

Be warned if you are on Windows once you have updated; you might run into this issue.

Another option is to download the .gem file and install it manually as such:

sudo gem install path/to/ibm_db-0.10.0.gem

This particular gem was at rubyforge.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top