Skip to content

fix/feat: CLion 2026 compatibility (Ktor crash, silent build failures) & CMake support - #177

Closed
Nightwing-007 wants to merge 3 commits into
Pushpavel:mainfrom
Nightwing-007:main
Closed

fix/feat: CLion 2026 compatibility (Ktor crash, silent build failures) & CMake support#177
Nightwing-007 wants to merge 3 commits into
Pushpavel:mainfrom
Nightwing-007:main

Conversation

@Nightwing-007

Copy link
Copy Markdown

This PR bundles three focused commits to restore compatibility with recent JetBrains IDE updates (specifically tested on CLion 2026.1) and improve the workflow for CMake users.

1. Fix: Ktor ServiceConfigurationError crash

In modern JetBrains IDEs, strict PluginClassLoader boundaries cause Ktor's default ServiceLoader to fail when initializing HttpClient().

  • Change: Explicitly passed the engine HttpClient(Java.create()) to bypass the ServiceLoader entirely, preventing the hard crash on problem import.

2. Fix: Silent build failures in ProcessRunner

Previously, ProcessRunner only checked if stderr was empty to determine compilation success. If a compiler (like MSYS2 g++) failed silently due to missing system PATH dependencies, it exited with code 1 but empty stderr, causing AutoCp to falsely report success and crash looking for the executable.

  • Change: Updated ProcessRunner to strictly evaluate the process exitCode. It now properly reports silent failures back to the user.

3. Feat: @projectDir and @name macros for CMake support

AutoCp's internal build pipeline bypasses IDE build systems. For CLion users, this meant AutoCp couldn't find binaries generated in cmake-build-debug.

  • Change: Added @projectDir and @name macros to AutoCpKeys and Lang.kt. Users can now clear the buildCommand and set executeCommand to "$projectDir/cmake-build-debug/@name.exe", allowing seamless integration with CMake.

Let me know if you need any adjustments to these commits

In recent JetBrains IDE versions, Ktor's default ServiceLoader initialization fails across PluginClassLoader boundaries with a ServiceConfigurationError. Explicitly passing Java.create() bypasses the ServiceLoader entirely.
ProcessRunner previously only checked if stderr was empty to determine success. If a compiler (like MSYS2 g++) failed silently due to missing PATH dependencies, it exited with code 1 but empty stderr, causing AutoCp to falsely report 'Build completed successfully'. This updates the runner to strictly evaluate the process exit code.
Introduces @projectdir and @name macros to the command execution templates. This allows IDE users to bypass AutoCp's internal compiler execution and point directly to external build system outputs, such as CLion's cmake-build-debug directory.
@znzryb

znzryb commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

One structural request first: would you mind splitting this into separate PRs? A crash fix, a build-failure fix and a new feature each need a different discussion, and bundling them holds the uncontroversial parts hostage to the rest.

1. Ktor crash: HttpClient(Java) already passes the engine factory explicitly — that line came from #174, which fixed this same ServiceConfigurationError — so the ServiceLoader shouldn't be involved since v0.10.0. Could you post the actual stack trace you hit on CLion 2026.1? If it still crashes with the factory form, something else is failing and we'd want to see it before switching to Java.create().

2. Exit-code check: the silent-build-failure motivation makes sense, but ProcessRunner.run is also used for the solution, generator and checker processes, and those callers already interpret exit codes themselves — e.g. Judge.kt maps a checker's non-zero exit codes to WA/PE verdicts, so throwing RuntimeErr inside run() would break checker-based judging. The build step's call site (TwoStepProcessFactory) would be the right home for this check — and since #178 is already reworking these exact lines in readOutputAsync, it'd be better coordinated there than landed twice.

3. @projectDir/@name macros: AutoCp compiling into its own isolated directory looks intentional rather than a limitation — it keeps test runs independent of the IDE's build state. With buildCommand cleared, AutoCp would run whatever binary CLion last produced in cmake-build-debug, so after editing the solution you could silently test a stale executable unless you remember to rebuild through CMake first. We'd rather not trade that guarantee away for this workflow.

@Nightwing-007

Copy link
Copy Markdown
Author

Closing to split these into smaller, focused PRs as discussed

@Nightwing-007

Nightwing-007 commented Jul 27, 2026 via email

Copy link
Copy Markdown
Author

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.

2 participants