Need help with rbenv-vars?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

412 Stars 44 Forks MIT License 26 Commits 9 Opened issues


An rbenv plugin that safely sets global and per-project environment variables

Services available


Need anything else?

Contributors list


This is a plugin for rbenv that lets you set global and project-specific environment variables before spawning Ruby processes.


Make sure you have the latest version of rbenv, then run:

git clone $(rbenv root)/plugins/rbenv-vars


Define environment variables in an

file in your project, one variable per line, in the format
. For example:

You can perform variable substitution with the traditional

syntax. For example, to append to

You may also have conditional variable assignments, such that a variable will only be set if it is not already defined or is blank:

JAVA_OPTS?=-server -Xmx768m -Xms768m -Xmn128m -Xss20m

In the above case,

will only be set if
is currently empty (i.e., if
[ -z "$JAVA_OPTS" ]
is true).

Spaces are allowed in values; quoting is not necessary. Expansion and command substitution are not allowed. Lines beginning with

or any lines not in the format VAR=value will be ignored.

Variables specified in the

file will be set first. Then variables specified in
files in any parent directories of the current directory will be set. Variables from the
file in the current directory are set last.

Use the

rbenv vars
command to print all environment variables in the order they'll be set.

Version History

1.2.0 (January 9, 2013)

  • Fixed a bug where source files without a trailing newline could concatenate improperly with other source files on systems with GNU sed.
  • Changed the output of
    rbenv vars
    to include the source file path in a comment above its variables, and an empty line between each source file, for easier debugging.
  • Added support for
    rbenv help vars
    with rbenv 0.4.0.

1.1.0 (June 25, 2012)

  • Added support for conditional variable assignments using
    . Thanks to Scott Gonyea for the patch.

1.0.0 (September 27, 2011)

  • Initial public release.


© 2012 Sam Stephenson. Released under the MIT license. See

for details.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.