Skip to content

Better error message if platform binaries package is not found #7698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#### :nail_care: Polish

- Configuration fields `bs-dependencies`, `bs-dev-dependencies` and `bsc-flags` are now deprecated in favor of `dependencies`, `dev-dependencies` and `compiler-flags`. https://github.com/rescript-lang/rescript/pull/7658
- Better error message if platform binaries package is not found. https://github.com/rescript-lang/rescript/pull/7698

#### :house: Internal

Expand Down
23 changes: 20 additions & 3 deletions cli/common/bins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,28 @@

const target = `${process.platform}-${process.arch}`;

const supportedPlatforms = [
"darwin-arm64",
"darwin-x64",
"linux-arm64",
"linux-x64",
"win32-x64",
];

/** @type {BinaryModuleExports} */
let mod;
try {
mod = await import(`@rescript/${target}`);
} catch {

if (supportedPlatforms.includes(target)) {
const binPackageName = `@rescript/${target}`;

try {
mod = await import(binPackageName);
} catch {
throw new Error(
`Package ${binPackageName} not found. Make sure the rescript package is installed correctly.`,
);
}
} else {
throw new Error(`Platform ${target} is not supported!`);
}

Expand Down
Loading