{"action":"created","issue":{"url":"https://api.github.com/repos/bundler/bundler/issues/4044","labels_url":"https://api.github.com/repos/bundler/bundler/issues/4044/labels{/name}","comments_url":"https://api.github.com/repos/bundler/bundler/issues/4044/comments","events_url":"https://api.github.com/repos/bundler/bundler/issues/4044/events","html_url":"https://github.com/bundler/bundler/pull/4044","id":110240152,"number":4044,"title":"Handle odd encoding cases in bundler path setup.","user":{"login":"samphippen","id":96662,"avatar_url":"https://avatars.githubusercontent.com/u/96662?v=3","gravatar_id":"","url":"https://api.github.com/users/samphippen","html_url":"https://github.com/samphippen","followers_url":"https://api.github.com/users/samphippen/followers","following_url":"https://api.github.com/users/samphippen/following{/other_user}","gists_url":"https://api.github.com/users/samphippen/gists{/gist_id}","starred_url":"https://api.github.com/users/samphippen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samphippen/subscriptions","organizations_url":"https://api.github.com/users/samphippen/orgs","repos_url":"https://api.github.com/users/samphippen/repos","events_url":"https://api.github.com/users/samphippen/events{/privacy}","received_events_url":"https://api.github.com/users/samphippen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-07T14:38:59Z","updated_at":"2015-12-12T06:53:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bundler/bundler/pulls/4044","html_url":"https://github.com/bundler/bundler/pull/4044","diff_url":"https://github.com/bundler/bundler/pull/4044.diff","patch_url":"https://github.com/bundler/bundler/pull/4044.patch"},"body":"This patch is motivated by [vagrant\r\n5475](https://github.com/mitchellh/vagrant/issues/5475)\r\n\r\nOn some windows systems, the value of `ENV[\"PATH\"]` is encoded with\r\n`windows-1251`, while the filesystem returns `utf-8` encoded strings for\r\nfile paths. During bundler setup it manipulates the path, but\r\nunfortunately this can potentially raise an\r\n`Encoding::CompatabilityError`.\r\n\r\nConsider a `windows-1251` encoded path:\r\n\r\n```ruby\r\n[209].pack(\"c*\").force_encoding(\"windows-1251\")\r\n```\r\n\r\nIf the bundler path contains characters which are not valid in the\r\nwindows-1251 encoding:\r\n\r\n```\r\n\"💕\"\r\n```\r\n\r\nthen this [code\r\nfragment](https://github.com/bundler/bundler/blob/21b1e3b6ff0f4fc9ff7ffeaded1fefdd42bcf8eb/lib/bundler/shared_helpers.rb#L78-L80)\r\nwill raise the `Encoding::CompatabilityError`.\r\n\r\nA reproduction example of this (which works on OS X and linux) can be\r\nfound in [this\r\ngist](https://gist.github.com/samphippen/85ed7a568d7475d50fa4). It's\r\npretty weird, but to explain, it basically stubs `ENV[\"PATH\"]` and\r\n`Bundler.bundle_path` to reproduce the error.\r\n\r\nWith the patch contained in this commit we circumvent the problem by\r\nmapping each string in `ENV[\"PATH\"]` with the UTF-8 encoding. This only\r\nhappens if an exception is raised and seems to fix my reproduction case."},"comment":{"url":"https://api.github.com/repos/bundler/bundler/issues/comments/164115752","html_url":"https://github.com/bundler/bundler/pull/4044#issuecomment-164115752","issue_url":"https://api.github.com/repos/bundler/bundler/issues/4044","id":164115752,"user":{"login":"indirect","id":78,"avatar_url":"https://avatars.githubusercontent.com/u/78?v=3","gravatar_id":"","url":"https://api.github.com/users/indirect","html_url":"https://github.com/indirect","followers_url":"https://api.github.com/users/indirect/followers","following_url":"https://api.github.com/users/indirect/following{/other_user}","gists_url":"https://api.github.com/users/indirect/gists{/gist_id}","starred_url":"https://api.github.com/users/indirect/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/indirect/subscriptions","organizations_url":"https://api.github.com/users/indirect/orgs","repos_url":"https://api.github.com/users/indirect/repos","events_url":"https://api.github.com/users/indirect/events{/privacy}","received_events_url":"https://api.github.com/users/indirect/received_events","type":"User","site_admin":false},"created_at":"2015-12-12T06:53:38Z","updated_at":"2015-12-12T06:53:38Z","body":"@samphippen ping, do you need anything else to get this passing?"}}