Issue #7958 has been updated by trans (Thomas Sawyer).


=begin
It's b/c of Module Inclusion Problem. StreamUtils_ is included into FileUtils and FileUtils is included in FileUtils::Verbose. So one would expect it to work, but b/c the later include is done first, StreamUtils_ only actually makes it as far as FileUtils.

The simplest solution is probably to move lines 90-125 from the top of the file to the bottom. But that's unfortunate b/c it would make the code less readable. 

Eric's patch can work but it might need to add `extend StreamUtils_` as well, in order to fully work.

Taking a moment to think about this more in depth, it becomes clear this will be a problem if anyone ever wants to extend FileUtils with some other module (for whatever reason). So perhaps a more robust solution would be to work around the module include problem altogether with an included callback, e.g.

    module FileUtils
      def self.included(mod)
        Verbose.send(:include, mod)
        NoWrite.send(:include, mod)
        DryRun.send(:include, mod)

        # re-extend self
        extend self
        Verbose.send(:extend, Verbose)
        NoWrite.send(:extend, NoWrite)
        DryRun.send(:extend, DryRun)
      end
    end

See any problems with that approach?
=end

----------------------------------------
Bug #7958: include FileUtils::Verbose gives NoMethodError when installing files with a different mode
https://bugs.ruby-lang.org/issues/7958#change-37099

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: lib
Target version: current: 2.1.0
ruby -v: ruby 2.1.0dev (2013-02-26 trunk 39490) [x86_64-darwin12.2.1]


=begin
Seems like (({fu_stream_blksize})) isn't included when (({FileUtils::Verbose})) is.  Changing to plain FileUtils works, though.

  $ cat test.rb 
  require 'fileutils'
  require 'tmpdir'
  
  include FileUtils::Verbose
  
  Dir.mktmpdir 'test' do |dir|
    install __FILE__, dir, mode: 0600
    install __FILE__, dir, mode: 0640
  end
  
  $ ~/.rubies/trunk/bin/ruby -v test.rb 
  ruby 2.1.0dev (2013-02-26 trunk 39490) [x86_64-darwin12.2.1]
  install -c -m 0600 test.rb /var/folders/87/twjsm89x01161gp5d9qwlx2m0000gn/T/test20130225-53176-197q6me
  install -c -m 0640 test.rb /var/folders/87/twjsm89x01161gp5d9qwlx2m0000gn/T/test20130225-53176-197q6me
  /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:898:in `compare_stream': undefined method `fu_stream_blksize' for main:Object (NoMethodError)
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:882:in `block (2 levels) in compare_file'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:881:in `open'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:881:in `block in compare_file'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:880:in `open'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:880:in `compare_file'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:926:in `block in install'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:1620:in `block in fu_each_src_dest'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:1633:in `fu_each_src_dest0'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:1618:in `fu_each_src_dest'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:925:in `install'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/fileutils.rb:137:in `install'
  	from test.rb:8:in `block in <main>'
  	from /Users/drbrain/.rubies/trunk/lib/ruby/2.1.0/tmpdir.rb:88:in `mktmpdir'
  	from test.rb:6:in `<main>'
=end



-- 
http://bugs.ruby-lang.org/