Skip to content

fix(install): detect curl version before using --ssl-revoke-best-effort#1124

Merged
liangshuo-1 merged 2 commits into
mainfrom
fix/install-curl-version-gate
May 28, 2026
Merged

fix(install): detect curl version before using --ssl-revoke-best-effort#1124
liangshuo-1 merged 2 commits into
mainfrom
fix/install-curl-version-gate

Conversation

@liangshuo-1

@liangshuo-1 liangshuo-1 commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

On older Windows systems (e.g. Windows 10 build 19044 with curl 7.55.1), npm install fails during postinstall because scripts/install.js unconditionally adds --ssl-revoke-best-effort on Windows. That flag was only introduced in curl 7.70.0 (2020-04-29), so older curl exits with:

curl: option --ssl-revoke-best-effort: is unknown

Fixes #1099.

Solution

Gate the flag behind a runtime curl-version probe: only pass --ssl-revoke-best-effort when isWindows && curl >= 7.70.0. Older curl falls back to standard SSL revocation checks and installs successfully; modern Windows curl behaves exactly as before (still avoids CRYPT_E_REVOCATION_OFFLINE).

Credit

The original fix is by @Ellien-Tang in #1116 — cherry-picked here with authorship preserved (first commit). This PR supersedes #1116 and adds maintainer follow-ups on top (second commit).

Follow-ups added on top

  • Testability refactor — extracted the version comparison into a pure isCurlVersionSupported(output) (no I/O), so the >= 7.70.0 logic is unit-testable without spawning a process.
  • Real testsscripts/install.test.js now covers 7.55.1 / 7.69.0 / 7.70.0 / 8.x, the unparseable case, and a regression guard ensuring the regex reads the leading curl X.Y.Z rather than the trailing libcurl/X.Y.Z.
  • Memoized probedownload() runs once per mirror URL; the curl --version result is now cached so curl is probed at most once per install instead of on every attempt.

Test

$ node --test scripts/install.test.js
# tests 31   # pass 31   # fail 0
curl version --ssl-revoke-best-effort
7.55.1 (old Windows 10) not used
7.69.0 (just below threshold) not used
7.70.0 (minimum supported) used
8.x+ used

Backward compatibility

  • curl >= 7.70.0: unchanged.
  • curl < 7.70.0: install now succeeds (previously failed outright).

Summary by CodeRabbit

  • Bug Fixes

    • Improved Windows installer compatibility by detecting curl capability once and only supplying the newer curl flag when supported, preventing errors on older curl releases.
  • Tests

    • Added comprehensive tests covering multiple curl version strings and edge cases to ensure reliable detection.

Review Change Stack

@CLAassistant

CLAassistant commented May 27, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4b98a1be-0959-447d-9aea-3d7b0af82d48

📥 Commits

Reviewing files that changed from the base of the PR and between c2abb78 and 2604eda.

📒 Files selected for processing (2)
  • scripts/install.js
  • scripts/install.test.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • scripts/install.test.js
  • scripts/install.js

📝 Walkthrough

Walkthrough

Adds a curl --version parser and a memoized probe in install.js, exports the helpers, and conditions Windows download() to prepend --ssl-revoke-best-effort only when curl >= 7.70.0; tests validate the parsing logic across threshold, future, and malformed inputs.

Changes

Windows curl version detection and conditional flag usage

Layer / File(s) Summary
Curl version detection implementation
scripts/install.js
Added isCurlVersionSupported() to parse leading curl X.Y.Z and compare to 7.70.0, plus curlSupportsSslRevokeBestEffort() which probes curl --version via execFileSync, memoizes the boolean result with timeout fallback, and exports both helpers.
Download integration and tests
scripts/install.js, scripts/install.test.js
Updated Windows download() to prepend --ssl-revoke-best-effort only when the probe returns true. Added tests for isCurlVersionSupported covering below-threshold, at-threshold, future versions, malformed/empty inputs, and anchoring to the leading curl token.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • larksuite/cli#226: Both PRs modify scripts/install.js's curl-based download logic around the Windows --ssl-revoke-best-effort flag—this PR makes its usage conditional via curl version probing.

Poem

