`require': no such file to load -- socket (LoadError) - ruby

I wrote a homework assignment on my Mac at home and am now trying to run it on the Linux machines at school (where it will be graded) and am getting:
.rb:1:in `require': no such file to load -- socket (LoadError)
Obviously I am trying to use Ruby's socket class:
require 'socket'
Checking the schools ruby version I see: ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]
Shouldn't this version of the sockets? Am I doing something wrong? Anyway to get this to work?
gem env output:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/devans/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/

Related

How to set correct Ruby version in gem environment

Note: This question relates to How can I get bundler to use the Ruby version set by chruby and .ruby-version?.
Using chruby I have Ruby 1.8.7 installed on macOS:
$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0]
Also, I have used gem update --system 1.8.30 to install a specific version of RubyGems which I am hoping is compatible. This would appear to be installed properly:
$ gem --version
1.8.30
However, my RubyGems environment shows the incorrect version of Ruby (2.5.0):
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.30
- RUBY VERSION: 2.5.0 (2017-12-25 patchlevel 0) [x86_64-darwin17]
- INSTALLATION DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
- GEM PATHS:
- /Users/keithpitty/.gem/ruby/1.8.7
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
How can I fix the RubyGems environment to use the version of Ruby that chruby has set?
My missing step was installing RubyGems 1.6.2 from source. Following advice elsewhere from Dan Cheail, I did the following:
curl -O https://rubygems.org/rubygems/rubygems-1.6.2.tgz
(and then unzipped it)
cd rubygems-1.6.2
chruby ruby-1.8.7-p374
ruby setup.rb
gem update --system 1.8.25
And then my RubyGems environment was fixed:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0]
- INSTALLATION DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7
- RUBY EXECUTABLE: /Users/keithpitty/.rubies/ruby-1.8.7-p374/bin/ruby
- EXECUTABLE DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-17
- GEM PATHS:
- /Users/keithpitty/.gem/ruby/1.8.7
- /Users/keithpitty/.rubies/ruby-1.8.7-p374/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/

`require`ing user-installed Ruby module

I've successfully installed my ruby gem to a subdirectory of ~ using the --user-install option to gem. I can now see it under ~/.gem/ruby/1.8/gems/.
However, I'm unable to require it from my script:
./public_html/tt_web/index.cgi:2:in `require': no such file to load -- mbox (LoadError)
from ./public_html/tt_web/index.cgi:2
I added ~/.gem/ruby/1.8/bin to my PATH variable per the information here (and I've verified it actually worked with echo $PATH).
What else do I need to load gems from a custom path?
Here is the output of gem env, if it helps:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /home/elliott/.gem
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gempath" => ["/home/elliott/.gem", "/var/lib/gems/1.8"]
- "install" => "--user-install"
- REMOTE SOURCES:
- http://rubygems.org/
Well, I have no idea why this works, but adding require 'rubygems' to the top of my code fixed everything. Perhaps someone else could still shine some light on why, but I'm just happy it's working now :)

Error when installing gems Windows 8

I'm having the following error after installing ruby on Windows 8, I've already uninstalled it several times, fired commands like gem cleanup, removed .gem folder, ruby folder, environment variables, btut nothing seems to work.
Here are the logs of the errors I am encountering
ruby 1.9.3p385 (2013-02-06) [i386-mingw32]
C:\Users\david>gem update
Updating installed gems
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
SocketError: getaddrinfo: No such host is known. (http://rubygems.org/lates
t_specs.4.8.gz)
C:\Users\david>gem install compass
ERROR: Could not find a valid gem 'compass' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
SocketError: getaddrinfo: No such host is known. (http://rubygems.org/lates
t_specs.4.8.gz)
C:\Users\david>gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2013-02-06 patchlevel 385) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby193/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby193/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby193/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby193/lib/ruby/gems/1.9.1
- C:/Users/david/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
C:\Users\david>gem -v
1.8.24
C:\Users\david>ruby -v
ruby 1.9.3p385 (2013-02-06) [i386-mingw32]
C:\Users\david>

`gem_original_require': no such file to load -- midiator

I have this error loading a ruby file:
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- midiator (LoadError)
RubyGems Environment:
RUBYGEMS VERSION: 1.3.6
RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]
INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
RUBY EXECUTABLE: /usr/local/bin/ruby
EXECUTABLE DIRECTORY: /usr/local/bin
RUBYGEMS PLATFORMS:
ruby
x86-darwin-9
GEM PATHS:
/usr/local/lib/ruby/gems/1.8
/Users/pableras/.gem/ruby/1.8
GEM CONFIGURATION:
:update_sources => true
:verbose => true
:benchmark => false
:backtrace => false
:bulk_threshold => 1000
I had a lot of problems tu install rubygems and now I have problems again with midiator gem. I think something is not well configured. It is like the paths are not properly configured (Midiator gem is installed), but I do not know how to fix this.
Turning this into an answer as it solved the problem:
Is it listed when you do gem list?

ruby version and gem's ruby version do not match

RubyGems is reporting a different ruby version than running ruby --version. Looking for suggestions on diagnosing and fixing this. OS is OS X 10.5.
lando-macbook:rubygems-1.3.7 lando$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-9
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/lkuhn/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
lando-macbook:rubygems-1.3.7 lando$ ruby --version
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin9]
lando-macbook:rubygems-1.3.7 lando$ which ruby
/opt/local/bin/ruby
The problem is that you have a ruby executable in /opt/local/bin that was probably installed by macports at some point. Either deleting this ruby executable or removing /opt/local/bin from your PATH variable should solve your problem. gems is telling you exactly where it expects to find ruby and its associated executables:
RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin

Resources