From 0b553ac68dccc824142c2a2811604a5957e4f252 Mon Sep 17 00:00:00 2001 From: Rahul Vyas Date: Mon, 26 Jan 2026 00:20:08 +0530 Subject: [PATCH 1/8] Add Miniconda installation and initialization to setup script --- scripts/setup.ps1 | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index c96da9953..b2d4c8bb1 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -112,6 +112,38 @@ if (-not (Test-Command cmake)) { Write-Host "CMake is already installed. Version: $(cmake --version)" -ForegroundColor Green } +# -------------------------------------------------- +# Miniconda +# -------------------------------------------------- +$condaRoot = "$env:USERPROFILE\miniconda3" +$condaExe = "$condaRoot\Scripts\conda.exe" + +if (-not (Test-Path $condaExe)) { + Write-Host "Installing Miniconda..." -ForegroundColor Yellow + $installer = "$env:TEMP\miniconda.exe" + Invoke-WebRequest ` + -Uri "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" ` + -OutFile $installer + + Start-Process -Wait -FilePath $installer -ArgumentList ` + "/InstallationType=JustMe", + "/AddToPath=0", + "/RegisterPython=0", + "/S", + "/D=$condaRoot" + + Remove-Item $installer +} + +# -------------------------------------------------- +# Initialize Conda (THIS WAS MISSING BEFORE) +# -------------------------------------------------- +$env:Path = "$condaRoot;$condaRoot\Scripts;$condaRoot\condabin;$env:Path" + +$condaBase = & $condaExe info --base +& "$condaBase\shell\condabin\conda-hook.ps1" + + # ---- Set up the frontend ---- Write-Host "Setting up frontend..." -ForegroundColor Yellow try { @@ -134,13 +166,14 @@ try { Set-Location .\backend\ # Create virtual environment - python -m venv .env + conda remove -n backend_env --all -y 2>$null + conda create -n backend_env python=3.12 -y # Activate virtual environment and install dependencies - .\.env\Scripts\Activate.ps1 + conda activate backend_env python -m pip install --upgrade pip python -m pip install -r requirements.txt - deactivate + conda deactivate Set-Location .. @@ -156,13 +189,14 @@ try { Set-Location .\sync-microservice\ # Create virtual environment - python -m venv .sync-env + conda remove -n sync_env --all -y 2>$null + conda create -n sync_env python=3.12 -y # Activate virtual environment and install dependencies - .\.sync-env\Scripts\Activate.ps1 + conda activate sync_env python -m pip install --upgrade pip python -m pip install -r requirements.txt - deactivate + conda deactivate Set-Location .. From f44ee308ffd02e5ef8558b15006b30a366c580a6 Mon Sep 17 00:00:00 2001 From: Rahul Vyas Date: Mon, 26 Jan 2026 00:41:39 +0530 Subject: [PATCH 2/8] Refactor Conda environment setup for backend and sync-microservice to handle errors and improve clarity --- scripts/setup.ps1 | 79 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index b2d4c8bb1..aacf0d6ab 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -163,20 +163,37 @@ try { # ---- Set up the backend using Python 3.12 ---- Write-Host "Setting up backend..." -ForegroundColor Yellow try { - Set-Location .\backend\ - - # Create virtual environment - conda remove -n backend_env --all -y 2>$null + + Set-Location .\backend\ + + Write-Host "Setting up backend Conda environment..." -ForegroundColor Cyan + + # Remove existing environment (ignore if it does not exist) + conda remove -n backend_env --all -y + if ($LASTEXITCODE -ne 0) { + Write-Host "Environment did not exist or could not be removed, continuing..." -ForegroundColor Yellow + } + + # Create fresh environment conda create -n backend_env python=3.12 -y - - # Activate virtual environment and install dependencies - conda activate backend_env - python -m pip install --upgrade pip - python -m pip install -r requirements.txt - conda deactivate - + if ($LASTEXITCODE -ne 0) { + throw "Failed to create Conda environment" + } + + # Upgrade pip inside the environment + conda run -n backend_env python -m pip install --upgrade pip + if ($LASTEXITCODE -ne 0) { + throw "Failed to upgrade pip inside Conda environment" + } + + # Install backend dependencies + conda run -n backend_env python -m pip install -r requirements.txt + if ($LASTEXITCODE -ne 0) { + throw "Failed to install backend dependencies" + } + Set-Location .. - + Write-Host "Backend setup completed successfully." -ForegroundColor Green } catch { Write-Host "Error setting up backend: $_" -ForegroundColor Red @@ -188,18 +205,34 @@ Write-Host "Setting up sync-microservice..." -ForegroundColor Yellow try { Set-Location .\sync-microservice\ - # Create virtual environment - conda remove -n sync_env --all -y 2>$null - conda create -n sync_env python=3.12 -y - - # Activate virtual environment and install dependencies - conda activate sync_env - python -m pip install --upgrade pip - python -m pip install -r requirements.txt - conda deactivate - + Write-Host "Setting up sync-microservice Conda environment..." -ForegroundColor Cyan + + # Remove existing environment (ignore if it does not exist) + conda remove -n sync_env --all -y + if ($LASTEXITCODE -ne 0) { + Write-Host "Environment did not exist or could not be removed, continuing..." -ForegroundColor Yellow + } + + # Create fresh environment + conda create -n sync_env python=3.12 -y + if ($LASTEXITCODE -ne 0) { + throw "Failed to create Conda environment for sync-microservice" + } + + # Upgrade pip inside the environment + conda run -n sync_env python -m pip install --upgrade pip + if ($LASTEXITCODE -ne 0) { + throw "Failed to upgrade pip in sync_env" + } + + # Install dependencies inside the environment + conda run -n sync_env python -m pip install -r requirements.txt + if ($LASTEXITCODE -ne 0) { + throw "Failed to install sync-microservice dependencies" + } + Set-Location .. - + Write-Host "Sync-microservice setup completed successfully." -ForegroundColor Green } catch { Write-Host "Error setting up sync-microservice: $_" -ForegroundColor Red From 68f6ae7d5346f1f7c68fed4f894224efb377918c Mon Sep 17 00:00:00 2001 From: Rahul Vyas Date: Mon, 26 Jan 2026 00:56:09 +0530 Subject: [PATCH 3/8] Enhance Miniconda installation process with error handling and validation --- scripts/setup.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index aacf0d6ab..42f8d029a 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -125,6 +125,10 @@ if (-not (Test-Path $condaExe)) { -Uri "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" ` -OutFile $installer + if ($LASTEXITCODE -ne 0 -or !(Test-Path $installerPath)) { + throw "Failed to download Miniconda installer" + } + Start-Process -Wait -FilePath $installer -ArgumentList ` "/InstallationType=JustMe", "/AddToPath=0", @@ -132,7 +136,21 @@ if (-not (Test-Path $condaExe)) { "/S", "/D=$condaRoot" + if ($LASTEXITCODE -ne 0) { + throw "Miniconda installer exited with an error" + } + Remove-Item $installer + + # Validate installation + if (-not (Test-Path $condaExe)) { + throw "Conda executable not found after Miniconda installation" + } + + Write-Host "Miniconda installed successfully." -ForegroundColor Green +} +else { + Write-Host "Miniconda already installed. Skipping installation." -ForegroundColor Green } # -------------------------------------------------- From a2f24d7072bc5432fa994f85403dd65f6cb10c1c Mon Sep 17 00:00:00 2001 From: Rahul Vyas Date: Mon, 26 Jan 2026 01:01:41 +0530 Subject: [PATCH 4/8] Fix Miniconda installer download path check in setup script --- scripts/setup.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index 42f8d029a..1bc4e500a 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -125,7 +125,7 @@ if (-not (Test-Path $condaExe)) { -Uri "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" ` -OutFile $installer - if ($LASTEXITCODE -ne 0 -or !(Test-Path $installerPath)) { + if ($LASTEXITCODE -ne 0 -or !(Test-Path $installer)) { throw "Failed to download Miniconda installer" } From eb0b5afef0225e6467361b013a7095c354c3e905 Mon Sep 17 00:00:00 2001 From: Rahul Vyas Date: Mon, 26 Jan 2026 01:23:55 +0530 Subject: [PATCH 5/8] Refactor Miniconda installer invocation to streamline argument handling and improve error reporting --- scripts/setup.ps1 | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index 1bc4e500a..dd226ad34 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -129,15 +129,10 @@ if (-not (Test-Path $condaExe)) { throw "Failed to download Miniconda installer" } - Start-Process -Wait -FilePath $installer -ArgumentList ` - "/InstallationType=JustMe", - "/AddToPath=0", - "/RegisterPython=0", - "/S", - "/D=$condaRoot" - - if ($LASTEXITCODE -ne 0) { - throw "Miniconda installer exited with an error" + $installerArgs = "/InstallationType=JustMe /AddToPath=0 /RegisterPython=0 /S /D=$condaRoot" + & $installer $installerArgs + if ($LASTEXITCODE -ne 0) { + throw "Miniconda installer failed with exit code $LASTEXITCODE" } Remove-Item $installer From b8c28ac3f842c497ad0a2141a90d4964ea45cdb6 Mon Sep 17 00:00:00 2001 From: Rahul Vyas Date: Wed, 11 Feb 2026 12:27:04 +0530 Subject: [PATCH 6/8] updating conda command to retain consistency --- scripts/setup.ps1 | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index dd226ad34..719be8704 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -182,29 +182,33 @@ try { Write-Host "Setting up backend Conda environment..." -ForegroundColor Cyan # Remove existing environment (ignore if it does not exist) - conda remove -n backend_env --all -y + conda remove -p .env --all -y if ($LASTEXITCODE -ne 0) { Write-Host "Environment did not exist or could not be removed, continuing..." -ForegroundColor Yellow } # Create fresh environment - conda create -n backend_env python=3.12 -y + conda create -p .env python=3.12 if ($LASTEXITCODE -ne 0) { throw "Failed to create Conda environment" } + conda activate .\.env + # Upgrade pip inside the environment - conda run -n backend_env python -m pip install --upgrade pip + python -m pip install --upgrade pip if ($LASTEXITCODE -ne 0) { throw "Failed to upgrade pip inside Conda environment" } # Install backend dependencies - conda run -n backend_env python -m pip install -r requirements.txt + pip install -r requirements.txt if ($LASTEXITCODE -ne 0) { throw "Failed to install backend dependencies" } - + + # Deactivate environment after setup + conda deactivate Set-Location .. Write-Host "Backend setup completed successfully." -ForegroundColor Green @@ -221,29 +225,32 @@ try { Write-Host "Setting up sync-microservice Conda environment..." -ForegroundColor Cyan # Remove existing environment (ignore if it does not exist) - conda remove -n sync_env --all -y + conda remove -p .sync-env --all -y if ($LASTEXITCODE -ne 0) { Write-Host "Environment did not exist or could not be removed, continuing..." -ForegroundColor Yellow } # Create fresh environment - conda create -n sync_env python=3.12 -y + conda create -p .sync-env python=3.12 if ($LASTEXITCODE -ne 0) { throw "Failed to create Conda environment for sync-microservice" } + conda activate .\.sync-env + # Upgrade pip inside the environment - conda run -n sync_env python -m pip install --upgrade pip + python -m pip install --upgrade pip if ($LASTEXITCODE -ne 0) { throw "Failed to upgrade pip in sync_env" } # Install dependencies inside the environment - conda run -n sync_env python -m pip install -r requirements.txt + conda install -r requirements.txt if ($LASTEXITCODE -ne 0) { throw "Failed to install sync-microservice dependencies" } - + # Deactivate environment after setup + conda deactivate Set-Location .. Write-Host "Sync-microservice setup completed successfully." -ForegroundColor Green From 95722dd9c7579e258c2896fc7964f7ad73f8b547 Mon Sep 17 00:00:00 2001 From: Rahul Vyas Date: Wed, 11 Feb 2026 12:44:22 +0530 Subject: [PATCH 7/8] updating requirement installation cmd in synv-env --- scripts/setup.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index 719be8704..8b34bcbc9 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -245,7 +245,7 @@ try { } # Install dependencies inside the environment - conda install -r requirements.txt + pip install -r requirements.txt if ($LASTEXITCODE -ne 0) { throw "Failed to install sync-microservice dependencies" } From 898d6cb9d175a5be3996e35373c4d78c1fec71b6 Mon Sep 17 00:00:00 2001 From: Rahul Vyas Date: Tue, 17 Feb 2026 15:49:52 +0530 Subject: [PATCH 8/8] Add Conda paths to USER environment variables if missing --- scripts/setup.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index 8b34bcbc9..f74b184a8 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -148,6 +148,16 @@ else { Write-Host "Miniconda already installed. Skipping installation." -ForegroundColor Green } +# Permanently add Conda to USER environment PATH if missing +$currentMachinePath = [System.Environment]::GetEnvironmentVariable("Path", "Machine") +if ($currentMachinePath -notlike "*$condaRoot*") { + $newMachinePath = "$currentMachinePath;$condaRoot;$condaRoot\Scripts;$condaRoot\condabin" + [System.Environment]::SetEnvironmentVariable("Path", $newMachinePath, "Machine") + Write-Host "Conda paths added permanently to MACHINE environment variables." -ForegroundColor Green +} else { + Write-Host "Conda paths already exist in MACHINE environment variables." -ForegroundColor Green +} + # -------------------------------------------------- # Initialize Conda (THIS WAS MISSING BEFORE) # --------------------------------------------------