Skip to content

Commit 42fa839

Browse files
committed
fix(ide): stop passing --keep-going to rust-analyzer twice
rust-analyzer already passes --keep-going to cargo check, and cargo rejects the duplicate, so VS Code showed no Rust diagnostics. Drop rust-analyzer.check.extraArgs from the generated settings; cstudy ide rewrites an unedited settings.json.
1 parent 6e57eba commit 42fa839

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎cli/src/coding_study/adapters/ide/vscode.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"go.toolsEnvVars": {"GOTOOLCHAIN": "local"},
5656
"rust-analyzer.linkedProjects": [f"{RUST_PROJECT}/Cargo.toml"],
5757
"rust-analyzer.check.allTargets": True,
58-
"rust-analyzer.check.extraArgs": ["--keep-going"],
5958
"files.watcherExclude": {
6059
"**/.gradle/**": True,
6160
"**/.kotlin/**": True,
@@ -78,8 +77,9 @@
7877
`java.jdt.ls.java.home` would pin a machine-specific path. gopls finds `go/` through the
7978
workspace's `go.work`; the Go tools run with `GOTOOLCHAIN=local`, as `cstudy` does, so they never
8079
download a toolchain. rust-analyzer needs the link because `Cargo.toml` is in `rust/`, checks every
81-
target because each problem is an `[[example]]`, and `--keep-going` keeps one broken problem from
82-
hiding the errors of the others."""
80+
target because each problem is an `[[example]]`. It passes `--keep-going` to `cargo check` itself,
81+
which keeps one broken problem from hiding the errors of the others; passing it again through
82+
`rust-analyzer.check.extraArgs` makes cargo fail and VS Code show no Rust diagnostics."""
8383
EXTENSIONS: JsonObject = {
8484
"recommendations": [
8585
"ms-python.python",

‎cli/tests/adapters/ide/test_vscode.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ def test_rust_analyzer_links_each_rust_project_folder_after_the_template():
240240
]
241241

242242

243-
def test_rust_analyzer_checks_every_target_and_keeps_going_past_a_broken_problem():
244-
settings = document(SETTINGS)
245-
assert (
246-
settings["rust-analyzer.check.allTargets"],
247-
settings["rust-analyzer.check.extraArgs"],
248-
) == (True, ["--keep-going"])
243+
def test_rust_analyzer_checks_every_target():
244+
assert document(SETTINGS)["rust-analyzer.check.allTargets"] is True
245+
246+
247+
def test_rust_analyzer_gets_no_extra_check_arguments_because_it_passes_keep_going_itself():
248+
assert "rust-analyzer.check.extraArgs" not in document(SETTINGS)
249249

250250

251251
def test_the_go_tools_never_download_a_toolchain():

‎docs/guides/toolchains.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Nothing else is needed: the runner crates' only dependencies, `rust_decimal` and
188188

189189
- **Your Cargo setup**: `cstudy` ignores your Cargo configuration for its builds. `RUSTFLAGS`, rustc wrappers such as `sccache`, `CARGO_TARGET_DIR`, `CARGO_BUILD_*` and `CARGO_PROFILE_*` do not reach them, and crates.io always resolves to the vendored crates, so none can break a build or change what it measures. They still apply to the `cargo` commands you run yourself. Builds go to `.cs/build/rust` in the workspace.
190190
- **Copied files**: Cargo rebuilds a crate only when a source is newer than the last build, so a file replaced by a copy that keeps an older time (`rsync -a`, `cp -p`) would run the old code. `cstudy` records a digest of your practice file, or of the Rust files and `Cargo.toml` of a project folder, at each build, and touches the ones that changed before Cargo runs, so the new code always builds. Nothing else is needed; your own `cargo` commands in `rust/` do not get this and still go by times.
191-
- **Editor**: `rust/Cargo.toml` lists each problem you start, so rust-analyzer checks every file; open the workspace root, or `rust/`. Its `rust/.cargo/config.toml` resolves `rust_decimal` and `chrono` from the vendored crates, for `cargo` commands run in `rust/`. The workspace's VS Code files recommend rust-analyzer (`rust-lang.rust-analyzer`), link `rust/Cargo.toml` and check with `--keep-going`; `cstudy ide` adds them to a workspace created earlier. The extension's rust-analyzer needs a recent stable toolchain: with an older one it reports an outdated toolchain and may flag standard macros such as `todo!` and `vec!`, which `rustup update` fixes.
191+
- **Editor**: `rust/Cargo.toml` lists each problem you start, so rust-analyzer checks every file; open the workspace root, or `rust/`. Its `rust/.cargo/config.toml` resolves `rust_decimal` and `chrono` from the vendored crates, for `cargo` commands run in `rust/`. The workspace's VS Code files recommend rust-analyzer (`rust-lang.rust-analyzer`), link `rust/Cargo.toml` and check every target; `cstudy ide` adds them to a workspace created earlier. If an older `cstudy` wrote `"rust-analyzer.check.extraArgs": ["--keep-going"]` into your `.vscode/settings.json` and you edited that file, remove the key (rust-analyzer already passes `--keep-going`, and cargo rejects it twice), or run `cstudy ide --force`. The extension's rust-analyzer needs a recent stable toolchain: with an older one it reports an outdated toolchain and may flag standard macros such as `todo!` and `vec!`, which `rustup update` fixes.
192192
- **Debugging**: `cstudy test --debug` runs the Rust runner under LLDB's debug server, and in VS Code **Debug current file (Rust)** attaches CodeLLDB (`vadimcn.vscode-lldb`, which the workspace's VS Code files recommend). On macOS the server is `debugserver`, which the Xcode Command Line Tools (`xcode-select --install`) and Xcode ship inside LLDB.framework; `cstudy` finds it as `lldb` does, through `xcode-select -p`. macOS lets a program be debugged only with permission: members of the `_developer` group have it (`id -Gn` lists your groups); for anyone else macOS asks for an administrator when a debug session starts, until an administrator turns developer mode on with `sudo DevToolsSecurity -enable`. On Linux the server is `lldb-server`, from your distribution's `lldb` package (`sudo apt install lldb` on Debian and Ubuntu; a versioned package alone, such as `lldb-18`, installs only `lldb-server-18`), and `cstudy` looks for it on `PATH`. In a Docker container, start the container with `--security-opt seccomp=unconfined`: the default profile refuses the call `lldb-server` makes to turn off address randomization, and the debug run stops with `personality set failed: Operation not permitted`. A debugged test of a Rust project problem is reported as an `error` on Linux, because `lldb-server` sends the test's output only to your debugger: read the result there. `cstudy doctor` warns while the server is missing.
193193

194194
## git

‎docs/specs/installation-and-workspaces.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ One catalog (`coding_study/domain/ide_actions.py`) lists these actions, and both
204204
|------|-------|
205205
| `.vscode/tasks.json` | A `process` task per action and scope (`cstudy test (current file)` runs `cstudy test ${file}` in `${workspaceFolder}`); `done` asks for the outcome through a `pickString` input. The `cstudy test --debug` tasks are background tasks whose problem matcher ends at `cstudy: waiting for debugger on 127.0.0.1:<port>` |
206206
| `.vscode/launch.json` | `Debug current file (<language>)` and `Debug active attempt (<language>)` for Python (`debugpy` attach, port 5678), TypeScript (`node` attach, 9229), Java (`java` attach, 5005), Go (the Go extension's `go` attach in `"mode": "remote"` to the headless Delve, 2345) and Rust (CodeLLDB's `lldb` attach: `targetCreateCommands` `["target create \"\""]`, an empty target that takes the executable the debug server reports, since each run launches its own copy of the runner, then `processCreateCommands` `["gdb-remote 127.0.0.1:12345"]`; `preTerminateCommands` an lldb `script` one-liner that kills the process only while it is alive (`lldb.process.is_alive`; a plain `process kill` would print `error: Process must be launched.` after a run that already finished), because CodeLLDB detaches from an attached process when its session ends and the runner would go on without a debugger; and `sourceLanguages` `["rust"]` for Rust's formatters), each starting its `cstudy test --debug` task first; all on 127.0.0.1. None for Kotlin: VS Code's Java debugger never binds Kotlin breakpoints ([vscode-java-debug#241](https://github.com/microsoft/vscode-java-debug/issues/241)) |
207-
| `.vscode/settings.json` | `python.defaultInterpreterPath` `${workspaceFolder}/python/.venv/bin/python`, `typescript.tsdk` `typescript/node_modules/typescript/lib`, `java.import.gradle.enabled`, `go.toolsEnvVars` `{"GOTOOLCHAIN": "local"}`, `rust-analyzer.linkedProjects` `["rust/Cargo.toml"]`, then `projects/<slug>/Cargo.toml` of each [Rust project folder](#project-folders) in path order, with `rust-analyzer.check.allTargets` and `rust-analyzer.check.extraArgs` `["--keep-going"]`, watcher and search exclusions for build output (`target` included) and for `projects/*/.venv`, the links to the shared venv; no JDK path |
207+
| `.vscode/settings.json` | `python.defaultInterpreterPath` `${workspaceFolder}/python/.venv/bin/python`, `typescript.tsdk` `typescript/node_modules/typescript/lib`, `java.import.gradle.enabled`, `go.toolsEnvVars` `{"GOTOOLCHAIN": "local"}`, `rust-analyzer.linkedProjects` `["rust/Cargo.toml"]`, then `projects/<slug>/Cargo.toml` of each [Rust project folder](#project-folders) in path order, with `rust-analyzer.check.allTargets`, watcher and search exclusions for build output (`target` included) and for `projects/*/.venv`, the links to the shared venv; no JDK path |
208208
| `.vscode/extensions.json` | Recommends `ms-python.python`, `ms-python.debugpy`, `vscjava.vscode-java-pack`, `vscjava.vscode-gradle`, `golang.go`, `rust-lang.rust-analyzer`, `vadimcn.vscode-lldb` (CodeLLDB, the Rust debugger) |
209209
| `.idea/misc.xml` | The project JDK named after the feature release of [the selected JDK](cli.md#the-selected-jdk) (`26`; `JavaSDK`) and the language level of the build's [release level](runners.md#the-jdk-and-the-release-level) (`JDK_26`, which JDK 27 gets too), so IntelliJ's Gradle import, which runs with the project JDK, compiles as `cstudy test` does. With no JDK selected it names the recommended `25`. [`cstudy ide`](cli.md#cstudy-ide) replaces it while it is still as written, so a JDK switch updates it, and keeps it, with a warning, once IntelliJ or you changed it |
210210
| `.idea/gradle.xml` | `jvm/` linked as a Gradle project with its `java` and `kotlin` modules, run with the project JDK (`#USE_PROJECT_JDK`) |
@@ -217,7 +217,7 @@ Go and Rust need no tasks or run configurations of their own: every action is la
217217
| `go.toolsEnvVars` `GOTOOLCHAIN=local` | The Go extension's tools (gopls) run as `cstudy` does and never download the toolchain `go/go.mod` asks for ([toolchains](../guides/toolchains.md#go)). gopls finds `go/` through the `go.work` at the workspace root; no setting is needed for that |
218218
| `rust-analyzer.linkedProjects` `rust/Cargo.toml` | The Cargo project is in `rust/`, not at the workspace root |
219219
| `rust-analyzer.linkedProjects` `projects/<slug>/Cargo.toml` | Each Rust project folder is a crate of its own, outside `rust/`; a folder is a Rust project when it holds a `Cargo.toml`. `cstudy start` refreshes VS Code's files when it writes a new Rust folder, once `cstudy` has written them; a folder started otherwise, or while a `settings.json` you edited is kept, is missing until `cstudy ide` runs again, and `cstudy doctor` says so |
220-
| `rust-analyzer.check.allTargets`, `rust-analyzer.check.extraArgs` `--keep-going` | Each problem is an `[[example]]` built as a library crate ([ADR 0012](../decisions/0012-go-and-rust.md)); checking every target covers them, and `--keep-going` reports the errors of every problem when one is broken instead of stopping at the first |
220+
| `rust-analyzer.check.allTargets` | Each problem is an `[[example]]` built as a library crate ([ADR 0012](../decisions/0012-go-and-rust.md)); checking every target covers them. rust-analyzer passes `--keep-going` to `cargo check` itself, so the errors of every problem show when one is broken; the setting `rust-analyzer.check.extraArgs` `["--keep-going"]`, which earlier `cstudy` versions wrote, makes cargo reject the duplicate and VS Code show no Rust diagnostics, so `cstudy ide` drops it while `settings.json` is as `cstudy` wrote it, and an edited one needs the key removed by hand or `cstudy ide --force` |
221221

222222
An existing workspace gets the new settings and extensions from `cstudy ide`, which follows the rewriting rule below: it updates `settings.json` and `extensions.json` while they are as `cstudy` wrote them, and keeps (with a warning) the ones you edited until `cstudy ide --force`, or until you copy the keys over. `cstudy doctor --fix` never writes IDE files. Debug configurations for Go and Rust are not generated yet.
223223

0 commit comments

Comments
 (0)