From 6da6c1a8a34ffc732bad53bead83c844f20b09b1 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Sun, 5 Apr 2026 01:56:14 +0530 Subject: [PATCH 1/8] fixed merger error --- tools/install/install.ps1 | 2 -- website/docs/public/install.ps1 | 60 ++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/tools/install/install.ps1 b/tools/install/install.ps1 index 94a86dd4..1cb715a4 100644 --- a/tools/install/install.ps1 +++ b/tools/install/install.ps1 @@ -118,8 +118,6 @@ function Detect-Architecture { $env:PROCESSOR_ARCHITECTURE } - Write-Host "Detected architecture: $arch" - # Check if supported switch ($arch) { "x86_64" { return "x86_64" } # Supported diff --git a/website/docs/public/install.ps1 b/website/docs/public/install.ps1 index a551ae78..1cb715a4 100644 --- a/website/docs/public/install.ps1 +++ b/website/docs/public/install.ps1 @@ -32,7 +32,8 @@ function Say-Green { param([string]$Message) if (Use-Color) { Write-Host $Message -ForegroundColor Green - } else { + } + else { Write-Host $Message } } @@ -41,7 +42,8 @@ function Say-Red { param([string]$Message) if (Use-Color) { Write-Host $Message -ForegroundColor Red - } else { + } + else { Write-Host $Message } } @@ -105,11 +107,22 @@ function Get-RequestHeaders { # --- Platform detection --- function Detect-Architecture { - $arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture + # Detect architecture from environment variable + $arch = if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") { + "x86_64" + } + elseif ($env:PROCESSOR_ARCHITECTURE -eq "x86") { + "x86" + } + else { + $env:PROCESSOR_ARCHITECTURE + } + + # Check if supported switch ($arch) { - "X64" { return "x86_64" } + "x86_64" { return "x86_64" } # Supported default { - Fail-Installer "error: Unsupported architecture: $arch`n meshc currently supports x86_64 (64-bit) Windows only." + Fail-Installer "error: Unsupported architecture: $arch`nmeshc currently supports x86_64 (64-bit) Windows only." } } } @@ -120,7 +133,8 @@ function Get-LatestVersion { $releaseApiUrl = Get-ReleaseApiUrl try { $release = Invoke-RestMethod -Uri $releaseApiUrl -Headers (Get-RequestHeaders) -TimeoutSec (Get-DownloadTimeoutSec) - } catch { + } + catch { Fail-Installer "error: Failed to fetch release metadata.`n URL: $releaseApiUrl" } @@ -195,7 +209,8 @@ function Invoke-MeshDownload { try { Invoke-WebRequest -Uri $Url -OutFile $OutFile -Headers (Get-RequestHeaders) -TimeoutSec (Get-DownloadTimeoutSec) | Out-Null - } catch { + } + catch { Fail-Installer "$FailureMessage`n URL: $Url`n timeout: $(Get-DownloadTimeoutSec)s" } } @@ -244,7 +259,8 @@ function Install-Binary { try { Invoke-WebRequest -Uri $checksumUrl -OutFile $checksumPath -Headers (Get-RequestHeaders) -TimeoutSec (Get-DownloadTimeoutSec) | Out-Null - } catch { + } + catch { if (Test-StrictProofMode) { Fail-Installer "error: Could not download SHA256SUMS in staged-proof mode.`n URL: $checksumUrl`n timeout: $(Get-DownloadTimeoutSec)s" } @@ -258,9 +274,11 @@ function Install-Binary { Fail-Installer "error: SHA256SUMS contained a malformed checksum for $archive.`n checksum file: $checksumPath`n checksum URL: $checksumUrl" } Say "warning: Malformed SHA256SUMS entry for $archive, skipping verification." - } elseif ($expectedHash) { + } + elseif ($expectedHash) { Verify-Checksum -FilePath $archivePath -Expected $expectedHash - } else { + } + else { if (Test-StrictProofMode) { Fail-Installer "error: SHA256SUMS did not contain $archive.`n checksum file: $checksumPath`n checksum URL: $checksumUrl" } @@ -271,7 +289,8 @@ function Install-Binary { $extractDir = Join-Path $tmpDir 'extracted' try { Expand-Archive -Path $archivePath -DestinationPath $extractDir -Force - } catch { + } + catch { Fail-Installer "error: Failed to extract $archive.`n archive: $archivePath" } @@ -283,7 +302,8 @@ function Install-Binary { New-Item -ItemType Directory -Path $BinDir -Force | Out-Null Copy-Item -Path $sourceBinary.FullName -Destination (Join-Path $BinDir "$BinaryName.exe") -Force $success = $true - } finally { + } + finally { if ($success -and (Test-Path $tmpDir)) { Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue } @@ -318,14 +338,21 @@ function Invoke-Install { if (-not $userPath -or $userPath -notlike "*$BinDir*") { if ($userPath) { [Environment]::SetEnvironmentVariable('Path', "$BinDir;$userPath", 'User') - } else { + } + else { [Environment]::SetEnvironmentVariable('Path', $BinDir, 'User') } } + # Update PATH for current session + if ($env:Path -notlike "*$BinDir*") { + $env:Path = "$BinDir;$env:Path" + } + Say-Green "Installed meshc and meshpkg v$RequestedVersion to ~\.mesh\bin\" - Say "Run 'meshc --version' and 'meshpkg --version' to verify, or restart your terminal." - } catch { + Say "Run 'meshc --version' and 'meshpkg --version' to verify." + } + catch { Show-ErrorMessage $_.Exception.Message exit 1 } @@ -354,6 +381,7 @@ if ($Help) { if ($Uninstall) { Invoke-Uninstall -} else { +} +else { Invoke-Install -RequestedVersion $Version } From ee815b2951d3c5a1d116b2a72b4bbb7a821cf774 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Sun, 5 Apr 2026 02:17:02 +0530 Subject: [PATCH 2/8] Added fallback and error message to generate:og script --- website/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/package.json b/website/package.json index 6b3d2fec..147d19ae 100644 --- a/website/package.json +++ b/website/package.json @@ -7,7 +7,7 @@ "dev": "vitepress dev docs", "build": "vitepress build docs", "preview": "vitepress preview docs", - "generate:og": "python3 scripts/generate-og-image.py" + "generate:og": "python3 scripts/generate-og-image.py || (echo Python is not installed. Please install it from https://www.python.org/downloads/ and try again. && exit 1)" }, "keywords": [], "author": "", @@ -31,4 +31,4 @@ "@types/node": "^25.2.3", "typescript": "^5.9.3" } -} +} \ No newline at end of file From 4c690c3f61c89535275cda5afbd5b6caece02ef4 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Mon, 6 Apr 2026 02:04:05 +0530 Subject: [PATCH 3/8] fixed meshc only detects runtime in hardcoded paths --- compiler/mesh-codegen/src/link.rs | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/compiler/mesh-codegen/src/link.rs b/compiler/mesh-codegen/src/link.rs index f5d3cae1..0726c99f 100644 --- a/compiler/mesh-codegen/src/link.rs +++ b/compiler/mesh-codegen/src/link.rs @@ -200,6 +200,14 @@ pub(crate) fn link_with_plan( /// profiles. Prefers the profile matching the compiler's own build: a release /// `meshc` links the release runtime, a debug `meshc` links the debug runtime. fn find_mesh_rt(target: &LinkTarget) -> Result { + // ✅ ENV override (highest priority) + if let Ok(path) = std::env::var("MESH_RT_PATH") { + let path = PathBuf::from(path); + if path.exists() { + return Ok(path); + } + } + let profiles: &[&str] = if cfg!(debug_assertions) { &["debug", "release"] } else { @@ -217,6 +225,49 @@ fn find_mesh_rt(target: &LinkTarget) -> Result { } } + // NEW: fallback directories + let mut extra_dirs: Vec = Vec::new(); + + // ~/.mesh/lib + if let Some(home) = std::env::var_os("HOME") { + extra_dirs.push(PathBuf::from(home).join(".mesh/lib")); + } + + // current working directory + if let Ok(current) = std::env::current_dir() { + extra_dirs.push(current); + } + + // directory of meshc binary + if let Ok(exe) = std::env::current_exe() { + if let Some(parent) = exe.parent() { + extra_dirs.push(parent.to_path_buf()); + } + } + + // search fallback dirs + for dir in extra_dirs { + // check profile-based structure + for profile in profiles { + let candidate = dir.join(profile).join(target.runtime_filename()); + + if candidate.exists() { + return Ok(candidate); + } + + searched_paths.push(candidate); + } + + // check direct file + let direct = dir.join(target.runtime_filename()); + if direct.exists() { + return Ok(direct); + } + + searched_paths.push(direct); + } + + // error message (unchanged) let mut message = format!( "Could not locate Mesh runtime static library for target '{}'. Expected {}. Run `cargo build -p mesh-rt{}` first.", target.display_triple(), From e5127153697d981728356984e66bdf5664633a36 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Mon, 6 Apr 2026 02:09:45 +0530 Subject: [PATCH 4/8] fixed meshc only detects runtime in hardcoded paths --- compiler/mesh-codegen/src/link.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/mesh-codegen/src/link.rs b/compiler/mesh-codegen/src/link.rs index 0726c99f..cfda8b92 100644 --- a/compiler/mesh-codegen/src/link.rs +++ b/compiler/mesh-codegen/src/link.rs @@ -200,7 +200,7 @@ pub(crate) fn link_with_plan( /// profiles. Prefers the profile matching the compiler's own build: a release /// `meshc` links the release runtime, a debug `meshc` links the debug runtime. fn find_mesh_rt(target: &LinkTarget) -> Result { - // ✅ ENV override (highest priority) + // ENV override (highest priority) if let Ok(path) = std::env::var("MESH_RT_PATH") { let path = PathBuf::from(path); if path.exists() { From 51ff580ffe254e30512ba211feb95a3e9ab3a8a8 Mon Sep 17 00:00:00 2001 From: Rahul Kumar <157830731+rcodyp@users.noreply.github.com> Date: Mon, 6 Apr 2026 03:12:32 +0530 Subject: [PATCH 5/8] Add additional parameters to install script --- website/docs/public/install.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/public/install.ps1 b/website/docs/public/install.ps1 index 1cb715a4..13817ada 100644 --- a/website/docs/public/install.ps1 +++ b/website/docs/public/install.ps1 @@ -9,6 +9,7 @@ param( [switch]$Help ) + $ErrorActionPreference = 'Stop' $Repo = "snowdamiz/mesh-lang" From 220504bdfeb4e567b38c42bcfe470a4887603368 Mon Sep 17 00:00:00 2001 From: Rahul Kumar <157830731+rcodyp@users.noreply.github.com> Date: Mon, 6 Apr 2026 03:13:22 +0530 Subject: [PATCH 6/8] Remove empty line in install.ps1 --- website/docs/public/install.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/website/docs/public/install.ps1 b/website/docs/public/install.ps1 index 13817ada..1cb715a4 100644 --- a/website/docs/public/install.ps1 +++ b/website/docs/public/install.ps1 @@ -9,7 +9,6 @@ param( [switch]$Help ) - $ErrorActionPreference = 'Stop' $Repo = "snowdamiz/mesh-lang" From 8d81c44c3586735336b67c9f915e510d1eca6619 Mon Sep 17 00:00:00 2001 From: Rahul Kumar <157830731+rcodyp@users.noreply.github.com> Date: Mon, 6 Apr 2026 03:37:39 +0530 Subject: [PATCH 7/8] Refactor architecture detection in install.ps1 --- tools/install/install.ps1 | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tools/install/install.ps1 b/tools/install/install.ps1 index c272924b..a551ae78 100644 --- a/tools/install/install.ps1 +++ b/tools/install/install.ps1 @@ -105,18 +105,7 @@ function Get-RequestHeaders { # --- Platform detection --- function Detect-Architecture { - # Detect architecture from environment variable - $arch = if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") { - "x86_64" - } - elseif ($env:PROCESSOR_ARCHITECTURE -eq "x86") { - "x86" - } - else { - $env:PROCESSOR_ARCHITECTURE - } - - # Check if supported + $arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture switch ($arch) { "X64" { return "x86_64" } default { From 5a5eec5bfd25a39ff5448ea8578f5df30dfceb24 Mon Sep 17 00:00:00 2001 From: Rahul Kumar <157830731+rcodyp@users.noreply.github.com> Date: Mon, 6 Apr 2026 03:38:23 +0530 Subject: [PATCH 8/8] Refactor error handling and architecture detection --- website/docs/public/install.ps1 | 60 +++++++++------------------------ 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/website/docs/public/install.ps1 b/website/docs/public/install.ps1 index 1cb715a4..a551ae78 100644 --- a/website/docs/public/install.ps1 +++ b/website/docs/public/install.ps1 @@ -32,8 +32,7 @@ function Say-Green { param([string]$Message) if (Use-Color) { Write-Host $Message -ForegroundColor Green - } - else { + } else { Write-Host $Message } } @@ -42,8 +41,7 @@ function Say-Red { param([string]$Message) if (Use-Color) { Write-Host $Message -ForegroundColor Red - } - else { + } else { Write-Host $Message } } @@ -107,22 +105,11 @@ function Get-RequestHeaders { # --- Platform detection --- function Detect-Architecture { - # Detect architecture from environment variable - $arch = if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") { - "x86_64" - } - elseif ($env:PROCESSOR_ARCHITECTURE -eq "x86") { - "x86" - } - else { - $env:PROCESSOR_ARCHITECTURE - } - - # Check if supported + $arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture switch ($arch) { - "x86_64" { return "x86_64" } # Supported + "X64" { return "x86_64" } default { - Fail-Installer "error: Unsupported architecture: $arch`nmeshc currently supports x86_64 (64-bit) Windows only." + Fail-Installer "error: Unsupported architecture: $arch`n meshc currently supports x86_64 (64-bit) Windows only." } } } @@ -133,8 +120,7 @@ function Get-LatestVersion { $releaseApiUrl = Get-ReleaseApiUrl try { $release = Invoke-RestMethod -Uri $releaseApiUrl -Headers (Get-RequestHeaders) -TimeoutSec (Get-DownloadTimeoutSec) - } - catch { + } catch { Fail-Installer "error: Failed to fetch release metadata.`n URL: $releaseApiUrl" } @@ -209,8 +195,7 @@ function Invoke-MeshDownload { try { Invoke-WebRequest -Uri $Url -OutFile $OutFile -Headers (Get-RequestHeaders) -TimeoutSec (Get-DownloadTimeoutSec) | Out-Null - } - catch { + } catch { Fail-Installer "$FailureMessage`n URL: $Url`n timeout: $(Get-DownloadTimeoutSec)s" } } @@ -259,8 +244,7 @@ function Install-Binary { try { Invoke-WebRequest -Uri $checksumUrl -OutFile $checksumPath -Headers (Get-RequestHeaders) -TimeoutSec (Get-DownloadTimeoutSec) | Out-Null - } - catch { + } catch { if (Test-StrictProofMode) { Fail-Installer "error: Could not download SHA256SUMS in staged-proof mode.`n URL: $checksumUrl`n timeout: $(Get-DownloadTimeoutSec)s" } @@ -274,11 +258,9 @@ function Install-Binary { Fail-Installer "error: SHA256SUMS contained a malformed checksum for $archive.`n checksum file: $checksumPath`n checksum URL: $checksumUrl" } Say "warning: Malformed SHA256SUMS entry for $archive, skipping verification." - } - elseif ($expectedHash) { + } elseif ($expectedHash) { Verify-Checksum -FilePath $archivePath -Expected $expectedHash - } - else { + } else { if (Test-StrictProofMode) { Fail-Installer "error: SHA256SUMS did not contain $archive.`n checksum file: $checksumPath`n checksum URL: $checksumUrl" } @@ -289,8 +271,7 @@ function Install-Binary { $extractDir = Join-Path $tmpDir 'extracted' try { Expand-Archive -Path $archivePath -DestinationPath $extractDir -Force - } - catch { + } catch { Fail-Installer "error: Failed to extract $archive.`n archive: $archivePath" } @@ -302,8 +283,7 @@ function Install-Binary { New-Item -ItemType Directory -Path $BinDir -Force | Out-Null Copy-Item -Path $sourceBinary.FullName -Destination (Join-Path $BinDir "$BinaryName.exe") -Force $success = $true - } - finally { + } finally { if ($success -and (Test-Path $tmpDir)) { Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue } @@ -338,21 +318,14 @@ function Invoke-Install { if (-not $userPath -or $userPath -notlike "*$BinDir*") { if ($userPath) { [Environment]::SetEnvironmentVariable('Path', "$BinDir;$userPath", 'User') - } - else { + } else { [Environment]::SetEnvironmentVariable('Path', $BinDir, 'User') } } - # Update PATH for current session - if ($env:Path -notlike "*$BinDir*") { - $env:Path = "$BinDir;$env:Path" - } - Say-Green "Installed meshc and meshpkg v$RequestedVersion to ~\.mesh\bin\" - Say "Run 'meshc --version' and 'meshpkg --version' to verify." - } - catch { + Say "Run 'meshc --version' and 'meshpkg --version' to verify, or restart your terminal." + } catch { Show-ErrorMessage $_.Exception.Message exit 1 } @@ -381,7 +354,6 @@ if ($Help) { if ($Uninstall) { Invoke-Uninstall -} -else { +} else { Invoke-Install -RequestedVersion $Version }