{"action":"opened","issue":{"url":"https://api.github.com/repos/chef/chef/issues/4189","labels_url":"https://api.github.com/repos/chef/chef/issues/4189/labels{/name}","comments_url":"https://api.github.com/repos/chef/chef/issues/4189/comments","events_url":"https://api.github.com/repos/chef/chef/issues/4189/events","html_url":"https://github.com/chef/chef/issues/4189","id":117948012,"number":4189,"title":"ArgumentError: invalid byte sequence in UTF-8 when using knife diff on binary files","user":{"login":"matschaffer","id":690,"avatar_url":"https://avatars.githubusercontent.com/u/690?v=3","gravatar_id":"","url":"https://api.github.com/users/matschaffer","html_url":"https://github.com/matschaffer","followers_url":"https://api.github.com/users/matschaffer/followers","following_url":"https://api.github.com/users/matschaffer/following{/other_user}","gists_url":"https://api.github.com/users/matschaffer/gists{/gist_id}","starred_url":"https://api.github.com/users/matschaffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matschaffer/subscriptions","organizations_url":"https://api.github.com/users/matschaffer/orgs","repos_url":"https://api.github.com/users/matschaffer/repos","events_url":"https://api.github.com/users/matschaffer/events{/privacy}","received_events_url":"https://api.github.com/users/matschaffer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-20T01:41:19Z","updated_at":"2015-11-20T01:41:19Z","closed_at":null,"body":"### Version:\r\n11.18.12\r\n\r\n### Environment: OS X, ruby 1.9.3 via rvm\r\n\r\n### Scenario:\r\n\r\nDiff cookbooks that may contain binary files\r\n\r\n### Steps to Reproduce:\r\n\r\n`knife diff cookbooks/a_cookbook_containing_a_binary`\r\n\r\nUsing OS X `.DS_Store` files seem especially likely to cause the error\r\n\r\n### Expected Result:\r\n\r\nSome sort of non-crash diff report (e.g., \"Binary files X and Y differ\")\r\n\r\n### Actual Result:\r\n\r\n`ERROR: ArgumentError: invalid byte sequence in UTF-8`\r\n\r\n### Notes\r\n\r\nThe problematic code seems to still be [here in `Chef::ChefFS::CommandLine.diff_text`](https://github.com/chef/chef/blob/master/lib/chef/chef_fs/command_line.rb#L263) in master.\r\n\r\n`new_value` and `old_value` come in as strings with specific encodings (ASCII-8BIT in the case of binary files). The values then get written out to files, then read back in [here in `Chef::Util::Diff#udiff`](https://github.com/chef/chef/blob/master/lib/chef/util/diff.rb#L92) but without and encoding option. `IO.readlines` then appears to default to UTF-8."}}