diff --git a/src/contributes/commandsBase.ts b/src/contributes/commandsBase.ts index a41db38..6500daf 100644 --- a/src/contributes/commandsBase.ts +++ b/src/contributes/commandsBase.ts @@ -31,7 +31,13 @@ export function checkDevChatDependency(pythonCommand: string, showError: boolean try { // Check if DevChat is installed - runCommand(`"${devChat}" --help`); + const expectVersion = 'DevChat 0.1.15'; + const devchatVersion = runCommand(`"${devChat}" --version`).toString().trim(); + if (devchatVersion < expectVersion) { + logger.channel()?.info("devchat version: ${devchatVersion}, but expect version: ${expectVersion}"); + return false; + } + logger.channel()?.info("devchat has installed.") return true; } catch(error) { diff --git a/src/util/uiUtil_vscode.ts b/src/util/uiUtil_vscode.ts index 92f5819..41fcf52 100644 --- a/src/util/uiUtil_vscode.ts +++ b/src/util/uiUtil_vscode.ts @@ -20,6 +20,7 @@ export class UiUtilVscode implements UiUtil { public async updateConfiguration(key1: string, key2: string, value: string): Promise { await vscode.workspace.getConfiguration(key1).update(key2, value, vscode.ConfigurationTarget.Global); + await vscode.workspace.getConfiguration(key1).update(key2, value, vscode.ConfigurationTarget.Workspace); } public async secretStorageGet(key: string): Promise { try { diff --git a/tools/install.py b/tools/install.py index aa16245..f75d363 100644 --- a/tools/install.py +++ b/tools/install.py @@ -89,23 +89,23 @@ def pip_install_devchat(pythoncmd): # if not, install devchat # first step: check if devchat is installed - try: - # before command run, output runnning command - print("run command: ", pythoncmd, "-m", "pip", "show", "devchat") - subprocess.run([pythoncmd, "-m", "pip", "show", "devchat"], check=True, stdout=sys.stdout, stderr=sys.stderr, text=True) + # try: + # # before command run, output runnning command + # print("run command: ", pythoncmd, "-m", "pip", "show", "devchat") + # subprocess.run([pythoncmd, "-m", "pip", "show", "devchat"], check=True, stdout=sys.stdout, stderr=sys.stderr, text=True) - pipCommandEnv = pythoncmd.replace("/python", "/devchat") - print("==> devchatCommandEnv: ", pipCommandEnv) + # pipCommandEnv = pythoncmd.replace("/python", "/devchat") + # print("==> devchatCommandEnv: ", pipCommandEnv) - return True - except Exception as error: - # devchat is not installed - print('devchat is not installed') - print(error) - pass + # return True + # except Exception as error: + # # devchat is not installed + # print('devchat is not installed') + # print(error) + # pass # second step: install devchat - if (pip_cmd_with_retries([pythoncmd, "-m", "pip", "install", "devchat"], 3, False)): + if (pip_cmd_with_retries([pythoncmd, "-m", "pip", "install", "devchat", "--force"], 3, False)): pip_command_env = pythoncmd.replace("/python", "/devchat") print("==> devchatCommandEnv: ", pip_command_env) return True