.\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . .TH "BUNDLE\-EXEC" "1" "July 2011" "" "" . .SH "NAME" \fBbundle\-exec\fR \- Execute a command in the context of the bundle . .SH "SYNOPSIS" \fBbundle exec\fR \fIcommand\fR . .SH "DESCRIPTION" This command executes the command, making all gems specified in the \fBGemfile(5)\fR available to \fBrequire\fR in Ruby programs\. . .P Essentially, if you would normally have run something like \fBrspec spec/my_spec\.rb\fR, and you want to use the gems specified in the \fBGemfile(5)\fR and installed via bundle install(1) \fIbundle\-install\.1\.html\fR, you should run \fBbundle exec rspec spec/my_spec\.rb\fR\. . .P Note that \fBbundle exec\fR does not require that an executable is available on your shell\'s \fB$PATH\fR\. . .SH "BUNDLE INSTALL \-\-BINSTUBS" If you use the \fB\-\-binstubs\fR flag in bundle install(1) \fIbundle\-install\.1\.html\fR, Bundler will automatically create a directory (which defaults to \fBapp_root/bin\fR) containing all of the executables available from gems in the bundle\. . .P After using \fB\-\-binstubs\fR, \fBbin/rspec spec/my_spec\.rb\fR is identical to \fBbundle exec rspec spec/my_spec\.rb\fR\. . .SH "ENVIRONMENT MODIFICATIONS" \fBbundle exec\fR makes a number of changes to the shell environment, then executes the command you specify in full\. . .IP "\(bu" 4 make sure that it\'s still possible to shell out to \fBbundle\fR from inside a command invoked by \fBbundle exec\fR (using \fB$BUNDLE_BIN_PATH\fR) . .IP "\(bu" 4 put the directory containing executables (like \fBrails\fR, \fBrspec\fR, \fBrackup\fR) for your bundle on \fB$PATH\fR . .IP "\(bu" 4 make sure that if bundler is invoked in the subshell, it uses the same \fBGemfile\fR (by setting \fBBUNDLE_GEMFILE\fR) . .IP "\(bu" 4 add \fB\-rbundler/setup\fR to \fB$RUBYOPT\fR, which makes sure that Ruby programs invoked in the subshell can see the gems in the bundle . .IP "" 0 . .P It also modifies Rubygems: . .IP "\(bu" 4 disallow loading additional gems not in the bundle . .IP "\(bu" 4 modify the \fBgem\fR method to be a no\-op if a gem matching the requirements is in the bundle, and to raise a \fBGem::LoadError\fR if it\'s not . .IP "\(bu" 4 Define \fBGem\.refresh\fR to be a no\-op, since the source index is always frozen when using bundler, and to prevent gems from the system leaking into the environment . .IP "\(bu" 4 Override \fBGem\.bin_path\fR to use the gems in the bundle, making system executables work . .IP "\(bu" 4 Add all gems in the bundle into Gem\.loaded_specs . .IP "" 0 . .SS "Shelling out" When shelling out (using the \fBsystem\fR or backticks methods, for example), Bundler\'s environment changes will propogate to the subshell environment\. If you desire to shell out without Bundler\'s environment changes, simply employ the \fBwith_clean_env\fR method\. It will restore all environment variables to what they were before Bundler was activated\. For example: . .IP "" 4 . .nf Bundler\.with_clean_env do `brew install wget` end . .fi . .IP "" 0 . .SH "RUBYGEMS PLUGINS" At present, the Rubygems plugin system requires all files named \fBrubygems_plugin\.rb\fR on the load path of \fIany\fR installed gem when any Ruby code requires \fBrubygems\.rb\fR\. This includes executables installed into the system, like \fBrails\fR, \fBrackup\fR, and \fBrspec\fR\. . .P Since Rubygems plugins can contain arbitrary Ruby code, they commonly end up activating themselves or their dependencies\. . .P For instance, the \fBgemcutter 0\.5\fR gem depended on \fBjson_pure\fR\. If you had that version of gemcutter installed (even if you \fIalso\fR had a newer version without this problem), Rubygems would activate \fBgemcutter 0\.5\fR and \fBjson_pure \fR\. . .P If your Gemfile(5) also contained \fBjson_pure\fR (or a gem with a dependency on \fBjson_pure\fR), the latest version on your system might conflict with the version in your Gemfile(5), or the snapshot version in your \fBGemfile\.lock\fR\. . .P If this happens, bundler will say: . .IP "" 4 . .nf You have already activated json_pure 1\.4\.6 but your Gemfile requires json_pure 1\.4\.3\. Consider using bundle exec\. . .fi . .IP "" 0 . .P In this situation, you almost certainly want to remove the underlying gem with the problematic gem plugin\. In general, the authors of these plugins (in this case, the \fBgemcutter\fR gem) have released newer versions that are more careful in their plugins\. . .P You can find a list of all the gems containing gem plugins by running . .IP "" 4 . .nf ruby \-rubygems \-e "puts Gem\.find_files(\'rubygems_plugin\.rb\')" . .fi . .IP "" 0 . .P At the very least, you should remove all but the newest version of each gem plugin, and also remove all gem plugins that you aren\'t using (\fBgem uninstall gem_name\fR)\.