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
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
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”.
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