Cannot run any gem as non-root user - freebsd 6.2

On my freeBSD 6.2 laptop I recently installed ruby 1.8.6 and ruby gems
from ports. Then (as root) used ‘gem’ to update itself and to install
rails. All of this proceeded without error - although it took so long
I’d hate to have to repeat it.

# cd /usr/ports/lang/ruby18 # make install # cd /usr/ports/devel/ruby-gems # make install # gem update --system # gem install cheat # gem install rails

(full list of installed gems near bottom)

Now as root I can run any gem I please simply by issuing

cheat # to run the ‘cheat’ gem

But as ordinary user I cannot run any gem at all. Here is what I see
when I try to run the above ‘cheat’ gem (exact same thing happens if I
run ‘rake’):

$ cheat /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:350:in `insert': no implicit conversion from nil to integer (TypeError) from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:350:in `activate' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:65:in `active_gem_with_options' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:50:in `gem' from /usr/local/bin/cheat:18

The same basic pattern holds true for any gem. It happens when I run
‘rails’. It happens when in a rails project I try to run something like
‘rake db:migrate’ even though every single file in my project is owned
by that user.

Any ideas? I scoured the web and ended up empty-handed. I’m too new to
ruby for you to trust my speculations, but I wonder if it is a
permissions or some other installation issue relating to the ‘gem’ app
itself. Just would not know where to look.

Here are a couple of gem admin commands issued by ordinary user:

/tmp $ gem check # no output so I assume okay

/tmp $ gem environment
ERROR: While executing gem … (TypeError)
no implicit conversion from nil to integer

/tmp $ gem list -l

*** LOCAL GEMS ***

actionmailer (2.0.2)
actionpack (2.0.2)
activerecord (2.0.2)
activeresource (2.0.2)
activesupport (2.0.2)
cheat (1.2.1)
rails (2.0.2)
rake (0.8.1)
ruby-debug (0.10.0)
ruby-debug-base (0.10.0)
rubygems-update (1.0.1)
sources (0.0.2)
sqlite3-ruby (1.2.1)

/tmp $ gem which cheat
(checking gem cheat-1.2.1 for cheat)
/usr/local/lib/ruby/gems/1.8/gems/cheat-1.2.1/lib/cheat.rb

On Saturday 02 February 2008 00:37:39 Gordon P. wrote:

gem update --system

gem install cheat

gem install rails

May i ask you what’s the purpose of such self shooting command
execution?
The ruby-gems port is already the latest one.
The rails port could be installed very easily. You can skip all those
commands and execute just:
cd /usr/ports/www/rubygem-rails ; make install clean
The end.
But i recommend to read this handbook chapter first:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html

Good hunch - it was incorrect values in the setting of “prefix” value in
rbconfig.rb - details below. Now things work!! Thanks.

Rick Denatale wrote:

On Feb 1, 2008 5:37 PM, Gordon P. [email protected] wrote:

gem update --system

But as ordinary user I cannot run any gem at all. Here is what I see
when I try to run the above ‘cheat’ gem (exact same thing happens if I
run ‘rake’):

$ cheat /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:350:in `insert': no implicit conversion from nil to integer (TypeError)

Looking at the code in rubygems.rb it looks like sitelibdir is nil.

Just above that it got set

sitelibdir = ConfigMap[:sitelibdir]

Smells like that’s on the right track. sitelibdir (and others from
ConfigMap) appear to have nonsensical values; viz, the string

“/i/client/ubh/proj/work”

probably ought to be “/usr/local”.

Ah, now I see. For unknown reason, in distant past, I was setting
PREFIX to the “/i/client/ubh/proj/work” value in my .profile file. This
got used by rbconfig.rb instead of the default value of “/usr/local”.

Once I unset this, the errant directory paths below became “/usr/local”.

And now ‘rake’ and ‘cheat’ work perfectly fine!

Display of ConfigMap from rubygems.rb line 350:

:RUBY_SO_NAME : ruby18
:sitedir : /i/client/ubh/proj/work/lib/ruby/site_ruby
:arch : i386-freebsd6
:sitelibdir : /i/client/ubh/proj/work/lib/ruby/site_ruby/1.8
:BASERUBY :
:bindir : /i/client/ubh/proj/work/bin
:libdir : /i/client/ubh/proj/work/lib
:EXEEXT :
:ruby_install_name : ruby18
:RUBY_INSTALL_NAME : ruby18
:ruby_version : 1.8

My guess is that, since you do seem to be able to run this as root
that the permisions are screwed up on rbconfig.rb

Seems not to be the case:

-rw-r–r-- 1 root wheel 7063 Jan 25 09:22
/usr/local/lib/ruby/1.8/i386-freebsd6/rbconfig.rb

On Feb 1, 2008 5:37 PM, Gordon P. [email protected] wrote:

gem update --system

But as ordinary user I cannot run any gem at all. Here is what I see
when I try to run the above ‘cheat’ gem (exact same thing happens if I
run ‘rake’):

$ cheat /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:350:in `insert': no implicit conversion from nil to integer (TypeError)

Looking at the code in rubygems.rb it looks like sitelibdir is nil.

Just above that it got set

sitelibdir = ConfigMap[:sitelibdir]

Now ConfigMap gets set up up around line 74 et seq

ConfigMap = {} unless defined?(ConfigMap)
require ‘rbconfig’
RbConfig = Config unless defined? ::RbConfig
ConfigMap.merge!(
:BASERUBY => RbConfig::CONFIG[“BASERUBY”],
:EXEEXT => RbConfig::CONFIG[“EXEEXT”],
:RUBY_INSTALL_NAME => RbConfig::CONFIG[“RUBY_INSTALL_NAME”],
:RUBY_SO_NAME => RbConfig::CONFIG[“RUBY_SO_NAME”],
:arch => RbConfig::CONFIG[“arch”],
:bindir => RbConfig::CONFIG[“bindir”],
:libdir => RbConfig::CONFIG[“libdir”],
:ruby_install_name => RbConfig::CONFIG[“ruby_install_name”],
:ruby_version => RbConfig::CONFIG[“ruby_version”],
:sitedir => RbConfig::CONFIG[“sitedir”],
:sitelibdir => RbConfig::CONFIG[“sitelibdir”]
)

My guess is that, since you do seem to be able to run this as root
that the permisions are screwed up on rbconfig.rb

Now you need to find out where on the load path it’s finding it.

You might want to start out by using

$locate rbconfig.rb

although if it’s not readable by the user used to build the locate
database, you might have to use find as root.


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs