summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extension/package-lock.json4
-rw-r--r--extension/package.json2
-rw-r--r--extension/src/activation/environmentSetup.ts99
3 files changed, 63 insertions, 42 deletions
diff --git a/extension/package-lock.json b/extension/package-lock.json
index b86cb10e..f1423041 100644
--- a/extension/package-lock.json
+++ b/extension/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "continue",
- "version": "0.0.172",
+ "version": "0.0.173",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "continue",
- "version": "0.0.172",
+ "version": "0.0.173",
"license": "Apache-2.0",
"dependencies": {
"@electron/rebuild": "^3.2.10",
diff --git a/extension/package.json b/extension/package.json
index 6b719723..0638e768 100644
--- a/extension/package.json
+++ b/extension/package.json
@@ -14,7 +14,7 @@
"displayName": "Continue",
"pricing": "Free",
"description": "The open-source coding autopilot",
- "version": "0.0.172",
+ "version": "0.0.173",
"publisher": "Continue",
"engines": {
"vscode": "^1.67.0"
diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts
index 7a0d24d4..928fe04b 100644
--- a/extension/src/activation/environmentSetup.ts
+++ b/extension/src/activation/environmentSetup.ts
@@ -53,6 +53,7 @@ async function retryThenFail(
break;
}
} finally {
+ console.log("After retries, failed to set up Continue extension", msg);
vscode.window.showErrorMessage(msg);
}
@@ -232,57 +233,77 @@ async function getLinuxAptInstallError(pythonCmd: string) {
return `[Important] Continue needs to create a Python virtual environment, but python3.${version}-venv is not installed. Please run this command in your terminal: \`${installVenvCommand}\`, reload VS Code, and then try again.`;
}
-async function setupPythonEnv() {
- console.log("Setting up python env for Continue extension...");
-
- const [pythonCmd, pipCmd] = await getPythonPipCommands();
- const [activateCmd, pipUpgradeCmd] = getActivateUpgradeCommands(
- pythonCmd,
- pipCmd
- );
+async function createPythonVenv(pythonCmd: string) {
+ if (checkEnvExists()) {
+ console.log("Python env already exists, skipping...");
+ } else {
+ // Assemble the command to create the env
+ const createEnvCommand = [
+ `cd "${serverPath()}"`,
+ `${pythonCmd} -m venv env`,
+ ].join(" ; ");
- await retryThenFail(async () => {
- // First, create the virtual environment
- if (checkEnvExists()) {
- console.log("Python env already exists, skipping...");
+ const [stdout, stderr] = await runCommand(createEnvCommand);
+ if (
+ stderr &&
+ stderr.includes("running scripts is disabled on this system")
+ ) {
+ console.log("Scripts disabled error when trying to create env");
+ await vscode.window.showErrorMessage(WINDOWS_REMOTE_SIGNED_SCRIPTS_ERROR);
+ throw new Error(stderr);
+ } else if (
+ stderr?.includes("On Debian/Ubuntu systems") ||
+ stdout?.includes("On Debian/Ubuntu systems")
+ ) {
+ const msg = await getLinuxAptInstallError(pythonCmd);
+ console.log(msg);
+ await vscode.window.showErrorMessage(msg);
+ } else if (checkEnvExists()) {
+ console.log("Successfully set up python env at ", `${serverPath()}/env`);
} else {
- // Assemble the command to create the env
- const createEnvCommand = [
- `cd "${serverPath()}"`,
- `${pythonCmd} -m venv env`,
- ].join(" ; ");
-
- const [stdout, stderr] = await runCommand(createEnvCommand);
- if (
- stderr &&
- stderr.includes("running scripts is disabled on this system")
- ) {
- await vscode.window.showErrorMessage(
- WINDOWS_REMOTE_SIGNED_SCRIPTS_ERROR
- );
- throw new Error(stderr);
- } else if (
- stderr?.includes("On Debian/Ubuntu systems") ||
- stdout?.includes("On Debian/Ubuntu systems")
- ) {
- const msg = await getLinuxAptInstallError(pythonCmd);
- console.log(msg);
- await vscode.window.showErrorMessage(msg);
- } else if (checkEnvExists()) {
- console.log(
- "Successfully set up python env at ",
- `${serverPath()}/env`
+ try {
+ // This might mean that another window is currently using the python.exe file to install requirements
+ // So we want to wait and try again
+ let i = 0;
+ await new Promise((resolve, reject) =>
+ setInterval(() => {
+ if (i > 5) {
+ reject();
+ }
+ if (checkEnvExists()) {
+ resolve(null);
+ } else {
+ console.log("Waiting for other window to create env...");
+ }
+ i++;
+ }, 5000)
);
- } else {
+ } catch (e) {
const msg = [
"Python environment not successfully created. Trying again. Here was the stdout + stderr: ",
`stdout: ${stdout}`,
`stderr: ${stderr}`,
+ `e: ${e}`,
].join("\n\n");
console.log(msg);
throw new Error(msg);
}
}
+ }
+}
+
+async function setupPythonEnv() {
+ console.log("Setting up python env for Continue extension...");
+
+ const [pythonCmd, pipCmd] = await getPythonPipCommands();
+ const [activateCmd, pipUpgradeCmd] = getActivateUpgradeCommands(
+ pythonCmd,
+ pipCmd
+ );
+
+ await retryThenFail(async () => {
+ // First, create the virtual environment
+ await createPythonVenv(pythonCmd);
// Install the requirements
if (await checkRequirementsInstalled()) {