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

  • Thread starter Gordon Pedersen
  • Start date
G

Gordon Pedersen

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.

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

(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'):

<code>
$ 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
</code>


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:

<blockquote>

/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
</blockquote>
 
N

Nikolay Pavlov

On my freeBSD 6.2 laptop I recently installed ruby 1.8.6 and ruby gems
from ports. =C2=A0Then (as root) used 'gem' to update itself and to insta= ll
rails. =C2=A0All of this proceeded without error - although it took so lo= ng
I'd hate to have to repeat it.

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

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=20
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=
=20

=2D-=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20
=2D Best regards, Nikolay Pavlov. <<<----------------------------------- =
=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20
 
R

Rick DeNatale

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.

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

(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'):

<code>
$ 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.
 
G

Gordon Pedersen

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

Rick said:
# 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'):

<code>
$ 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top