fix(install): ensure bin directory exists before copying binary - #2592
fix(install): ensure bin directory exists before copying binary#2592iF2007 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe installer now recreates the ChangesInstaller directory handling
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to The installer now ensures the binary destination directory exists immediately before copying, preventing the reported installation failure without changing broader product behavior. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
Fixes an
ENOENT: no such file or directoryinstallation/update failure inscripts/install.jswhere thebin/destination directory could disappear during download due to a race condition with npm package lifecycle reification.<= v1.0.92darwin-arm64/ Apple Silicon)Problem & Root Cause
In
scripts/install.js,fs.mkdirSync(binDir, { recursive: true })was called at the start ofinstall(), prior to fetching the ~13.8MB release asset over the network.During the remote asset download (which can take 5–30s depending on network/mirror latency), npm's global install/update pipeline (e.g.
npm install -g @larksuite/cliorlark-cli update --force) continues extracting and reifying the package. Becausebin/is not listed inpackage.json'sfilesfield (it is populated purely post-install), npm can prune or recreate the package directory tree while the download is in-flight.When the download finishes and the archive is extracted,
fs.copyFileSync(extractedBinary, dest)executes while the target../bindirectory is missing, resulting inENOENT.Changes
fs.mkdirSync(binDir, { recursive: true })immediately beforefs.copyFileSync(extractedBinary, dest)inscripts/install.jsto guarantee destination directory existence at copy time regardless of download duration or npm tree modifications.Test Plan
make script-test(165/165 tests passing across all test suites includingscripts/install.test.js).darwin-arm64).lark-cli --version(v1.0.92) andlark-cli --helpexecute correctly.Related Issues
Summary by CodeRabbit