Add custom ruff/ty binary paths with structured resolution#414
Merged
Conversation
4263f08 to
b9e5589
Compare
b9e5589 to
384623e
Compare
|
Hi @manzt, we are running into this problem. index-url = "https://our.domain.internal/api/pypi/pypi-all/simple"
python-install-mirror = "https://our.domain.internal/generic-github-remote/astral-sh/python-build-standalone/releases/download"
native-tls = trueWill this PR use https://docs.astral.sh/uv/reference/settings/#index-url and not override it when marimo-lsp/extension/src/services/Uv.ts Line 374 in 7ca6754 Related issue #437 |
c39bce5 to
671e255
Compare
Closes #408 Users in offline environments cannot use the extension's managed ruff/ty language servers because `uv pip install` tries to download packages from the internet. This adds a 3-tier binary resolution strategy so these users can point to locally-installed binaries instead. Binary resolution now follows this priority for both ruff and ty: 1. User-configured path via `marimo.ruff.path` / `marimo.ty.path` 2. Companion extension discovery — checks the `charliermarsh.ruff` or `astral-sh.ty` extension's configured path setting, then its bundled binary at `<extensionPath>/bundled/libs/bin/<binary>` 3. Existing `uv pip install` fallback (unchanged behavior) Each candidate binary is validated by running `<binary> --version` and checking the result meets the minimum version requirement (ruff >= 0.15.0, ty >= 0.0.15). If validation fails at any tier, resolution falls through to the next.
4be5cca to
25c24c6
Compare
The ruff and ty language servers resolve their binaries through a 3-tier
strategy (user-configured path, companion extension, uv install), but
previously each server implemented this inline with ad-hoc string labels
to identify which source was used. This made it hard to display
consistent diagnostics, track resolution paths in telemetry, or test the
fallthrough logic in isolation.
This introduces a `BinarySource` tagged enum (modeled after `UvBin`)
with three variants: `UserConfigured`, `CompanionExtension` (with a
`kind` field distinguishing "configured" vs "bundled"), and
`UvInstalled`. A generic `resolveBinary()` function tries composable
`ResolutionSource` values in order and returns the first match, with
structured log annotations on every attempt.
```ts
BinarySource.$match(source, {
UserConfigured: ({ path }) => ...,
CompanionExtension: ({ extensionId, path, kind }) => ...,
UvInstalled: ({ path }) => ...,
});
```
The `Running` status for both language servers now carries the full
`BinarySource` value, which the health diagnostics format via exhaustive
`$match`. A telemetry event type `lsp_binary_resolved` is defined for
future instrumentation using `_tag` as the discriminant.
25c24c6 to
69187df
Compare
The `lsp_binary_resolved` event type was defined but never captured.
This adds `reportBinaryResolved` to the `Telemetry` service and calls
it from both `RuffLanguageServer` and `TyLanguageServer` after the
server starts successfully. The event includes the server name, the
`BinarySource._tag` discriminant, the companion extension `kind` when
applicable, and the resolved server version — enough to see the
distribution of resolution paths across users.
```ts
telemetry.reportBinaryResolved("ruff", resolved, serverVersion)
```
5f3f522 to
26a6e14
Compare
Collaborator
Author
|
This PR doesn't fix the The easiest path forward: install the {
"marimo.ruff.path": "/usr/local/bin/ruff",
"marimo.ty.path": "/usr/local/bin/ty"
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #408
Users in offline or restricted environments cannot use the extension's managed ruff/ty language servers because the
uv pip installfallback requires internet access. This adds two new settings (marimo.ruff.pathandmarimo.ty.path) and a companion extension discovery mechanism so these users can point to locally-installed binaries instead.New settings
marimo.ruff.path— absolute path to a customruffbinarymarimo.ty.path— absolute path to a customtybinaryLeave empty (default) to use automatic discovery.
Resolution strategy
Binary resolution follows this priority for both ruff and ty:
marimo.ruff.path/marimo.ty.pathcharliermarsh.rufforastral-sh.tyextension's own path setting (ruff.path/ty.path), then its bundled binary at<extensionPath>/bundled/libs/bin/<binary>uv pip install— existing behavior, unchangedEach candidate is validated by running
<binary> --versionand checking it meets the minimum version (ruff >= 0.15.6, ty >= 0.0.23). If validation fails at any tier, resolution falls through to the next.The resolution pipeline is generic:
resolveBinary()accepts an ordered list ofResolutionSourcevalues and a fallback, tries each in sequence, and returns aBinarySourcetagged enum describing where the binary came from: