[LRUG] Rake binstub

Nik Wakelin me at nikwakelin.com
Wed Oct 8 06:04:56 PDT 2014


Hey Andy,

As far as I'm aware, binstubs are just a convenience to avoid typing
"bundle exec" (please correct me if I'm wrong).

So I guess the question is: does a binstub bring any benefit over the plain
ol' bundle exec? (Aside from a prettier command, of course)

Nik

On Wednesday, October 8, 2014, Andrew Stewart <boss at airbladesoftware.com>
wrote:

> Hello!
>
> For a long time I have had on my server a cronjob which runs a rake task:
>
>     42 * * * * RAILS_ENV=production cd /path/to/my/app && bundle exec rake
> blah
>
> Recently I decided to get with the program and use a binstub instead:
>
>     42 * * * * RAILS_ENV=production /path/to/my/app/bin/rake blah
>
> But it fails with: "rake aborted! No Rakefile found".  Naturally there is
> a Rakefile at /path/to/my/app.
>
> My rake binstub is the one that comes with Rails 4:
>
>
> https://github.com/rails/rails/commit/009873aec89a4b843b41accf616b42b7a9917ba8#diff-15
>
> – not the one that Bundler would generate:
>
>     #!/usr/bin/env ruby
>     #
>     # This file was generated by Bundler.
>     #
>     # The application 'rake' is installed as part of a gem, and
>     # this file is here to facilitate running it.
>     #
>
>     require 'pathname'
>     ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
>       Pathname.new(__FILE__).realpath)
>
>     require 'rubygems'
>     require 'bundler/setup'
>
>     load Gem.bin_path('rake', 'rake')
>
> After doing some research on this I learned it's controversial, a surprise
> for Rails ;)
>
> Now that the dust has settled, what's the generally recommended approach?
> Keep the Rails-generated binstub for rake, and cronjobs that cd into the
> app directory, or go for a bundler-generated binstub (which presumably
> works from anywhere)?
>
> Thanks in advance,
>
> Andy Stewart
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org <javascript:;>
> Archives: http://lists.lrug.org/pipermail/chat-lrug.org
> Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org
> List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20141008/215f08f8/attachment-0003.html>


More information about the Chat mailing list