Search code examples
ruby-on-railsruby-on-rails-4rspec

Why do I need binstubs in Rails?


I don't completely understand the purpose of binstubs feature in Rails.

For example, when I ran bin/bundle binstubs rspec-rails I got the following output:

rspec-rails has no executables, but you may want one from a gem it depends on.
  railties has: rails
  rspec-core has: autospec, rspec

What does it mean? And why do I need bin/bundle binstubs rspec-core command?


Solution

  • Binstubs are wrapper scripts around executables (sometimes referred to as "binaries", although they don't have to be compiled) whose purpose is to prepare the environment before dispatching the call to the original executable.

    In the Ruby world, the most common binstubs are the ones that RubyGems generates after installing a gem that contains executables. But binstubs can be written in any language, and it often makes sense to create them manually.

    Source: rbenv wiki – Understanding binstubs