rails/rails — pull request #4858 by aia (2012-02-03 05:31:40+00:00)
Title: Setting the RakeFileUtils.verbose_flag default to false

Running rake assets:precompile produces the following

rake assets:precompile
/Users/artem/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /Users/artem/.rvm/gems/ruby-1.9.3-p0@rails-edge/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets

There is an extra line showing a command that I did not ask for. Looks harmless.

However, when running from Capistrano the result is the following:

cap deploy
[snip]

* 21:16:28 == Currently executing `deploy:assets:precompile'
* executing "cd /home/rails/captest/releases/20120203051625 & & bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["192.168.147.17"]
[192.168.147.17] executing command
*** [err :: 192.168.147.17] /usr/bin/ruby /home/rails/captest/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: 192.168.147.17]

[snip]

The output comes out on stderr and Capistrano and automations built on Capistrano treat it as an error.

This small annoyance was big enough for me to actually find out why rake assets:precompile produces stderr output in a deployment mode.

The cause of this is the following commit to rake:
https://github.com/jimweirich/rake/commit/d383d953e1fe791422052dd1236dcf29255c09a6

By default FileUtilsExt.verbose_flag = DEFAULT = Object.new (not true/false/nil etc) which has the same effect as the default true.

Arguable, Rake's FileUtilsExt default verbose = on setting is there by design and it may be a reasonable default for Rake. However, verbose = on is not a reasonable default for Rails because of deployment tools that treat output on stderr as errors.

With the attached fix the behavior changes to the following:

$ rake assets:precompile
$ rake assets:precompile -v
/Users/artem/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /Users/artem/.rvm/gems/ruby-1.9.3-p0@rails-edge/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
$