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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:34:31+00:00 2026-05-15T16:34:31+00:00

I am trying to run a ruby script as root. When I try to

  • 0

I am trying to run a ruby script as root. When I try to require a gem, ruby says it can’t be found. This is because of $:

$ ruby -e "puts $:"
/opt/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.beta4/lib
/opt/local/lib/ruby/gems/1.9.1/gems/cgi_multipart_eof_fix-2.5.0/lib
/opt/local/lib/ruby/gems/1.9.1/gems/daemons-1.1.0/lib
/opt/local/lib/ruby/gems/1.9.1/gems/eventmachine-0.12.10/lib
/opt/local/lib/ruby/gems/1.9.1/gems/fastthread-1.0.7/lib
/opt/local/lib/ruby/gems/1.9.1/gems/fastthread-1.0.7/ext
/opt/local/lib/ruby/gems/1.9.1/gems/fastthread-1.0.7/bin
/opt/local/lib/ruby/gems/1.9.1/gems/gem_plugin-0.2.3/bin
/opt/local/lib/ruby/gems/1.9.1/gems/gem_plugin-0.2.3/lib
/opt/local/lib/ruby/gems/1.9.1/gems/json_pure-1.4.3/bin
/opt/local/lib/ruby/gems/1.9.1/gems/json_pure-1.4.3/lib
/opt/local/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5/bin
/opt/local/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5/lib
/opt/local/lib/ruby/gems/1.9.1/gems/msgpack-0.4.3/lib
/opt/local/lib/ruby/gems/1.9.1/gems/nestful-0.0.2/lib
/opt/local/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2/bin
/opt/local/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2/lib
/opt/local/lib/ruby/gems/1.9.1/gems/num_to_bytes-1.4.1/ext
/opt/local/lib/ruby/gems/1.9.1/gems/num_to_bytes-1.4.1/bin
/opt/local/lib/ruby/gems/1.9.1/gems/open4-1.0.1/lib
/opt/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/bin
/opt/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib
/opt/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin
/opt/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib
/opt/local/lib/ruby/gems/1.9.1/gems/ruby-processing-1.0.9/bin
/opt/local/lib/ruby/gems/1.9.1/gems/ruby-processing-1.0.9/lib
/opt/local/lib/ruby/gems/1.9.1/gems/ruby_parser-2.0.4/bin
/opt/local/lib/ruby/gems/1.9.1/gems/ruby_parser-2.0.4/lib
/opt/local/lib/ruby/gems/1.9.1/gems/rubyforge-2.0.4/bin
/opt/local/lib/ruby/gems/1.9.1/gems/rubyforge-2.0.4/lib
/opt/local/lib/ruby/gems/1.9.1/gems/sexp_processor-3.0.4/lib
/opt/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib
/opt/local/lib/ruby/gems/1.9.1/gems/thin-1.2.7/bin
/opt/local/lib/ruby/gems/1.9.1/gems/thin-1.2.7/lib
/opt/local/lib/ruby1.9/site_ruby/1.9.1
/opt/local/lib/ruby1.9/site_ruby/1.9.1/i386-darwin10
/opt/local/lib/ruby1.9/site_ruby
/opt/local/lib/ruby1.9/vendor_ruby/1.9.1
/opt/local/lib/ruby1.9/vendor_ruby/1.9.1/i386-darwin10
/opt/local/lib/ruby1.9/vendor_ruby
/opt/local/lib/ruby1.9/1.9.1
/opt/local/lib/ruby1.9/1.9.1/i386-darwin10
.
$ sudo ruby -e "puts $:"
/opt/local/lib/ruby1.9/site_ruby/1.9.1
/opt/local/lib/ruby1.9/site_ruby/1.9.1/i386-darwin10
/opt/local/lib/ruby1.9/site_ruby
/opt/local/lib/ruby1.9/vendor_ruby/1.9.1
/opt/local/lib/ruby1.9/vendor_ruby/1.9.1/i386-darwin10
/opt/local/lib/ruby1.9/vendor_ruby
/opt/local/lib/ruby1.9/1.9.1
/opt/local/lib/ruby1.9/1.9.1/i386-darwin10
.

Why is this happening?

  • 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-15T16:34:32+00:00Added an answer on May 15, 2026 at 4:34 pm

    Try sudo -E ruby -e "puts $:".

    From the sudo man page:

       -E          The -E (preserve environment) option will override the env_reset option in sudoers(5)).
                   It is only available when either the matching command has the SETENV tag or the setenv
                   option is set in sudoers(5).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run a ruby script which needs root access for some
I've been having real problems trying to get a ruby script to run through
I tried to run ruby script/server RAILS_ENV=production but somehow it always try to read
I am trying to run a ruby script that parses a text file with
I am trying to run growlnotify from inside a ruby script. The command I
I'm trying to run RoR server under ubuntu 9.10: > ruby script/server > =>
I have a Ruby script that I built in TextMate and can successfully run
I have two ruby script cron jobs that I'm trying to run under Ubuntu
I am trying to run a ruby script to rename some files but I
I'm trying to run a Ruby script using rbenv with cron. I know that

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.