Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6045117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:05:21+00:00 2026-05-23T07:05:21+00:00

I am trying to load a file into IRB. I have the file saved

  • 0

I am trying to load a file into IRB. I have the file saved on my desktop titled “Ruby.rb”
How do i load the file into IRB?

I have tried using both, ‘load “Ruby.rb”‘, ‘load “Ruby”‘ and ‘require “Ruby.rb”. these documents are on my desktop, is there something requiring a path directory here?

The path for the document is C:\Users\Jamal\desktop, am i meant to include this into the load “Ruby.rb” command?
THanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:05:22+00:00Added an answer on May 23, 2026 at 7:05 am

    It depends on the version of Ruby you are using (1.8.x or 1.9.x). load and require work both on the loadpath of Ruby. You can have a look at it by evaluating $: inside IRB. In Ruby 1.9.x the current directory is not part of the loadpath, so you have to use the absolute path to your file. Depending on the operating system you are using (Windows 7), this may look like:

    c:\Users\mliebelt\Desktop>irb
    irb(main):001:0> $:
    => ["C:/apps/ruby/ruby192/lib/ruby/site_ruby/1.9.1", "C:/apps/ruby/ruby192/lib/ruby/site_ruby/1.9.1/i386-msvcrt", "C:/apps/ruby/ruby192/lib/ruby/site_ruby", "C:/apps/ruby/ruby192/lib/ruby/vendor_ruby/1.9.1", "C:/apps/ruby/ruby192/lib/ruby/vendor_ruby/1.9.1/i386-msvcrt", "C:/apps/ruby/ruby192/lib/ruby/vendor_ruby", "C:/apps/ruby/ruby192/lib/ruby/1.9.1", "C:/apps/ruby/ruby192/lib/ruby/1.9.1/i386-mingw32"]
    irb(main):002:0> require 'c:/Users/mliebelt/Desktop/ruby'
    File c:/Users/mliebelt/Desktop/ruby.rb loaded.
    => true
    irb(main):003:0> load 'c:/Users/mliebelt/Desktop/ruby.rb'
    File c:/Users/mliebelt/Desktop/ruby.rb loaded.
    => true
    

    By the way, the contents of the file ruby.rb is:

    puts "File #{__FILE__} loaded."
    

    The same session with IRB on Ruby 1.8.x may look like that:

    c:\Users\mliebelt\Desktop>irb
    irb(main):001:0> $:
    => ["C:/Users/mliebelt/.pik/rubies/Ruby-187-p334/lib/ruby/site_ruby/1.8", "C:/Users/mliebelt/.pik/rubies/Ruby-187-p334/lib/ruby/site_ruby/1.8/i386-msvcrt", "C:/Users/mliebelt/.pik/rubies/Ruby-187-p334/lib/ruby/site_ruby", "C:/Users/mliebelt/.pik/rubies/Ruby-187-p334/lib/ruby/vendor_ruby/1.8", "C:/Users/mliebelt/.pik/rubies/Ruby-187-p334/lib/ruby/vendor_ruby/1.8/i386-msvcrt", "C:/Users/mliebelt/.pik/rubies/Ruby-187-p334/lib/ruby/vendor_ruby", "C:/Users/mliebelt/.pik/rubies/Ruby-187-p334/lib/ruby/1.8", "C:/Users/mliebelt/.pik/rubies/Ruby-187-p334/lib/ruby/1.8/i386-mingw32", "."]
    irb(main):002:0> require 'ruby'
    File ./ruby.rb loaded.
    => true
    irb(main):003:0> load 'ruby.rb'
    File ./ruby.rb loaded.
    => true
    

    The differences between require and load are:

    • require does not need the suffix (.rb) of the file
      • require 'ruby' and require 'ruby.rb' are the same
    • require reads the file into memory once, so require should normally be used instead of load, which reads the file into memory every time functions in the file are called.

    So to load files (by using require or load), do the following:
    – expand your load path by your current directory (if necessary). See Adding a directory to loadpath
    – (when using Ruby 1.8.x) Start your program (or IRB) in the directory from which you want to load or require files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to load a data file into mysql table using LOAD DATA
I'm trying to load a .sql file in a ruby script into a string
I am trying to load a data file into mysql table using LOAD DATA
Im trying to load a csv file into a datatable using oledb. This is
I have been trying to load a OCX file into one of my VB6
I am trying to load a CSV file into an array using ColdFusion (version
I have imported a file x.ani into Resource file Resources.resx. Now trying to load
I have been trying to load a text file into a combobox, and then
I have problems trying to load png file into my application. It seems to
I am trying to figure out an eazy way to load CSV file into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.