Skip to content

Latest commit

 

History

History
130 lines (78 loc) · 3.51 KB

README.md

File metadata and controls

130 lines (78 loc) · 3.51 KB

rubygems-bundler && Noexec

Let's stop using bundle exec, kthx.

Installation

gem install rubygems-bundler

Add / Change a line in ~/.gemrc to:

custom_shebang: $env ruby_noexec_wrapper

Next run (once):

gem regenerate_binstubs

And you're done!

Alternatively, in your .bashrc (or somewhere you can set env variables):

export RUBYOPT="-r`noexec`"

Configuration

Though you can let noexec do it's own thing and rely on looking up your binary via your Gemfile, you can also specify which binaries you want included or excluded. Create a .noexec.yaml file along side any Gemfiles you want to use. Then, to enable (or disable) the usage of your particular binary into your bundle, add an include or exclude section. For example:

.noexec.yaml

exclude: [rake]

Or,

include: [irb, ruby]

Problems?

Things not going the way you'd like? Try your command again with NOEXEC_DEBUG=1 set and create a ticket. I'll fix it right away!

How does this work?

It adds a script to every execution of ruby via the RUBYOPT environment variable. Then, when you run ruby, it takes a look at your working directory, and every directory above it until it can find a Gemfile. If the executable you're running is present in your Gemfile, it switches to using that Gemfile instead (via Bundle.setup).

Rubygems and Bundler integration, makes executable wrappers generated by rubygems aware of bundler.

Old description

This gem is intended to fill in the integration gap between Bundler and Rubygems, it also backports shebang customization from rubygems 1.9 to older versions - down to 1.3.7.

With this gem rubygems generated wrappers will allow to use bundler when asked for.

Using this gem solves problem of calling bundle exec ... with your every command.

Please note that this gem can make your gem executables load in versions specified in Gemfile!

The problem with Gemfile is that you can have few of them, so expect that gem version for executable will be taken from ~/Gemfile when your project is in ~/projects/my_project and does not contain Gemfile

Last note is that bundler handling can be used only when bundler is installed, but you will be warned when it is

Uninstallation

Before uninstalling change a line in ~/.gemrc to:

custom_shebang: $env ruby

and run gem regenerate_binstubs

this will set all gems to /usr/bin/env ruby which is one of the safest choices (especially when using rvm).

Controlling the wrapper - the old way, the old wrapper

Add / Change a line in ~/.gemrc to:

custom_shebang: $env ruby_bundler_wrapper

Next run (once):

gem regenerate_binstubs

Wrappers generated by this gem will replace original rubygems wrapper, but it will not change wrapper behavior unless explicitly asked for.

To allow using bundler when available, but fallback to rubygems when not:

export USE_BUNDLER=try

To force usage of bundler:

export USE_BUNDLER=force

Some gems should not be called with bundler support, to blacklist them use the following line:

BUNDLER_BLACKLIST="cheat heroku"

To make your choices persistent put them into ~/.bashrc or ~/.rvmrc.

Authors

Thanks

  • Carl Lerche : help with the noexec code
  • Yehuda Katz : the initial patch code
  • Wayne E. Seguin : support in writing good code
  • Evan Phoenix : support on rubygems internalls
  • Andre Arko : claryfications how rubygems/bundler works
  • Loren Segal : shebang customization idea and explanations