Ruby is giving me a headache

SirDice

Administrator
Staff member
Administrator
Moderator
Let me start off by stating that I have zero knowledge when it comes to Ruby. But I'm at a client installing things and I've run into a potential show stopper.

I have to use Ruby 1.8.7 and an older version of Rails. Yes, the client should upgrade but we simply cannot test dozens of websites on short notice. So I'm stuck with it.

This works as expected:
Code:
root@j-build-amd64:~# gem18 install rails --version=2.3.18
Fetching: rake-10.1.0.gem (100%)
Fetching: activerecord-2.3.18.gem (100%)
Fetching: rack-1.1.6.gem (100%)
Fetching: actionpack-2.3.18.gem (100%)
Fetching: actionmailer-2.3.18.gem (100%)
Fetching: activeresource-2.3.18.gem (100%)
Fetching: rails-2.3.18.gem (100%)
Successfully installed rake-10.1.0
Successfully installed activesupport-2.3.18
Successfully installed activerecord-2.3.18
Successfully installed rack-1.1.6
Successfully installed actionpack-2.3.18
Successfully installed actionmailer-2.3.18
Successfully installed activeresource-2.3.18
Successfully installed rails-2.3.18
8 gems installed

But I'm having issues with acts_as_audited:
Code:
root@j-build-amd64:~# gem18 install acts_as_audited --version=1.1.1
Fetching: acts_as_audited-1.1.1.gem (100%)
Fetching: i18n-0.6.4.gem (100%)
Fetching: multi_json-1.7.7.gem (100%)
Fetching: tzinfo-0.3.37.gem (100%)
Fetching: minitest-4.7.5.gem (100%)
Fetching: atomic-1.1.10.gem (100%)
Building native extensions.  This could take a while...
Fetching: thread_safe-0.1.2.gem (100%)
Fetching: activesupport-4.0.0.gem (100%)
ERROR:  Error installing acts_as_audited:
        activesupport requires Ruby version >= 1.9.3.

Why is it trying to install activesupport-4.0.0? If I look at the dependencies it requires activesupport >= 2.1:
Code:
root@j-build-amd64:~# gem18 dependency  acts_as_audited --version=1.1.1
Gem acts_as_audited-1.1.1
  activerecord (>= 2.1)
  jnunemaker-matchy (>= 0, development)
  thoughtbot-shoulda (>= 0, development)

I also don't get why it's pulling in i18n, multi_json, tzinfo, minitest, atomic and thread_safe when they're not listed as dependencies. But at least they appear to install.

Code:
root@j-build-amd64:~# gem18 list

*** LOCAL GEMS ***

actionmailer (2.3.18)
actionpack (2.3.18)
activerecord (2.3.18)
activeresource (2.3.18)
activesupport (2.3.18)
acts_as_audited (1.1.1)
atomic (1.1.10)
i18n (0.6.4)
minitest (4.7.5)
multi_json (1.7.7)
rack (1.1.6)
rails (2.3.18)
rake (10.1.0)
thread_safe (0.1.2)
tzinfo (0.3.37)

I may be overlooking something but isn't 2.3.18 >= 2.1? So why does it try to install a newer version?
 
Make Ruby go clean up her room and give her a time out. If that doesn't work, open up a can of whip-ass and let her have it.
 
Code:
Gem acts_as_audited-1.1.1
  activerecord (>= 2.1)
Will install any version that is 2.1 or newer (newer preferred)

You should install bundler sysutils/rubygem-bundler and simply run # bundle install. However, I recommend to set up and use RVM (you'll need to install archivers/gtar and shells/bash to easily install it). With RVM you can set up any Ruby you want locally and then install any gems required for specific project. Read more about RVM at it's homepage.
 
graudeejs said:
Code:
Gem acts_as_audited-1.1.1
  activerecord (>= 2.1)
Will install any version that is 2.1 or newer (newer preffered)
Yes, and I have version 2.3.18 installed, which is newer. So why does it insist on installing the latest version (4.0.0)?

You should install bundler sysutils/rubygem-bundler and simply run # bundle install
I might have a go with that.

However, I recommend to setup and use rvm (you'll need to install archivers/gtar and shells/bash to easily install it).

With rvm you can setup any ruby you want locally and then install any gems required for specific project. Read more about rvm at it's homepage.

The problem is that I have to use Ruby Enterprise Edition. I had to build a custom port for it to install properly. The custom port is basically a repo-copy of the existing lang/ruby18 with some modifications. Would RVM be able to handle that?

I have tested this with the 'standard' ruby18 that's in the ports and the issue is exactly the same. So I know it's not a problem specific to the enterprise edition.
 
SirDice said:
Yes, and I have version 2.3.18 installed, which is newer. So why does it insist on installing the latest version (4.0.0)?
2.3.18 is older than latest. If you use gem to install gems, then it'll try to get the latest version of dependencies (I guess). Perhaps some dependency requires a later version than you have. That's where bundler steps in; it should resolve all these problems.

SirDice said:
The problem is that I have to use Ruby Enterprise Edition. I had to build a custom port for it to install properly. The custom port is basically a repo-copy of the existing lang/ruby18 with some modifications. Would rvm be able to handle that?

I have tested this with the 'standard' ruby18 that's in the ports and the issue is exactly the same. So I know it's not a problem specific to the enterprise edition.

I don't know. I only used standard Ruby.
 
Ah, yes. This particular problem with acts-as-audited is fixed. Client managed to install the module into the websites itself. I didn't even know that was possible. I did manage to get all the other gems installed, with the versions required.

Oddly enough Rails seems to have several similar dependencies but accepts them as expected. If it, for example, requires somegem to be at least version 1.0 it'll happily accept 1.1 if it's already installed. Even if 2.0 is the latest version that's available. If there's nothing installed it'll install the latest version. But if 1.1 is already installed it'll use that. Most of the gems I've handled behave this way. The only exception was acts-as-audited.

If you have multiple ruby versions (as I need to have) gem-sane-binary seems to work wonders. It'll look specifically at the version of ruby that's running to keep references to other gems working correctly. It culled a lot of the weird and wonderful warnings I had previously. FreeBSD also made life a little easier as the ports system installs 1.8 and 1.9 neatly besides each other. I took full advantage of that. So I know none of the default ruby19 gems I installed using ports will interfere with the gem stuff I installed using the enterprise edition :beer

Everything is currently installing perfectly using puppet. The whole web server pretty much installs by itself. My custom enterprise edition packages are neatly fetched and installed. All the right versions of all the gems are installed automatically too. Not sure yet if the sites actually run on it. But I am optimistic though, with the few minor tests I did I'm not getting any errors or warnings and everything appears to be working. I'd say, make it so! :h
 
graudeejs said:
If your app has tests, I encourage you to run them (requires test environment).

It's a crappy app if it does not have any custom tests, should encourage your client/developers to add them if so.
 
Back
Top