Skip to content

Conversation

@cristianoc
Copy link
Collaborator

@cristianoc cristianoc commented Jan 4, 2026

More in style with the existing codebase.
Just add one more path to try, on top of all the others already tried.

@cristianoc cristianoc force-pushed the fix-rescript-v12-binary-paths branch from fc05c53 to 848eba1 Compare January 4, 2026 08:43
@cristianoc cristianoc requested review from cknitt and zth January 4, 2026 08:43
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc05c532fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

ReScript v12 changed its binary distribution to use @rescript/{platform}/bin.js.
This PR updates the extension to correctly locate binaries for v12+ projects.

Changes:
- Add dedicated v12+ binary finding via @rescript/{target}/bin.js
- Move legacy (<v12) binary finding to separate utils-legacy.ts files
- Clean top-level version check routes to v12+ or legacy code path
- Code Analyzer uses rescript-tools.exe for v12+, rescript-editor-analysis.exe for legacy
- Add findRescriptToolsBinary export for v12+ projects

No functional changes for pre-v12 projects - legacy behavior is preserved exactly.
@cristianoc cristianoc force-pushed the fix-rescript-v12-binary-paths branch from 848eba1 to 19a813d Compare January 4, 2026 09:02
Copy link
Member

@nojaf nojaf left a comment

Choose a reason for hiding this comment

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

I'm not going to claim what we have today is the crown jewel or can't be improved, but this PR makes too many assumptions and misses a lot of recent developments.

Makes me wonder whether we should add a rescript binaries command that outputs all the info as JSON to stdout. That would essentially be what compiler-info.json contains today, but without invoking a full build.

Can you elaborate what wasn't working for you? This feels more like a rewrite for the fun of it, presented as "v12 never worked so here is the fix." We fixed a lot over the summer, so I'm curious which setups failed and what exactly went wrong.

* Finds binaries for ReScript < 12 using the old path structure.
* Checks compiler-info.json first, then falls back to node_modules/rescript/${platformDir}/.
* NOTE: This preserves the original behavior exactly - do not add existence checks
* to the compiler-info.json branch as the original code returned immediately.
Copy link
Member

Choose a reason for hiding this comment

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

compiler-info.json is NOT at all legacy.
It is a ReScript (Rewatch) 12 feature that has a significant higher accuracy to determine the bsc_exe value.

It gets written after a rescript build and has significant accurate information about the compiler and runtime. Respecting environment variables that can override these locations which is crucial for local testing.

https://github.com/rescript-lang/rescript/blob/66ba3f8d7769c9d21084f8e3e3acd1c622d56514/rewatch/src/build.rs#L410

@cristianoc
Copy link
Collaborator Author

cristianoc commented Jan 4, 2026

I'm not going to claim what we have today is the crown jewel or can't be improved, but this PR makes too many assumptions and misses a lot of recent developments.

Makes me wonder whether we should add a rescript binaries command that outputs all the info as JSON to stdout. That would essentially be what compiler-info.json contains today, but without invoking a full build.

Can you elaborate what wasn't working for you? This feels more like a rewrite for the fun of it, presented as "v12 never worked so here is the fix." We fixed a lot over the summer, so I'm curious which setups failed and what exactly went wrong.

The original intent is actually quite simple.
"Start Code Analyzer" does not find the correct binary path (and it looks for the wrong binary anyway), falls back into some "use what's included in the extension", then crashes. Instead of simply reporting that the binaries were not found.

The original intent is to at least eliminate the v12 vs other versions complexity. And fix code analyzer binary lookup.
Clearly the result simplifies too much at the moment.

Is there a spec anywhere of what binary resolution should look like? Is there a reason why it should be different than what the compiler does (if not, then the compiler code could be the spec). Even a few tiny example projects checked in that "should not break" could work as substitute for a proper spec.

Otherwise, "change the existing code as little as possible or something will break" is the only thing that can be done at the moment. Which is one way to do the PR if there's no alternative.

@cristianoc cristianoc changed the title fix: use correct binary paths for ReScript v12+ fix Start Code Analysis: use correct binary paths for ReScript v12+ Jan 4, 2026
@cristianoc cristianoc requested review from cknitt and nojaf January 4, 2026 12:58
@cristianoc
Copy link
Collaborator Author

moved to different PR for simplicty.

@cristianoc cristianoc closed this Jan 4, 2026
@nojaf
Copy link
Member

nojaf commented Jan 5, 2026

Is there a spec anywhere of what binary resolution should look like?

Not really, this is mostly the consequence of situation x or y was not working.

The

    const targetPackagePath = path.join(
      fs.realpathSync(rescriptDir),
      "..",
      `@rescript/${target}/bin.js`,
    );

part was a recent addition.

If we had that sooner, we probably would not have done the compiler-info.json lookup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants