{"action":"closed","issue":{"url":"https://api.github.com/repos/yyuu/pyenv/issues/420","labels_url":"https://api.github.com/repos/yyuu/pyenv/issues/420/labels{/name}","comments_url":"https://api.github.com/repos/yyuu/pyenv/issues/420/comments","events_url":"https://api.github.com/repos/yyuu/pyenv/issues/420/events","html_url":"https://github.com/yyuu/pyenv/issues/420","id":99468578,"number":420,"title":"Avoid dangling shims","user":{"login":"saj","id":194389,"avatar_url":"https://avatars.githubusercontent.com/u/194389?v=3","gravatar_id":"","url":"https://api.github.com/users/saj","html_url":"https://github.com/saj","followers_url":"https://api.github.com/users/saj/followers","following_url":"https://api.github.com/users/saj/following{/other_user}","gists_url":"https://api.github.com/users/saj/gists{/gist_id}","starred_url":"https://api.github.com/users/saj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saj/subscriptions","organizations_url":"https://api.github.com/users/saj/orgs","repos_url":"https://api.github.com/users/saj/repos","events_url":"https://api.github.com/users/saj/events{/privacy}","received_events_url":"https://api.github.com/users/saj/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-06T16:00:16Z","updated_at":"2015-08-15T02:01:21Z","closed_at":"2015-08-15T02:01:21Z","body":"The `python2` shim that pyenv installs can result in surprising (and undesirable) behaviour under some circumstances.\r\n\r\nGiven the following set of Python runtimes:\r\n\r\n    % pyenv versions\r\n    * system (set by /Users/saj/.pyenv/version)\r\n      2.7.10\r\n\r\n`pyenv rehash` will install shims for `python`, `python2`, and `python2.7`.\r\n\r\n    % ls ~/.pyenv/shims | egrep 'python[0-9\\.]*$'\r\n    python\r\n    python2\r\n    python2.7\r\n\r\nSuppose we leave system `python` enabled globally.\r\n\r\n    % pyenv global\r\n    system\r\n\r\nSystem `python` on my platform, OS X 10.10, is 2.7.6.\r\n\r\n    % /usr/bin/python -V\r\n    Python 2.7.6\r\n\r\nOS X provides `python` and `python2.7` files that link to this interpreter.  More importantly, OS X does *not* provide a `python2` link.\r\n\r\n    % pyenv which python\r\n    /usr/bin/python\r\n\r\n    % pyenv which python2.7\r\n    /usr/bin/python2.7\r\n\r\n    % pyenv which python2\r\n    pyenv: python2: command not found\r\n\r\n    The `python2' command exists in these Python versions:\r\n      2.7.10\r\n\r\nWith pyenv's shims loaded into my `PATH`, trying to invoke `python2` results in a failure:\r\n\r\n    % python2 -V\r\n    pyenv: python2: command not found\r\n\r\n    The `python2' command exists in these Python versions:\r\n      2.7.10\r\n\r\nThis causes obvious problems for software that probe for `python2` before `python`.  The [ycmd](https://github.com/Valloric/ycmd/) code completion server is one such example:\r\n\r\nhttps://github.com/Valloric/ycmd/blob/master/ycmd/utils.py#L154\r\n\r\nThe problem can be worked-around by manually symlinking `/usr/bin/python2` to `/usr/bin/python`, though this is rather smelly.\r\n\r\nI take it the shims are built from the set union of all installed Python versions.  Because I have 2.7.10 installed, pyenv found `python2` in my 2.7.10 `bin/` directory and created the `python2` shim to match.\r\n\r\nWhy is this search based on the set of *installed* runtimes and not the set of *activated* runtimes?  (Would it make more sense to rehash after `pyenv global` instead of `pyenv install`?)\r\n\r\nhttps://github.com/yyuu/pyenv/blob/8e276a009e592724ae9804cff328baee3a23df20/README.md#choosing-the-python-version\r\n\r\n    % pyenv global system 2.7.10\r\n\r\n    % pyenv global\r\n    system\r\n    2.7.10\r\n\r\n    % python -V\r\n    Python 2.7.6\r\n\r\n    % python2 -V\r\n    Python 2.7.10\r\n\r\n    % python2.7 -V\r\n    Python 2.7.6\r\n"}}