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 8882887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:41:10+00:00 2026-06-14T20:41:10+00:00

I need to reference a local gem from a plain ruby script, without installing

  • 0

I need to reference a local gem from a plain ruby script, without installing the gem. On the trail of How to refer a local gem in ruby?, i tried creating a Gemfile with the following setup:

%w(
  custom_gem
  another_custom_gem
).each do |dependency|
  gem dependency, :path => File.expand_path("../../#{dependency}", __FILE__)
end

and the script looks like this:

require 'custom_gem'
CustomGem::Do.something

When I execute this with:

bundle exec ruby script.rb

I get:

script.rb:1:in `require': cannot load such file -- custom_gem (LoadError) from script.rb:1:in `<main>'

If I leave out the require 'custom_gem' , I get:

script.rb:3:in `<main>': uninitialized constant CustomGem (NameError)

I even tried without bundler, and just writing gem ... :path =>̣ ... in the script itself, but without results. Is there any other way of referencing custom gems from ruby scripts, without installing the gems locally?

  • 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-06-14T20:41:11+00:00Added an answer on June 14, 2026 at 8:41 pm

    Make sure that your gem name as same as in Gemfile (e.g. custom_gem)

    # Gemfile
    
    source "https://rubygems.org"
    
    gem "custom_gem", path: "/home/username/path/to/custom_gem"
    

    Don’t forget to actually install this gem using bundler

    bundle install
    

    After that, the script should be ready to use by bundle exec ruby script.rb

    # script.rb
    
    require 'custom_gem'
    CustomGem::Do.something
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a resume script and I need the heading Reference to be
I use google as my primary reference so I don't need a local copy
I need a reference counter for an object not allocated on the heap. I
Say I have some 10 categories that I need to reference in a web
I am building a common function library but the functions inside need to reference
I'm building a Windows Phone 7 app, and I need a reference to my
Somebody ask me this question today . What is the need of reference in
I need to programmatically set up a node reference field. My module successfully creates
Here is the reference tutorial Do I need to create django_login and edit the
What do I need to do in order to reference the double click event

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.