"undefined method path" error installing RubyGems - ruby

I have installed Ruby v1.9.2, and (according to the instructions on http://rubyonrails.org/download) I am trying to install Gems. I've downloaded the 1.4.2 zip from http://rubyforge.org/frs/?group_id=126, but when I run setup.rb, I get the following error/trace:
C:\temp\rubygemsInstall\rubygems-1.4.2\rubygems-1.4.2>setup.rb
C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/source_index.
rb:62:in `installed_spec_directories': undefined method `path' for Gem:Module (N
oMethodError)
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
source_index.rb:52:in `from_installed_gems'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:914:in `source_index'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
gem_path_searcher.rb:83:in `init_gemspecs'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
gem_path_searcher.rb:13:in `initialize'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:873:in `new'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:873:in `searcher'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:495:in `find_files'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:1034:in `load_plugins'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
gem_runner.rb:84:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/setup.rb:25:i
n `<main>'
I am running Windows Server 2008 R2 - please post a comment if there is any other relevant info.
How do I get around this error?

The windows RubyInstaller includes rubygems already, so you don't have to install it separately. I'm assuming you're using RubyInstaller because that's what the rubyonrails.org page links you to if you click on the Windows link, but there is more information on the RubyInstaller page in the Help section.
What happens if you go to a cmd prompt and do "gem list"?

Older versions of rubygems aren't completely compatible with Ruby 1.9.2. I realize the OP discovered that rubygems was already installed, but for those who still need to install it, all you need to do is downgrade to Ruby 1.8.7 and then it should work properly. This is where a tool like RVM really comes in handy.

Related

"uninitialized constant OpenSSL::PKey::EC" from Ruby on CentOS 6.6

I have a Rails server application that uses the openid_connect gem. When I attempt to run it on CentOS 6.6, I get:
uninitialized constant OpenSSL::PKey::EC
Here is the full stacktrace:
$ rails server
/home/foo/.rvm/gems/ruby-2.1.3/gems/json-jwt-1.5.1/lib/json/jwk/jwkizable.rb:69:in `<top (required)>': uninitialized constant OpenSSL::PKey::EC (NameError)
from /home/foo/.rvm/gems/ruby-2.1.3/gems/json-jwt-1.5.1/lib/json/jwt.rb:102:in `<top (required)>'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/openid_connect-0.9.2/lib/openid_connect/response_object/id_token.rb:1:in `<top (required)>'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/openid_connect-0.9.2/lib/openid_connect/response_object.rb:7:in `block in <top (required)>'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/openid_connect-0.9.2/lib/openid_connect/response_object.rb:6:in `each'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/openid_connect-0.9.2/lib/openid_connect/response_object.rb:6:in `<top (required)>'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/openid_connect-0.9.2/lib/openid_connect/connect_object.rb:52:in `<top (required)>'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/openid_connect-0.9.2/lib/openid_connect.rb:85:in `<top (required)>'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
from /home/foo/tmp/openid_connect_sample/config/application.rb:7:in `<top (required)>'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands.rb:53:in `require'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands.rb:53:in `block in <top (required)>'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands.rb:50:in `tap'
from /home/foo/.rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
What does this mean and how I can I get past it?
This problem stems from Red Hat's refusal to include (for fear-of-patent-litigation reasons) certain Elliptic Curve (EC) algorithms in CentOS' default build of OpenSSL.
Note: According to #Cal's answer, CentOS 6.7 does not have this issue.
The openid_connect gem is dependent on the json-jwt gem, which uses one of those not-included algorithms.
Therefore, you need to rebuild a new version of OpenSSL that includes the needed algorithms.
These are the steps I followed (adapted from here) to build a new OpenSSL on my machine:
cd /usr/src
wget https://www.openssl.org/source/openssl-1.0.1l.tar.gz
yum install autoconf automake (you probably already have these installed)
tar zxvf openssl-1.0.1l.tar.gz
cd openssl-1.0.1l
export CFLAGS="-fPIC"
./config --prefix=/opt/openssl shared enable-ec enable-ecdh enable-ecdsa
make all
make install
Now, your Ruby is probably still linked against the old OpenSSL library, so you'll need to rebuild it to link to the new one.
Are you using rvm? Then great! Any new Rubies you install will build against the new OpenSSL. rvm remove your Ruby and re-install it (or simply install a different ruby version).
Not using rvm? Then I guess you'll need to rebuild Ruby the traditional way. But you probably already know how to do that, right? If not, you'll need to look in a different tutorial, because we can't cover that here.
Now reinstall bunder and do a bundle install, and your rails server should now run successfully.
(If anyone has corrections or clarifications to offer, please leave a comment and I'll make edits as necessary.)
I ran into this same problem with CentOS 6.6. But I didn't want to recompile a custom openssl and ruby to fix this. I didn't take very good notes because I tried so many things, but it appears that an update to all of the latest & greatest packages to CentOS 6.7 solves the problem.
Here are a few relevant package versions I have:
openssl098e-0.9.8e-18.el6_5.2.x86_64
openssl-1.0.1e-42.el6.x86_64
openssl-1.0.1e-42.el6.i686
openssl-devel-1.0.1e-42.el6.x86_64
glibc-2.12-1.166.el6_7.3.x86_64
kernel-2.6.32-573.7.1.el6.x86_64
After updating these packages, rebooting, and reinstalling my bundle the json-jwt gem worked perfectly.
This was our production machines, and I believe the ruby standard libs were compiled from source, then created as a custom RPM.
Our build server uses RVM, and this ended up being more of a pain. The RVM installer kept pulling binaries for centos, and the same failure came back again.
Found remote file https://rvm.io/binaries/centos/6/x86_64/ruby-1.9.3-p484.tar.bz2
I forced a source recompile like this:
rvm reinstall --disable-binary ruby-1.9.3-p484
And I noticed a very wonderful looking message:
#applying patch .rvm/patches/ruby/ssl_no_ec2m.patch.
That patch file has some C macro conditions that appear to exclude some EC related code.
And that worked! I also noticed that ruby's openssl.so has a lot of EC related symbols in it. The previously packaged centos ruby did not have these:
$ cd ~/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-linux
$ strings openssl.so |grep _EC
PEM_write_bio_ECPKParameters
i2d_ECPKParameters
PEM_read_bio_ECPKParameters
d2i_ECPKParameters
PEM_write_bio_ECPrivateKey
i2d_ECPrivateKey_bio
i2d_EC_PUBKEY_bio
PEM_write_bio_EC_PUBKEY
PEM_read_bio_ECPrivateKey
PEM_read_bio_EC_PUBKEY
d2i_ECPrivateKey_bio
d2i_EC_PUBKEY_bio
OPENSSL_1.0.1_EC
EVP_PKEY_assign_EC_KEY
OP_SINGLE_ECDH_USE
If I had to guess, the recompile against my new openssl 1.0.1 package must have triggered some C macros that opened up some kind of alternative algorithm that isn't legally protected.
If you check your openssl.so for symbols and it doesn't have all of these _EC related stuff, that's probably an issue.

nanoc installation setup in Linux

I'm a newbie to Ruby. Trying to setup nanoc in my machine. I'm running Ubuntu 14.04.
After the nanoc installation, when I type
$nanoc --version
I get the following errors:
/home/ananth/.rvm/gems/ruby-head#global/gems/bundler-1.6.2/lib/bundler/shared_helpers.rb:24:in `default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound)
from /home/ananth/.rvm/gems/ruby-head#global/gems/bundler-1.6.2/lib/bundler.rb:248:in `default_gemfile'
from /home/ananth/.rvm/gems/ruby-head#global/gems/bundler-1.6.2/lib/bundler.rb:192:in `root'
from /home/ananth/.rvm/gems/ruby-head#global/gems/bundler-1.6.2/lib/bundler.rb:99:in `bundle_path'
from /home/ananth/.rvm/gems/ruby-head#global/gems/bundler-1.6.2/lib/bundler.rb:400:in `configure_gem_home_and_path'
from /home/ananth/.rvm/gems/ruby-head#global/gems/bundler-1.6.2/lib/bundler.rb:90:in `configure'
from /home/ananth/.rvm/gems/ruby-head#global/gems/bundler-1.6.2/lib/bundler.rb:151:in `definition'
from /home/ananth/.rvm/gems/ruby-head#global/gems/bundler-1.6.2/lib/bundler.rb:116:in `setup'
from /home/ananth/.rvm/gems/ruby-head#global/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
from /home/ananth/.rvm/gems/ruby-head/gems/nanoc-3.7.0/bin/nanoc:7:in `<top (required)>'
from /home/ananth/.rvm/gems/ruby-head/bin/nanoc:23:in `load'
from /home/ananth/.rvm/gems/ruby-head/bin/nanoc:23:in `<main>'
from /home/ananth/.rvm/gems/ruby-head/bin/ruby_executable_hooks:15:in `eval'
from /home/ananth/.rvm/gems/ruby-head/bin/ruby_executable_hooks:15:in `<main>'
Am I missing something from my rvm? Anything to do with $PATH, .bashrc or .bash_profile?
Thanks for the help in advance!
This is a bug in 3.7.0 that will be fixed in 3.7.1.
3.7.0 unintentionally requires a Gemfile to be present when Bundler is installed.
To avoid this bug, either temporarily switch back to 3.6.11, or use a Gemfile (I recommend the latter).

Ruby gamebox can't find the file gosu.for_1_9.so even though it's right there

Preface: I'm on a Windows 8 box, running Ruby 2.0.0.
I recently installed the gamebox gem for Ruby. During the installation of all its dependencies, a few files, among them the file $RUBYHOME/lib/ruby/gems/2.0.0/gems/gosu-0.7.50-x86-mingw32/lib/gosu.for_1_9.so, did not build properly because of some ASCII/Unicode issues in rdoc, and were thus "skipped". I hadn't payed much attention to it initially, but when I tried to run gamebox test_game to setup a new gamebox game, it spat the following message at me:
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:118:in `require': 126: The specified module could not be found. - C:/Ruby200/lib/ruby/gems/2.0.0/gems/gosu-0.7.50-x86-mingw32/lib/gosu.for_1_9.so (LoadError)
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:118:in `rescue in require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:124:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/gosu-0.7.50-x86-mingw32/lib/gosu.rb:11:in `<top (required)>'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:114:in `require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:114:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/gamebox-0.5.0/lib/gamebox.rb:5:in `<top (required)>'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:66:in `require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:66:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/gamebox-0.5.0/bin/gamebox:4:in `<top (required)>'
from C:/Ruby200/bin/gamebox:23:in `load'
from C:/Ruby200/bin/gamebox:23:in `<main>'
The important bit there is The specified module could not be found. - C:/Ruby200/lib/ruby/gems/2.0.0/gems/gosu-0.7.50-x86-mingw32/lib/gosu.for_1_9.so
I then went back and realized the whole Unicode thing, updated rdoc to the newest version as per this guy, and ran gem uninstall gosu followed by gem install gosu. Everything seemed to build just fine, and I saw that the needed file, .../gosu.for_1_9.so, was right where it needed to be.
However, I am still getting exactly the same error about not being able to find gosu.for_1_9.so!
I've been able to find exactly two Google results where someone else had this issue. In one situation the problem was peripheral because the guy was hacking on his gosu installation a bit; in the other, the solution was "Ruby 2 is bad and you should use Ruby 1.9", which is really not my preferred option.
Any ideas?
Ken,
The file is being found, but is not compatible to load in Ruby 2.0.0.
This is a bug / missing feature of Gosu. It does not work with Ruby 2.0.0 on Windows. The author of the gem has plans to work this out, but has not yet tackled it. You can follow up on the issue on Github here: https://github.com/jlnr/gosu/issues/163
The author can be found on freenode IRC in #gosu. I'm sure they could use some help with their windows support. Unfortunately, the answer to using Gamebox on Windows is to downgrade to Ruby 1.9.3. I will add this to the Gamebox wiki.
I agree with #Shawn42
But probably the best way is to install beforehand a ruby version manager.
RVM with Pik is what I use on Windows.
That way you can install the older 1.9.3 version of ruby and call pik to use that version whenever you want to use gamebox. You'll still have ruby 2.0.0 installed and ready to be used for your other projects.
http://www.ruby-on-rails-outsourcing.com/articles/2010/07/28/ruby-version-manager-for-windows/
Cheers

ruby error on windows 7 x64

install ruby 1.9.3, devkit, mingw
gem install rails work good, but when i create new rails app - have bundler error
D:/Programes/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': 193: %1 эх  ты хЄё  яЁшыюцхэшхь Win32. - D:/Programes/Ruby193/lib/ruby/1.9.1/i386-mingw32/digest/sha1.so (LoadError)
from D:/Programes/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from D:/Programes/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/definition.rb:1:in `<top (required)>'
from D:/Programes/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:138:in `definition'
from D:/Programes/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/cli.rb:219:in `install'
from D:/Programes/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `run'
from D:/Programes/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from D:/Programes/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/vendor/thor.rb:263:in `dispatch'
from D:/Programes/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/vendor/thor/base.rb:386:in`start'
from D:/Programes/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/bin/bundle:13:in `<main>'
and commands like
D:\Work\ruby>gem help commands
ERROR: Loading command: server (LoadError)
193: %1 эх  ты хЄё  яЁшыюцхэшхь Win32. - D:/Programes/Ruby193/lib/ruby/1.9.1/i386-mingw32/digest/md5.so
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::ServerCommand
file md5.so exists
what i forgot to do and may ruby don`t work on windows 7 x64?
I think you use cyrillic without # encoding: UTF-8, just add it to file where you use эх ты...
P.S.: откуда вообще там кирилица?
Also running Windows 7 x64, and I had this same problem crop up on me with 1.9.3-p0. Searched the web without success. Also tried copying in the "sha1.so" file from 1.9.2-p290 in case it was a problem with that particular library -- nope.
I'd suggest something about rubygems or bundler seems to break require, but the same bundler and rubygems code runs fine on 1.9.2. I get no problem running require "digest/sha1"
in my own bare test file with Ruby 1.9.3.
Reverting to Ruby 1.9.2-p290 fixed the problem for me for the moment.

Problem using wxRuby

I am trying to create my first GUI using wxRuby. I installed wxRuby (using gem install wxruby-ruby19) and, it seemed to be installed alright. I copied some code directly from the wxRuby site. Here is the code I used:
test.rb
require "wx"
include Wx
class MinimalApp < App
def on_init
Frame.new(nil, -1, "The Bare Minimum").show()
end
end
MinimalApp.new.main_loop
When I ran it, I got this error:
<internal:lib/rubygems/custom_require>:29:in `require': libwx_gtk2u_stc-2.8.so.0: cannot open shared object file: No such file or directory - /usr/local/ruby/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-linux/lib/wxruby2.so (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-linux/lib/wx.rb:12:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:33:in `require'
from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from test.rb:2:in `<main>'
I thought it was saying that wxruby wasn't in that directory, but I checked and it was, so I'm not sure what the problem is. If anyone could help, that would be awesome.
I tried the same thing and got the same result.
It turns out that there are 2 wxRuby gems. If you are using Ruby 1.9x, you want wxRuby-ruby19. (gem install wxruby-ruby19).
I uninstalled the wxruby gem that I installed the first time (gem uninstall wxruby), and then installed the gem for my version of Ruby (gem install wxruby-ruby19). And Voila! All the sample code just worked. No additional downloads needed.
To use wxRuby you need wxWidgets installed (wxGTK in your case).
The problem is wxRuby uses the wxWidgets shared libraries (e.g. libwx_gtk2u_stc-2.8.so.0) and it cant find them.

Resources