Repository: pyenv-win/pyenv-win (language: python)

Issue:
bug: pyenv rehash giving error
**Describe the bug**
I followed the windows install instructions and get the following error when I run `pyenv rehash` :
`~\.pyenv\pyenv-win\libexec\pyenv.vbs(0, 1) Microsoft VBScript runtime error: Path not found`

`pyenv --version` and `pyenv commands` both seem to work fine

**To Reproduce**
Steps to reproduce the behavior:
1. Use Git Bash to clone pyenv-win
2. Use PowerShell to execute the first three steps in the 'Finish the installation' section in the README
4. run `pyenv rehash`

**Expected behavior**
not an error message

**Desktop (please complete the following information):**
 - OS: Windows 10 Pro version 1909
 - git bash, command prompt

**Additional context**
Add any other context about the problem here.



Discussion / hints:
Please be more specific about the steps to reproduce the issue.
No need to run `pyenv rehash` anymore since shims are automatically
generated after python installations.
Have you installed any python version?


Fix patch:
diff --git a/pyenv-win/libexec/libs/pyenv-lib.vbs b/pyenv-win/libexec/libs/pyenv-lib.vbs
index 241cd706..696774ed 100644
--- a/pyenv-win/libexec/libs/pyenv-lib.vbs
+++ b/pyenv-win/libexec/libs/pyenv-lib.vbs
@@ -175,12 +175,14 @@ Function GetInstalledVersions()
     ' WScript.echo "kkotari: pyenv-lib.vbs get installed versions..!"
     Dim rootBinDir, winBinDir, version, versions()
     ReDim Preserve versions(0)
-    Set rootBinDir = objfs.GetFolder(strDirVers)
-    For Each winBinDir in rootBinDir.SubFolders
-        version = winBinDir.Name
-        ReDim Preserve versions(UBound(versions) + 1)
-        versions(UBound(versions)) = version
-    Next
+    If objfs.FolderExists(strDirVers) Then
+        Set rootBinDir = objfs.GetFolder(strDirVers)
+        For Each winBinDir in rootBinDir.SubFolders
+            version = winBinDir.Name
+            ReDim Preserve versions(UBound(versions) + 1)
+            versions(UBound(versions)) = version
+        Next
+    End If
     GetInstalledVersions = versions
 End Function
 
diff --git a/pyenv-win/libexec/pyenv.vbs b/pyenv-win/libexec/pyenv.vbs
index 998a26c1..87059797 100644
--- a/pyenv-win/libexec/pyenv.vbs
+++ b/pyenv-win/libexec/pyenv.vbs
@@ -322,7 +322,17 @@ End Sub
 
 Sub CommandRehash(arg)
     ' WScript.echo "kkotari: pyenv.vbs command rehash..!"
-    Rehash
+    If arg.Count >= 2 Then
+        If arg(1) = "--help" Then PrintHelp "pyenv-rehash", 0
+    End If
+
+    Dim versions
+    versions = GetInstalledVersions()
+    If UBound(versions) = 0 Then
+        WScript.Echo "No version installed. Please install one with 'pyenv install <version>'."
+    Else
+        Rehash
+    End If
 End Sub
 
 Sub CommandGlobal(arg)


Test patch:
diff --git a/tests/test_pyenv_feature_rehash.py b/tests/test_pyenv_feature_rehash.py
index a74fa3b9..6fbaad4b 100644
--- a/tests/test_pyenv_feature_rehash.py
+++ b/tests/test_pyenv_feature_rehash.py
@@ -16,6 +16,11 @@ def assert_shims(pyenv_path, ver):
 
 
 class TestPyenvFeatureRehash(TestPyenvBase):
+    def test_rehash_no_version(self, setup):
+        def commands(ctx):
+            assert ctx.pyenv('rehash') == "No version installed. Please install one with 'pyenv install <version>'."
+        run_pyenv_test({}, commands)
+
     def test_rehash_global_version(self, setup):
         def commands(ctx):
             assert ctx.pyenv('rehash') == ""