fix: resolve 3 failing tests in installer and uninstall scripts#779
Conversation
📝 WalkthroughWalkthroughAdjusted install and uninstall script privilege checks: Changes
Sequence Diagram(s)sequenceDiagram
participant Installer as "install.sh"
participant NPM as "npm config"
participant FS as Filesystem
participant SUDO as sudo
Installer->>NPM: npm config get prefix
NPM-->>Installer: PREFIX
Installer->>FS: is PREFIX non-empty?
FS-->>Installer: yes / no
Installer->>FS: is PREFIX writable by user?
FS-->>Installer: yes / no
alt PREFIX writable or empty or user is root
Installer->>FS: run npm link (no sudo)
FS-->>Installer: link result
else PREFIX not writable & user not root
Installer->>SUDO: sudo npm link
SUDO-->>FS: link with elevated perms
FS-->>Installer: link result
end
sequenceDiagram
participant Remover as "uninstall.sh"
participant FS as Filesystem
participant SUDO as sudo
Remover->>FS: is parent directory writable?
FS-->>Remover: yes / no
alt parent directory writable
Remover->>FS: rm -f target (no sudo)
FS-->>Remover: removed / failed
else parent not writable
alt non-interactive & sudo available
Remover->>SUDO: sudo rm -f target
SUDO-->>FS: removed / failed
else
Remover->>Remover: skip removal / abort
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Solid fixes both changes improve correctness of the privilege escalation logic:
install.sh Checking npm config get prefix writability instead of hardcoding NODE_MGR = "nodesource" is strictly better. This handles nvm, fnm, Homebrew, and any other Node manager where the global prefix is user-writable, without needing to enumerate package managers. The || true guard and -n check are good defensive coding.
uninstall.sh Correct fix. On Unix, the ability to delete a file depends on write permission to the parent directory (the directory entry), not the file itself. Checking [ -w "$path" ] was the wrong predicate. a read-only file in a writable directory can still be rm -f'd. Narrowing to just [ -w "$(dirname "$path")" ] matches POSIX semantics.
Minor note: research/results.tsv looks like experiment tracking data. maintainers may want to decide if this belongs in the repo long-term or in a separate tracking system.
|
Sorry about that — research/results.tsv was a local experiment tracking file that got committed by mistake. Removed it and added research/ to .gitignore. |
|
@cluster2600 all commits must have verified signatures. Please update commit ce7677d with a signature. Until then merging is blocked! |
84668c4 to
9f3489b
Compare
|
Sorry mate, commit is now signed. |
Signed-off-by: Maxime Grenu <maxime.grenu@gmail.com>
0ba6c88 to
a68320c
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Dockerfile (1)
5-8: Consider: Build stage could also benefit fromnpm cifor full determinism.The build stage currently uses
npm installwithout the lockfile, meaning dev dependencies (like TypeScript) are resolved based on semver ranges rather than exact locked versions. For fully reproducible builds, consider copyingpackage-lock.jsonhere as well and usingnpm ci.This is optional and outside the scope of this PR's fixes—just noting it for potential future improvement.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Dockerfile` around lines 5 - 8, The Dockerfile's build stage uses RUN npm install which can produce non-deterministic installs; to make builds reproducible, update the COPY and RUN steps so the lockfile is included and use npm ci instead of npm install—specifically, ensure the COPY that currently references package.json also copies package-lock.json (the existing COPY lines for package.json/tsconfig.json) and replace the RUN npm install && npm run build invocation with RUN npm ci && npm run build.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@Dockerfile`:
- Around line 5-8: The Dockerfile's build stage uses RUN npm install which can
produce non-deterministic installs; to make builds reproducible, update the COPY
and RUN steps so the lockfile is included and use npm ci instead of npm
install—specifically, ensure the COPY that currently references package.json
also copies package-lock.json (the existing COPY lines for
package.json/tsconfig.json) and replace the RUN npm install && npm run build
invocation with RUN npm ci && npm run build.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b04ddcf3-0ffe-453b-b32d-be60b4ab5b8b
📒 Files selected for processing (4)
.gitignoreDockerfilescripts/install.shuninstall.sh
✅ Files skipped from review due to trivial changes (2)
- .gitignore
- scripts/install.sh
🚧 Files skipped from review as they are similar to previous changes (1)
- uninstall.sh
…IA#779) Signed-off-by: Maxime Grenu <maxime.grenu@gmail.com>
Summary
Brings the test suite from 188/194 passing to 194/194.
Test plan
Summary by CodeRabbit