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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:35:14+00:00 2026-06-04T01:35:14+00:00

rbenv requires you to manually run bundle exec if you’re running an executable from

  • 0

rbenv requires you to manually run “bundle exec” if you’re running an executable from a gem, to avoid loading a different version of that gem compared with your Gemfile.

Are there any downsides to having the rbenv shims run “bundle exec” when a Gemfile is present in the current directory? It’s a somewhat naive approach, because it doesn’t handle Gemfile’s that are further up the directory tree, but I don’t need that behavior. The change would also make sure the current shim isn’t named “bundle” or there could be an infinite recursion.

Patch:

diff --git a/libexec/rbenv-rehash b/libexec/rbenv-rehash
index eebc4d3..00f4ec0 100755
--- a/libexec/rbenv-rehash
+++ b/libexec/rbenv-rehash
@@ -38,7 +38,14 @@ create_prototype_shim() {
 #!/usr/bin/env bash
 set -e
 export RBENV_ROOT="$RBENV_ROOT"
-exec rbenv exec "\${0##*/}" "\$@"
+# This only handles Gemfile in current dir
+if [[ \$RBENV_AUTO_BUNDLE = '1' && -e Gemfile && \`basename \$0\` != 'bundle' ]]; then
+  exec 3>/dev/tty
+  echo "rbenv: Using Gemfile" >&3
+  exec rbenv exec bundle exec "\${0##*/}" "\$@"
+else
+  exec rbenv exec "\${0##*/}" "\$@"
+fi
 SH
   chmod +x "$PROTOTYPE_SHIM_PATH"
 }

You must set environment variable RBENV_AUTO_BUNDLE=1 to enable the auto “bundle exec” behavior.

If there’s enough demand I might submit a patch.

To apply the patch, just put the patch file in your .rbenv dir, and run

git apply PATCHFILE

To test the patch, you’ll have to delete your shims and run “rbenv rehash”.

To undo:

git apply -R PATCHFILE

or

git checkout -- libexec/rbenv-rehash

then recreate the shims again.

It does seem that vim will run some ruby when you load a ruby file, and bundle exec will be used with that too. You could disable the auto behavior via let $RBENV_AUTO_BUNDLE=0.

  • 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-04T01:35:15+00:00Added an answer on June 4, 2026 at 1:35 am

    rbenv requires you to manually run “bundle exec” if you’re running an
    executable from a gem, to avoid loading a different version of that
    gem compared with your Gemfile.

    Unless you use the rbenv-bundler plugin, which IMHO is a saner approach than trying to reimplemented that behavior yourself. If there’s anything missing from that plugin, rather contribute it there.

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

Sidebar

Related Questions

I moved from RVM to rbenv on my production server. I uninstalled rvm using
Let's say my PATH=/usr/bin ... /root/.rbenv/shims I have an executable (ruby) in /usr/bin and
I'm seriously stumped. I run bundle install successfully: bundle install ... Using activerecord-oracle_enhanced-adapter (1.4.1)
I've decided to move away from rvm to rbenv on my personal machine. Followed
I'm trying to run a Ruby script using rbenv with cron. I know that
After following the setup described on the Github page for rbenv and running the
I've switched to rbenv in production (staging to be correct) and most of the
After installing RBEnv and rebuilding my ROR project, I now seem to have added
I was following along with Ryan's RailsCast Episode 339. I had installed rbenv and
The rbenv documentation states that you can use the gemsets plugin to sandbox your

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.