Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Tempfile.new #88

Merged

Conversation

jeremymv2
Copy link
Contributor

@jeremymv2 jeremymv2 commented Sep 1, 2016

Description

This PR fixes the call to Tempfile.new

Issues Resolved

Since Ruby 2.2.0 bundled in newer versions of chef-client, Tempfile.new errors with:

    ================================================================================
    Error executing action `fetch` on resource 'compliance_profile[linux]'
    ================================================================================

    ArgumentError
    -------------
    wrong number of arguments (given 3, expected 0..2)

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/audit/libraries/profile.rb:64:in `new'

This is because Tempfile.new has just ignored the 'wb+' option - not so any more.

https://bugs.ruby-lang.org/issues/10690

This PR fixes how the Tempfile object is instantiated.

As documented here: http://ruby-doc.org/stdlib-2.3.1/libdoc/tempfile/rdoc/Tempfile.html#method-c-new Tempfile.new will open the file with "w+" by default; then using bindmode=>true we get binary mode.

~/Devel/ChefProject/tmp$ ruby test_fileutils.rb

Frame number: 0/1

From: /Users/jmiller/Devel/ChefProject/tmp/test_fileutils.rb @ line 5 :

    1: require 'tempfile'
    2: require 'pry'
    3: tf = Tempfile.new('foo', Dir.tmpdir, :binmode => true)
    4: binding.pry
 => 5: puts tf

[1] pry(main)> tf.binmode?
=> true
[2] pry(main)> File.writable?(tf.path)
=> true
[3] pry(main)>

[List any existing issues this PR resolves]

Check List

@chris-rock chris-rock merged commit afbcd7e into chef-boneyard:master Sep 1, 2016
@iennae iennae removed the in progress label Sep 1, 2016
@chris-rock
Copy link
Contributor

Thanks @jeremymv2

@jeremymv2 jeremymv2 deleted the fix_wrong_number_of_arguments branch September 1, 2016 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants