{"action":"opened","number":11,"pull_request":{"url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/pulls/11","id":50516558,"html_url":"https://github.com/aripollak/rbenv-bundler-ruby-version/pull/11","diff_url":"https://github.com/aripollak/rbenv-bundler-ruby-version/pull/11.diff","patch_url":"https://github.com/aripollak/rbenv-bundler-ruby-version/pull/11.patch","issue_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/issues/11","number":11,"state":"open","locked":false,"title":"per shell RBENV_VERSION overrides Gemfile","user":{"login":"jasonkarns","id":119972,"avatar_url":"https://avatars.githubusercontent.com/u/119972?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonkarns","html_url":"https://github.com/jasonkarns","followers_url":"https://api.github.com/users/jasonkarns/followers","following_url":"https://api.github.com/users/jasonkarns/following{/other_user}","gists_url":"https://api.github.com/users/jasonkarns/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonkarns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonkarns/subscriptions","organizations_url":"https://api.github.com/users/jasonkarns/orgs","repos_url":"https://api.github.com/users/jasonkarns/repos","events_url":"https://api.github.com/users/jasonkarns/events{/privacy}","received_events_url":"https://api.github.com/users/jasonkarns/received_events","type":"User","site_admin":false},"body":"While it's true that at the time the `which` hooks run, RBENV_VERSION is *always* set (https://github.com/sstephenson/rbenv/blob/9e664b5d27cd7b2bdb94a9ec8ce55c32ebe1ad7a/libexec/rbenv-which#L36); the RBENV_VERSION is not exported. Which means that it is *not* set in any subshells.\n\nAnd it just so happens, that the `which` hook invokes rbenv-bundler-ruby-version in a subshell: https://github.com/aripollak/rbenv-bundler-ruby-version/blob/9e2320f570e770f4044a8d1f1e11ac3740d66451/etc/rbenv.d/which/bundler-ruby-version.bash#L1\n\nThis means that RBENV_VERSION is *not* set in the context of bin/rbenv-bundler-ruby-version, unless explicitly set by the user, which is precisely what we wish to detect.\n\nExample with this PR active:\n\n```\n$ head -2 Gemfile\nsource 'https://rubygems.org'\nruby '2.1.1'\n$ rbenv which ruby\n/usr/local/var/rbenv/versions/2.1.1/bin/ruby\n$ RBENV_VERSION=1.9.3\n$ rbenv which ruby\n/usr/local/var/rbenv/versions/2.1.1/bin/ruby\n$ RBENV_VERSION=1.9.3 rbenv which ruby\n/usr/local/var/rbenv/versions/1.9.3/bin/ruby\n$ rbenv which ruby\n/usr/local/var/rbenv/versions/2.1.1/bin/ruby\n$ rbenv shell 2.0.0\n$ rbenv which ruby\n/usr/local/var/rbenv/versions/2.0.0/bin/ruby\n$ rbenv shell --unset\n$ rbenv which ruby\n/usr/local/var/rbenv/versions/2.1.1/bin/ruby\n```","created_at":"2015-11-12T14:27:18Z","updated_at":"2015-11-12T14:27:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/pulls/11/commits","review_comments_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/pulls/11/comments","review_comment_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/issues/11/comments","statuses_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/statuses/5df36dc4c973460e24c65642344c8693b616059a","head":{"label":"jasonkarns:allow-overriding-by-shell","ref":"allow-overriding-by-shell","sha":"5df36dc4c973460e24c65642344c8693b616059a","user":{"login":"jasonkarns","id":119972,"avatar_url":"https://avatars.githubusercontent.com/u/119972?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonkarns","html_url":"https://github.com/jasonkarns","followers_url":"https://api.github.com/users/jasonkarns/followers","following_url":"https://api.github.com/users/jasonkarns/following{/other_user}","gists_url":"https://api.github.com/users/jasonkarns/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonkarns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonkarns/subscriptions","organizations_url":"https://api.github.com/users/jasonkarns/orgs","repos_url":"https://api.github.com/users/jasonkarns/repos","events_url":"https://api.github.com/users/jasonkarns/events{/privacy}","received_events_url":"https://api.github.com/users/jasonkarns/received_events","type":"User","site_admin":false},"repo":{"id":36412846,"name":"rbenv-bundler-ruby-version","full_name":"jasonkarns/rbenv-bundler-ruby-version","owner":{"login":"jasonkarns","id":119972,"avatar_url":"https://avatars.githubusercontent.com/u/119972?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonkarns","html_url":"https://github.com/jasonkarns","followers_url":"https://api.github.com/users/jasonkarns/followers","following_url":"https://api.github.com/users/jasonkarns/following{/other_user}","gists_url":"https://api.github.com/users/jasonkarns/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonkarns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonkarns/subscriptions","organizations_url":"https://api.github.com/users/jasonkarns/orgs","repos_url":"https://api.github.com/users/jasonkarns/repos","events_url":"https://api.github.com/users/jasonkarns/events{/privacy}","received_events_url":"https://api.github.com/users/jasonkarns/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jasonkarns/rbenv-bundler-ruby-version","description":"rbenv plugin to pick a ruby version from bundler's Gemfile","fork":true,"url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version","forks_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/forks","keys_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/teams","hooks_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/hooks","issue_events_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/issues/events{/number}","events_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/events","assignees_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/assignees{/user}","branches_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/branches{/branch}","tags_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/tags","blobs_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/git/refs{/sha}","trees_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/statuses/{sha}","languages_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/languages","stargazers_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/stargazers","contributors_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/contributors","subscribers_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/subscribers","subscription_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/subscription","commits_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/commits{/sha}","git_commits_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/git/commits{/sha}","comments_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/comments{/number}","issue_comment_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/issues/comments{/number}","contents_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/contents/{+path}","compare_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/merges","archive_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/downloads","issues_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/issues{/number}","pulls_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/pulls{/number}","milestones_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/milestones{/number}","notifications_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/labels{/name}","releases_url":"https://api.github.com/repos/jasonkarns/rbenv-bundler-ruby-version/releases{/id}","created_at":"2015-05-28T03:39:19Z","updated_at":"2015-05-28T03:39:19Z","pushed_at":"2015-11-12T14:27:10Z","git_url":"git://github.com/jasonkarns/rbenv-bundler-ruby-version.git","ssh_url":"git@github.com:jasonkarns/rbenv-bundler-ruby-version.git","clone_url":"https://github.com/jasonkarns/rbenv-bundler-ruby-version.git","svn_url":"https://github.com/jasonkarns/rbenv-bundler-ruby-version","homepage":"","size":91,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"aripollak:master","ref":"master","sha":"9e2320f570e770f4044a8d1f1e11ac3740d66451","user":{"login":"aripollak","id":451345,"avatar_url":"https://avatars.githubusercontent.com/u/451345?v=3","gravatar_id":"","url":"https://api.github.com/users/aripollak","html_url":"https://github.com/aripollak","followers_url":"https://api.github.com/users/aripollak/followers","following_url":"https://api.github.com/users/aripollak/following{/other_user}","gists_url":"https://api.github.com/users/aripollak/gists{/gist_id}","starred_url":"https://api.github.com/users/aripollak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aripollak/subscriptions","organizations_url":"https://api.github.com/users/aripollak/orgs","repos_url":"https://api.github.com/users/aripollak/repos","events_url":"https://api.github.com/users/aripollak/events{/privacy}","received_events_url":"https://api.github.com/users/aripollak/received_events","type":"User","site_admin":false},"repo":{"id":13020275,"name":"rbenv-bundler-ruby-version","full_name":"aripollak/rbenv-bundler-ruby-version","owner":{"login":"aripollak","id":451345,"avatar_url":"https://avatars.githubusercontent.com/u/451345?v=3","gravatar_id":"","url":"https://api.github.com/users/aripollak","html_url":"https://github.com/aripollak","followers_url":"https://api.github.com/users/aripollak/followers","following_url":"https://api.github.com/users/aripollak/following{/other_user}","gists_url":"https://api.github.com/users/aripollak/gists{/gist_id}","starred_url":"https://api.github.com/users/aripollak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aripollak/subscriptions","organizations_url":"https://api.github.com/users/aripollak/orgs","repos_url":"https://api.github.com/users/aripollak/repos","events_url":"https://api.github.com/users/aripollak/events{/privacy}","received_events_url":"https://api.github.com/users/aripollak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aripollak/rbenv-bundler-ruby-version","description":"rbenv plugin to pick a ruby version from bundler's Gemfile","fork":false,"url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version","forks_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/forks","keys_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/teams","hooks_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/hooks","issue_events_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/issues/events{/number}","events_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/events","assignees_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/assignees{/user}","branches_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/branches{/branch}","tags_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/tags","blobs_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/git/refs{/sha}","trees_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/statuses/{sha}","languages_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/languages","stargazers_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/stargazers","contributors_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/contributors","subscribers_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/subscribers","subscription_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/subscription","commits_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/commits{/sha}","git_commits_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/git/commits{/sha}","comments_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/comments{/number}","issue_comment_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/issues/comments{/number}","contents_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/contents/{+path}","compare_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/merges","archive_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/downloads","issues_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/issues{/number}","pulls_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/pulls{/number}","milestones_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/milestones{/number}","notifications_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/labels{/name}","releases_url":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/releases{/id}","created_at":"2013-09-22T20:20:57Z","updated_at":"2015-11-05T08:36:49Z","pushed_at":"2015-11-07T22:12:40Z","git_url":"git://github.com/aripollak/rbenv-bundler-ruby-version.git","ssh_url":"git@github.com:aripollak/rbenv-bundler-ruby-version.git","clone_url":"https://github.com/aripollak/rbenv-bundler-ruby-version.git","svn_url":"https://github.com/aripollak/rbenv-bundler-ruby-version","homepage":"","size":216,"stargazers_count":25,"watchers_count":25,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":1,"forks":5,"open_issues":1,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/pulls/11"},"html":{"href":"https://github.com/aripollak/rbenv-bundler-ruby-version/pull/11"},"issue":{"href":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/issues/11"},"comments":{"href":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/aripollak/rbenv-bundler-ruby-version/statuses/5df36dc4c973460e24c65642344c8693b616059a"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":3,"additions":30,"deletions":9,"changed_files":3}}