Can't make the require work

I am new to Ruby but just need to run this:

  1. I know how require works in Perl, but don’t know how does the Ruby
    require work. Does it require just the octokit.rb file or the whole
    directory including the ./client subdirectory?

  2. For the ssl cert error, I tried the solution here to download the new
    cert,, but still
    doesn’t work.

  3. One more note, for the ssl cert error, I don’t get it when run “gem
    install octokit” from a pc at home, but always got that error from the
    company pc. Can anyone help me get this running?


Directory of C:\OTPPB2015\Workspace\Ruby

10/09/2015 01:20 PM

10/09/2015 01:20 PM ..
10/09/2015 11:07 AM 18 hello.rb
10/09/2015 12:58 PM octokit
09/24/2015 09:35 AM 2,182 octokit.rb
10/09/2015 12:57 PM 2,447 team_audit.rb
3 File(s) 4,647 bytes
3 Dir(s) 273,722,306,560 bytes free
C:\OTPPB2015\Workspace\Ruby>ruby team_audit.rb

require’: cannot load such file – octokit/client (LoadError) from
from C:/OTPPB2015/Workspace/Ruby/octokit.rb:1:in <top (required)>’
from team_audit.rb:13:inrequire_relative’
from team_audit.rb:13:in `

C:\Users\huj\Desktop>ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x64-mingw32]

C:\Users\huj\Desktop>gem -v

C:\Users\huj\Desktop>gem install octokit
ERROR: Could not find a valid gem 'octokit' (>= 0), here is why:
Unable to download data from - SSL_connect

returned=1 errno=0 state=
SSLv3 read server certificate B: certificate verify failed

Jirong Hu wrote in post #1179003:

I am new to Ruby but just need to run this:

  1. I know how require works in Perl, but don’t know how does the Ruby
    require work.

require() is a method in the Kernel class. You can read the ruby docs

If that is too technical, I suggest you read about load(), then
require() here:

But essentially, require() executes the code in the file you specify–
just like perl’s require. So, if you have a file containing this code:

puts “hello”

and in another file in the same directory you have the code:

require ‘./my_prog’

Then “hello” will be output in your terminal/command window when you run

$ ruby test.rb

The next issue is: where does ruby search for the files you require. If
you don’t specify a path to your file in the require(), then ruby
searches for the specified file name in the directories listed in the
Array $LOAD_PATH, which you can examine:


(perl searches the directories listed in the @INC array). So in the
example above if you write:

require ‘my_prog’

that will result in an error (unless the current directory happens to be
one of the directories in $LOAD_PATH).

So an easy way to run the program you want is: copy the code and paste
it into a file, then look through the code for any require statements.
For any files that are required, copy those files into the same
directory as the main program, then change the require statements so
that they specify paths to the files:

require ‘./file_name’ (no .rb extension)

I should warn you: even though that works, that isn’t considered good
practice. Read about require_relative() at the second link above for
the proper way to do things.

Ugh…it looks like the file you need to require also requires other
files. Because the file you want to require is a ruby gem, you
are in luck. You can install the gem, then use a normal require:

require ‘octokit’

Installing a gem will modify $LOAD_PATH. You can read about it

By the way, if the file you are trying to require has this code:

class Dog
def greet
puts “bow wow”

…there won’t be any output when the require statement executes that
code. However, when that code executes it will create a global variable
named Dog, and it will be a ruby Class, which you can use to create
instances, e.g.

my_dog =

Typically, when you require a file, there won’t be any output–the
reason you are requiring the file is so that the variables defined in
the file (usually classes) will be created.