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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:17:17+00:00 2026-05-23T14:17:17+00:00

(See update at bottom) I feel like I’m missing something terribly obvious here, but

  • 0

(See update at bottom)


I feel like I’m missing something terribly obvious here, but I can’t change gemsets from within a shell script. This minimal script demonstrates:

#!/usr/bin/env bash

rvm gemset use "testing"

I even tried the instructions from the Scripting RVM page (although it didn’t seem necessary):

#!/usr/bin/env bash

# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
  # First try to load from a user install
  source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
  # Then try to load from a root install
  source "/usr/local/rvm/scripts/rvm"
else
  printf "ERROR: An RVM installation was not found.\n"
fi

rvm gemset use "testing"

Still no go.

Interestingly enough, if I try to run the script without first creating the “testing” gemset, I get ERROR: Gemset 'testing' does not exist, rvm gemset create 'testing' first. However, if I create the gemset and then run the script, I get no output from the script and the gemset is not changed (according to rvm info). I am able to perform other RVM gemset actions, such as creating gemsets and trusting .rvmrc files, from within the script.

[Update]

Of course, the environment is changing, as indicated by a call to rvm info from within the script. How do I get these changes to persist/affect the calling shell? Or, if that’s not possible (as indicated here), is there any way to set the current RVM gemset based on input to a script?

  • 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-23T14:17:18+00:00Added an answer on May 23, 2026 at 2:17 pm

    Had exactly the same problem, and here’s the solution:

    #!/bin/bash
    
    # IMPORTANT: Source RVM as a function into local environment.
    #            Otherwise switching gemsets won't work.
    [ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
    
    # Enable shell debugging.
    set -x
    
    rvm 1.9.2@gemset_a
    rvm gemdir
    gem env gemdir
    
    rvm 1.9.2@gemset_b
    rvm gemdir
    gem env gemdir
    

    What I’ve found out is that your interactive shell has got rvm() and its helpers, whereas script’s environment has not got them. rvm binary is executed instead, partially working and thus causing some confusion.

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

Sidebar

Related Questions

I see the answer here is no, but wondered if there is any update
Update: See the bottom of this question for a C# workaround. Hi there, Consider
I see that EF can update a model based on an existing database schema.
Update: OK I see it's a bubble sort, but is it less efficient because
UPDATE The issue is solved, all the code you can see works. Hello! I
UPDATE: See the bottom of this question for what I did to solve the
On lots of sites now, you can see a Facebook Like Button. - When
Was able to recreate a simpler scenario, see update near bottom First some backround
UPDATE See bottom for update. I've been looking alot around the internet and I
UPDATE: Please see the updates below, as I'm adding more information to the bottom

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.