summaryrefslogtreecommitdiff
path: root/extension/src/activation
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-07-15 17:57:51 -0700
committerNate Sesti <sestinj@gmail.com>2023-07-15 17:57:51 -0700
commit1c41fb0a803c886841dbea9fa5e4129059a32e5d (patch)
treef8f57c26b11f80b85a1e0057ce140961b5449b11 /extension/src/activation
parent21dc20871347165a8526bbbea1d351e2f10f4d93 (diff)
downloadsncontinue-1c41fb0a803c886841dbea9fa5e4129059a32e5d.tar.gz
sncontinue-1c41fb0a803c886841dbea9fa5e4129059a32e5d.tar.bz2
sncontinue-1c41fb0a803c886841dbea9fa5e4129059a32e5d.zip
patch
Diffstat (limited to 'extension/src/activation')
-rw-r--r--extension/src/activation/environmentSetup.ts92
1 files changed, 51 insertions, 41 deletions
diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts
index b4ada632..be1c220c 100644
--- a/extension/src/activation/environmentSetup.ts
+++ b/extension/src/activation/environmentSetup.ts
@@ -21,11 +21,16 @@ async function retryThenFail(
): Promise<any> {
try {
if (retries < MAX_RETRIES && process.platform === "win32") {
- const [stdout, stderr] = await runCommand(
- "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser"
- );
- console.log("Execution policy stdout: ", stdout);
- console.log("Execution policy stderr: ", stderr);
+ let [stdout, stderr] = await runCommand("Get-ExecutionPolicy");
+ if (!stdout.includes("RemoteSigned")) {
+ [stdout, stderr] = await runCommand(
+ "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser"
+ );
+ console.log("Execution policy stdout: ", stdout);
+ console.log("Execution policy stderr: ", stderr);
+ // Then reload the window for this to take effect
+ await vscode.commands.executeCommand("workbench.action.reloadWindow");
+ }
}
return await fn();
@@ -238,45 +243,50 @@ async function setupPythonEnv() {
pipCmd
);
- // First, create the virtual environment
- 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(" ; ");
-
- 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`);
+ await retryThenFail(async () => {
+ // First, create the virtual environment
+ if (checkEnvExists()) {
+ console.log("Python env already exists, skipping...");
} else {
- const msg = [
- "Python environment not successfully created. Trying again. Here was the stdout + stderr: ",
- `stdout: ${stdout}`,
- `stderr: ${stderr}`,
- ].join("\n\n");
- console.log(msg);
- throw new Error(msg);
+ // 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`
+ );
+ } else {
+ const msg = [
+ "Python environment not successfully created. Trying again. Here was the stdout + stderr: ",
+ `stdout: ${stdout}`,
+ `stderr: ${stderr}`,
+ ].join("\n\n");
+ console.log(msg);
+ throw new Error(msg);
+ }
}
- }
- // Install the requirements
- await retryThenFail(async () => {
+ // Install the requirements
if (await checkRequirementsInstalled()) {
console.log("Python requirements already installed, skipping...");
} else {