{"action":"created","issue":{"url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/373","labels_url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/373/labels{/name}","comments_url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/373/comments","events_url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/373/events","html_url":"https://github.com/sdkman/sdkman-cli/pull/373","id":110804672,"number":373,"title":"Dynamically reinitialize sdkman","user":{"login":"calid","id":494405,"avatar_url":"https://avatars.githubusercontent.com/u/494405?v=3","gravatar_id":"","url":"https://api.github.com/users/calid","html_url":"https://github.com/calid","followers_url":"https://api.github.com/users/calid/followers","following_url":"https://api.github.com/users/calid/following{/other_user}","gists_url":"https://api.github.com/users/calid/gists{/gist_id}","starred_url":"https://api.github.com/users/calid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calid/subscriptions","organizations_url":"https://api.github.com/users/calid/orgs","repos_url":"https://api.github.com/users/calid/repos","events_url":"https://api.github.com/users/calid/events{/privacy}","received_events_url":"https://api.github.com/users/calid/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-10T16:44:59Z","updated_at":"2015-10-13T09:56:23Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sdkman/sdkman-cli/pulls/373","html_url":"https://github.com/sdkman/sdkman-cli/pull/373","diff_url":"https://github.com/sdkman/sdkman-cli/pull/373.diff","patch_url":"https://github.com/sdkman/sdkman-cli/pull/373.patch"},"body":"The current init logic using the SDKMAN_INIT flag is fragile and can break if the PATH is modified/reset, but SDKMAN_INIT is still set to true.  In that case re-sourcing sdkman_init.sh is not sufficient, and it's necessary to also unset SDKMAN_INIT.  I added a test case for this scenario.\r\n\r\nThis patch changes the init logic to dynamically check if a candidate is on the PATH, instead of relying on storing state in a flag.  If a candidate is not on the PATH it will be prefixed.  This should resolve both #251 and #299."},"comment":{"url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/comments/147667623","html_url":"https://github.com/sdkman/sdkman-cli/pull/373#issuecomment-147667623","issue_url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/373","id":147667623,"user":{"login":"calid","id":494405,"avatar_url":"https://avatars.githubusercontent.com/u/494405?v=3","gravatar_id":"","url":"https://api.github.com/users/calid","html_url":"https://github.com/calid","followers_url":"https://api.github.com/users/calid/followers","following_url":"https://api.github.com/users/calid/following{/other_user}","gists_url":"https://api.github.com/users/calid/gists{/gist_id}","starred_url":"https://api.github.com/users/calid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calid/subscriptions","organizations_url":"https://api.github.com/users/calid/orgs","repos_url":"https://api.github.com/users/calid/repos","events_url":"https://api.github.com/users/calid/events{/privacy}","received_events_url":"https://api.github.com/users/calid/received_events","type":"User","site_admin":false},"created_at":"2015-10-13T09:56:23Z","updated_at":"2015-10-13T09:56:23Z","body":"> However, would it be possible to explain under what circumstances the path breaks? When will the candidate not be on the path?\r\n\r\nAny time the path is reinitialized or modified.  Re-sourcing sdkman-init.sh is not sufficient and the SDKMAN_INIT flag needs to be manually unset.\r\n\r\n```\r\ncalid@xen ~\r\n[✔]▶ which groovy\r\n/home/calid/.sdkman/groovy/current/bin/groovy\r\n\r\ncalid@xen ~\r\n[✔]▶ tail -3 ~/.bashrc\r\necho RE-SOURCING SDKMAN\r\nexport SDKMAN_DIR=\"/home/calid/.sdkman\"\r\n[[ -s \"/home/calid/.sdkman/bin/sdkman-init.sh\" ]] && source \"/home/calid/.sdkman/bin/sdkman-init.sh\"\r\n\r\ncalid@xen ~\r\n[✔]▶ exec bash --login\r\nRE-SOURCING SDKMAN\r\n\r\ncalid@xen ~\r\n[✔]▶ which groovy\r\n\r\ncalid@xen ~\r\n[✘]▶ \r\n\r\ncalid@xen ~\r\n[✘]▶ unset SDKMAN_INIT\r\n\r\ncalid@xen ~\r\n[✔]▶ exec bash --login\r\nRE-SOURCING SDKMAN\r\n\r\ncalid@xen ~\r\n[✔]▶ which groovy\r\n/home/calid/.sdkman/groovy/current/bin/groovy\r\n\r\ncalid@xen ~\r\n[✔]▶\r\n```\r\n\r\n> Do you see it happen often?\r\n\r\nYes, quite often.  Because I use tmux (which creates a login shell by default) sdkman breaks both as soon as I launch tmux and anytime I create a new tmux window or pane.  This makes sdkman basically unusable for me out of the box.\r\n\r\nBoth #251 and #299 are also for the same problem with terminal multiplexers.  However as the example above demonstrates, this is not just a terminal multiplexer problem (though it's most annoying there), and manifests anytime the user changes or reinitializes their shell or path."}}