Skip to content

fix: make build chmod cross-platform - #1187

Closed
fuentes71 wants to merge 1 commit into
mainfrom
fix/build-chmod-windows
Closed

fix: make build chmod cross-platform#1187
fuentes71 wants to merge 1 commit into
mainfrom
fix/build-chmod-windows

Conversation

@fuentes71

@fuentes71 fuentes71 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

O que a branch entrega

Torna o npm run build dos dois servidores MCP cross-platform. Hoje a chain termina em chmod +x build/index.js, comando que nao existe no Windows.

O problema

O tsc ja compilou quando a chain quebra, entao o build sai integro mas com exit 1. O artefato esta bom e o comando reporta falha.

Esse e o risco real, e nao e o build: um build que falha vermelho com artefato bom ensina todo mundo a ignorar o exit code, e a proxima falha de verdade passa batido. Em CI, significa que o job so nao quebra por sorte de plataforma.

A correcao

chmod +x build/index.js vira node -e "require('node:fs').chmodSync('build/index.js', 0o755)".

  • Sem dependencia nova. fs.chmodSync e stdlib. Descartei shx justamente por isso.
  • Seguro no Windows. Nao lanca, apenas nao tem efeito util, que e exatamente o comportamento desejado ali.
  • Preserva o Unix. Os dois fontes tem #!/usr/bin/env node no topo, entao o bit de execucao e intencional. Simplesmente remover o chmod teria trocado um bug barulhento por um silencioso.

Escopo

Corrigido nos dois servidores, egc-guardian e egc-memory, nao so onde o problema apareceu. O memory tinha a mesma linha e teria continuado quebrado.

Verificacao

npm run build com exit 0 nos dois servidores, no Windows, em cima desta base. Um diff de 2 linhas.

Fora de escopo, de proposito

Durante a investigacao o egc-memory falhava tambem com TS5108: moduleResolution=node10 has been removed. Confirmei que era staleness da base antiga: apos rebase na main atual, com a migracao do TypeScript 7 (#689) ja integrada, o erro nao ocorre mais. Nada a fazer aqui.

🤖 Generated with Claude Code


Summary by cubic

Make the MCP server build scripts cross-platform by replacing chmod +x with a Node fs.chmodSync call. Fixes Windows builds that compiled but exited with code 1.

  • Bug Fixes
    • Replaced chmod +x build/index.js with node -e "require('node:fs').chmodSync('build/index.js', 0o755)" in egc-guardian and egc-memory.
    • No new deps; uses Node stdlib.
    • Windows: no error, benign no-op. Unix: keeps exec bit for shebang.
    • Builds now exit 0 when tsc succeeds, avoiding false CI failures.

Written for commit 6d90c59. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved the build process to set executable permissions consistently across supported platforms.
    • Reduced reliance on platform-specific command-line utilities during builds.

@fuentes71
fuentes71 requested a review from Fmarzochi as a code owner August 4, 2026 12:28
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The build scripts for egc-guardian and egc-memory replace chmod +x with Node.js filesystem permission calls using mode 0o755.

Changes

Build permission handling

Layer / File(s) Summary
Node.js executable permission wiring
mcp/servers/egc-guardian/package.json, mcp/servers/egc-memory/package.json
The build scripts use Node.js filesystem calls to set build/index.js permissions to executable mode.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

Suggested reviewers: fmarzochi

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing platform-specific chmod with cross-platform Node.js fs.chmodSync in build scripts.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/build-chmod-windows

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

DCO sign-off missing

One or more commits in this PR are missing a Signed-off-by line (Developer Certificate of Origin).

How to fix:

# Single commit
git commit --amend -s
git push --force-with-lease

# Multiple commits -- replace N with the number of commits in your PR
git rebase --signoff HEAD~N
git push --force-with-lease

Note: This check is informational only -- a maintainer can still merge your PR without sign-off.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

O
pm run build dos dois servidores MCP terminava em chmod +x build/index.js,
que nao existe no Windows. O tsc ja tinha compilado quando a chain quebrava,
entao o build saia integro mas com exit 1. Esse e o problema real: o build
"falhando" com artefato bom treina a gente a ignorar o exit code, e ai a
proxima falha de verdade passa batido.

Trocado por
ode -e "require('node:fs').chmodSync(...)". Sem dependencia nova:
fs.chmodSync e stdlib e no Windows nao lanca, so nao tem efeito util, que e
exatamente o comportamento desejado. O shebang #!/usr/bin/env node continua nos
dois fontes, entao o bit de execucao segue sendo aplicado no Unix.

Corrigido nos DOIS servidores, nao so no guardian onde apareceu. O egc-memory
tinha a mesma linha e teria continuado quebrado.

Verificacao: egc-guardian roda ponta a ponta com exit 0. No egc-memory o tsc
para antes, por um bug independente e anterior a este commit (TS5108,
moduleResolution=node10 removido, porque node_modules tem typescript 7.0.2
enquanto o package.json declara ^5.3.3); ali o chmod foi validado isolado,
tambem exit 0. Esse bug de versao fica pra branch propria.

Signed-off-by: Matheus Fuentes <matheus.fu.p@hotmail.com>
@fuentes71
fuentes71 force-pushed the fix/build-chmod-windows branch from 768431a to 6d90c59 Compare August 4, 2026 13:10
@sonarqubecloud

sonarqubecloud Bot commented Aug 4, 2026

Copy link
Copy Markdown

@Fmarzochi

Copy link
Copy Markdown
Owner

@fuentes71 heads up: this branch started conflicting with main after the v1.1.18 release. A quick rebase and it is ready to move.

@Fmarzochi

Copy link
Copy Markdown
Owner

Closing this one with credit where it is due, @fuentes71: your diagnosis was exactly right, and the v1.1.18 release hardening shipped the same fix as a dedicated postbuild script (mcp/servers/*/scripts/postbuild.js). It skips the chmod on Windows and preserves the compiler file mode on Unix, so both servers build with exit 0 on every platform straight from main. Your branch predates that landing, so there is nothing left for it to change. If you can, pull main and confirm the Windows build on your machine; that confirmation is still valuable. And #1188 stays open waiting for your answer.

@Fmarzochi Fmarzochi closed this Aug 7, 2026
@Fmarzochi
Fmarzochi deleted the fix/build-chmod-windows branch August 7, 2026 04:24
@Fmarzochi Fmarzochi moved this to Done in EGC Roadmap Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants