0

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/
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Deekor
  • 9,144
  • 16
  • 69
  • 121
  • You need dev package not just ruby: http://stackoverflow.com/questions/7645918/require-no-such-file-to-load-mkmf-loaderror – pjsofts May 01 '15 at 19:37
  • When require fails it means you don't the module to use. – pjsofts May 01 '15 at 19:39
  • Socket is available in Ruby 1.8.7, so if Ruby is installed so is Socket. Socket is a prerequisite for all number of things so Ruby probably wouldn't work without it. We need to see more information: "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve)." – the Tin Man May 01 '15 at 19:55
  • @theTinMan Theres not much more info to provide. Line of my code throws an error because it cant find sockets. What more info would help you? – Deekor May 01 '15 at 19:59
  • Try `require 'open-uri'; puts open('http://www.example.com').read` and see if you get that error. Add the output of `gem env` to your question, formatted for readability. – the Tin Man May 01 '15 at 20:01
  • @theTinMan same error `'require': no such file to load -- open-uri (LoadError)` – Deekor May 01 '15 at 20:02
  • Then Ruby isn't installed correctly. I'd say it was installed from a package and they didn't install any of the gems that go with it. Ruby should be installed from source, which will install the necessary gems/libraries. Doing it from packages is a horrible mess. – the Tin Man May 01 '15 at 20:02
  • @theTinMan I just tried running those two commands in irb and it worked fine... – Deekor May 01 '15 at 20:04
  • Interesting. Well, `gem env` should reveal something then. It still sounds like your system or environment isn't configured right. – the Tin Man May 01 '15 at 20:08
  • One possibility: make sure you’re using `socket` (all lower case) and not e.g. `Socket` or `SOCKET`. They will work on a Mac but not on Linux (probably – Linux usually has a case sensitive file system). – matt May 01 '15 at 20:21
  • @theTinMan ive added the env to my question – Deekor May 01 '15 at 20:34
  • @matt nope it all lowercase – Deekor May 01 '15 at 20:34
  • `gem env` output is missing the PATH information. Please add the output of `echo $PATH` – the Tin Man May 01 '15 at 21:27
  • @theTinMan `/usr/lib64/ruby/:/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin`, if you saw my previous comment I was wrong.. still doesn't work. – Deekor May 01 '15 at 21:56
  • Adding /usr/lib64/ruby/ to the path won't do any good. Path has to point to executables. Your Ruby executables should all exist in `/usr/bin` or `/usr/local/bin`. And, except for conversational responses, you should always put requests for information in your question, not in comments. The question is the container for all information necessary for us helping you. Doing otherwise forces people to read every comment to try to make sense of things. – the Tin Man May 01 '15 at 22:05
  • @theTinMan how do I find the executables? – Deekor May 01 '15 at 22:19
  • I'd recommend talking to your systems admins who can straighten this out for you quickly. – the Tin Man May 01 '15 at 22:22
  • @theTinMan I just tried and he has no clue. – Deekor May 01 '15 at 22:22

0 Answers0