fix detecting GEM_HOME/bin at the end of PATH, fix #2154