{"action":"created","issue":{"url":"https://api.github.com/repos/rubygems/rubygems/issues/1135","labels_url":"https://api.github.com/repos/rubygems/rubygems/issues/1135/labels{/name}","comments_url":"https://api.github.com/repos/rubygems/rubygems/issues/1135/comments","events_url":"https://api.github.com/repos/rubygems/rubygems/issues/1135/events","html_url":"https://github.com/rubygems/rubygems/pull/1135","id":54021903,"number":1135,"title":"Don't treat inaccessible working directories as build failures.","user":{"login":"pete","id":3936,"avatar_url":"https://avatars.githubusercontent.com/u/3936?v=3","gravatar_id":"","url":"https://api.github.com/users/pete","html_url":"https://github.com/pete","followers_url":"https://api.github.com/users/pete/followers","following_url":"https://api.github.com/users/pete/following{/other_user}","gists_url":"https://api.github.com/users/pete/gists{/gist_id}","starred_url":"https://api.github.com/users/pete/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pete/subscriptions","organizations_url":"https://api.github.com/users/pete/orgs","repos_url":"https://api.github.com/users/pete/repos","events_url":"https://api.github.com/users/pete/events{/privacy}","received_events_url":"https://api.github.com/users/pete/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rubygems/rubygems/labels/status+-+feedback","name":"status - feedback","color":"02d7e1"},{"url":"https://api.github.com/repos/rubygems/rubygems/labels/type+-+feature","name":"type - feature","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rubygems/rubygems/milestones/12","labels_url":"https://api.github.com/repos/rubygems/rubygems/milestones/12/labels","id":720820,"number":12,"title":"2.5","description":"","creator":{"login":"drbrain","id":9831,"avatar_url":"https://avatars.githubusercontent.com/u/9831?v=3","gravatar_id":"","url":"https://api.github.com/users/drbrain","html_url":"https://github.com/drbrain","followers_url":"https://api.github.com/users/drbrain/followers","following_url":"https://api.github.com/users/drbrain/following{/other_user}","gists_url":"https://api.github.com/users/drbrain/gists{/gist_id}","starred_url":"https://api.github.com/users/drbrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drbrain/subscriptions","organizations_url":"https://api.github.com/users/drbrain/orgs","repos_url":"https://api.github.com/users/drbrain/repos","events_url":"https://api.github.com/users/drbrain/events{/privacy}","received_events_url":"https://api.github.com/users/drbrain/received_events","type":"User","site_admin":false},"open_issues":33,"closed_issues":59,"state":"open","created_at":"2014-07-14T20:05:36Z","updated_at":"2015-01-20T23:50:14Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2015-01-12T05:31:15Z","updated_at":"2015-01-20T23:57:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rubygems/rubygems/pulls/1135","html_url":"https://github.com/rubygems/rubygems/pull/1135","diff_url":"https://github.com/rubygems/rubygems/pull/1135.diff","patch_url":"https://github.com/rubygems/rubygems/pull/1135.patch"},"body":"If the user installing the gem does not have access to the directory\r\nwhere the `gem install` command is run (which is common for sudo(1),\r\nfor example) then extensions will build correctly, but will then report\r\na build failure when trying to return to the previous working directory\r\nraises an exception.  This fixes the bug by returning to a fallback\r\ndirectory if we can't return to the original one.\r\n\r\nAn example is probably clearer:\r\n\r\n```sh\r\nmkdir /tmp/test\r\nchmod 700 /tmp/test\r\ncd /tmp/test\r\nsudo -u $a_non_root_user gem install sqlite3\r\n```\r\n\r\n(Although a non-root user is easier to demonstrate, this happened to me\r\nwhile installing a gem as root from a working directory that happed to\r\nbe inside a FUSE filesystem that root couldn't see.)\r\n\r\nIn this case, rubygems will compile sqlite3's extensions correctly, and\r\nthen try to return to the previous working directory, which will raise\r\nan Errno::EACCES, which will trigger the rescue block that is intended\r\nto report build failures.  This patch bounces back to dest_dir in that\r\ncase, which allows installation to proceed as normal."},"comment":{"url":"https://api.github.com/repos/rubygems/rubygems/issues/comments/70759614","html_url":"https://github.com/rubygems/rubygems/pull/1135#issuecomment-70759614","issue_url":"https://api.github.com/repos/rubygems/rubygems/issues/1135","id":70759614,"user":{"login":"pete","id":3936,"avatar_url":"https://avatars.githubusercontent.com/u/3936?v=3","gravatar_id":"","url":"https://api.github.com/users/pete","html_url":"https://github.com/pete","followers_url":"https://api.github.com/users/pete/followers","following_url":"https://api.github.com/users/pete/following{/other_user}","gists_url":"https://api.github.com/users/pete/gists{/gist_id}","starred_url":"https://api.github.com/users/pete/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pete/subscriptions","organizations_url":"https://api.github.com/users/pete/orgs","repos_url":"https://api.github.com/users/pete/repos","events_url":"https://api.github.com/users/pete/events{/privacy}","received_events_url":"https://api.github.com/users/pete/received_events","type":"User","site_admin":false},"created_at":"2015-01-20T23:57:31Z","updated_at":"2015-01-20T23:57:31Z","body":"Do you mean it's better to rescue Errno::EACCES directly?  I figured that, should the chdir fail for whatever reason (permissions in this case, but disappearing mountpoint, etc.), it's better to be somewhere than nowhere and to report that as a failure to build the extension.  Or did you mean something else?  Happy to make whatever changes."}}