Script

March 19, 2026 ยท View on GitHub

Runs a rbenv aware script.

Properties

NameTypeDefaultDescription
rbenv_versionStringRuby version to run the script on.
codeStringScript code to run.
createsStringPrevent the script from creating a file when that file already exists.
cwdStringThe current working directory from which the command will be run.
environmentHashA Hash of environment variables in the form of ({"ENV_VARIABLE" => "VALUE"})
groupStringThe group ID to run the command as.
pathArrayPath to add to environment.
returnsArray[0]The return value for a command. This may be an array of accepted values.
timeoutIntegerThe amount of time (in seconds) to wait for the script to complete.
umaskString, IntegerThe file mode creation mask, or umask.
live_streamtrue, falsefalseLive stream the output from the script to the console.
userStringUsername to run the script as.
root_pathStringSee root_path helperPath to install Ruby to.

Examples

rbenv_script 'foo' do
  rbenv_version '2.5.1'
  user 'vagrant'
  returns ['1','255']
  code "echo 'FOO'"
end

Note that environment overwrites the entire variable. For example, setting the $PATH variable can be done like this:

rbenv_script 'bundle package' do
  cwd node["bundle_dir"]
  environment ({"PATH" => "/usr/local/rbenv/shims:/usr/local/rbenv/bin:#{ENV["PATH"]}"})
  code "bundle package"
end

Where #{ENV["PATH"]} appends the existing PATH to the end of the newly set PATH.