🐰 I sniff the system curl with care and haste,
Hunting versions so no install is faced,
If seven-dot-seventy shows it's fine,
I add the revoke flag at the right time,
Cached once, I hop away—no more errors to chide.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(install): detect curl version before using --ssl-revoke-best-effort' clearly and concisely summarizes the main change: implementing version detection for curl compatibility.
Description check ✅ Passed The PR description comprehensively covers the problem, solution, follow-ups, tests, and backward compatibility. However, it deviates from the template structure with custom sections instead of the specified 'Summary', 'Changes', 'Test Plan', and 'Related Issues' headings.
Linked Issues check ✅ Passed The code changes fully address issue #1099 by implementing curl version detection and gating --ssl-revoke-best-effort behind a version check, preventing installation failures on older Windows curl versions.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the curl version compatibility issue. The version detection logic, tests, and memoization are all necessary and relevant to resolving #1099.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/install-curl-version-gate

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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 and usage tips.

@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label May 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/install.js`:
- Around line 123-125: The regex in isCurlVersionSupported currently can match
substrings like "libcurl 8.0.0"; change the pattern to require the leading
"curl" token by anchoring it (e.g., use a start-of-string anchor or a word
boundary) so only outputs beginning with "curl" are accepted; update the match
in isCurlVersionSupported to use the anchored pattern while keeping the existing
capture groups for major/minor/patch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2ce6dbc7-4c15-468d-b785-42589528b814

📥 Commits

Reviewing files that changed from the base of the PR and between 9e2be14 and c2abb78.

📒 Files selected for processing (2)
  • scripts/install.js
  • scripts/install.test.js

Comment thread scripts/install.js
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.22%. Comparing base (9e2be14) to head (2604eda).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1124   +/-   ##
=======================================
  Coverage   68.22%   68.22%           
=======================================
  Files         617      617           
  Lines       57192    57192           
=======================================
  Hits        39017    39017           
  Misses      14945    14945           
  Partials     3230     3230           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@2604eda45d692886d8cb4055f6f0f01c669bb6c0

🧩 Skill update

npx skills add larksuite/cli#fix/install-curl-version-gate -y -g

Extract the version comparison out of curlSupportsSslRevokeBestEffort()
into a pure isCurlVersionSupported(output), so the >= 7.70.0 logic is unit
testable without spawning curl. Add cases for 7.55.1 / 7.69.0 / 7.70.0 /
8.x plus the unparseable and libcurl-token edge cases (the regex must read
the leading "curl X.Y.Z", not the trailing "libcurl/X.Y.Z").

Memoize the `curl --version` probe: curl's version is invariant for the
install's lifetime while download() runs once per mirror URL, so probe at
most once instead of re-spawning curl on every attempt.
@liangshuo-1
liangshuo-1 force-pushed the fix/install-curl-version-gate branch from c2abb78 to 2604eda Compare May 27, 2026 05:48
@liangshuo-1
liangshuo-1 merged commit a2cc5e1 into main May 28, 2026
21 checks passed
@liangshuo-1
liangshuo-1 deleted the fix/install-curl-version-gate branch May 28, 2026 14:51
tuxedomm pushed a commit to zhumiaoxin/cli that referenced this pull request Jun 6, 2026
…rt (larksuite#1124)

* fix(install): detect curl version before using --ssl-revoke-best-effort

(cherry picked from commit da14737)

* test(install): cover curl version gate and refactor for testability

Extract the version comparison out of curlSupportsSslRevokeBestEffort()
into a pure isCurlVersionSupported(output), so the >= 7.70.0 logic is unit
testable without spawning curl. Add cases for 7.55.1 / 7.69.0 / 7.70.0 /
8.x plus the unparseable and libcurl-token edge cases (the regex must read
the leading "curl X.Y.Z", not the trailing "libcurl/X.Y.Z").

Memoize the `curl --version` probe: curl's version is invariant for the
install's lifetime while download() runs once per mirror URL, so probe at
most once instead of re-spawning curl on every attempt.

---------

Co-authored-by: EllienTang <146210093+Ellien-Tang@users.noreply.github.com>
Co-authored-by: liangshuo-1 <266696938+liangshuo-1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

windows低版本 使用curl安装二进制程序 --ssl-revoke-best-effort 不支持 导致安装失败

4 participants