huggingface/open-r1 · error
Compilation error exit code {compile_result.exit_code} {comp
Error message
Compilation error exit code {compile_result.exit_code}
{compile_result.stderr} What it means
_compile_code runs ./compile inside the MorphCloud VM workspace and raises RuntimeError with the exit code and stderr when compilation fails. This is the VM-side build of the submission (plus task graders), so a failure means the submitted source does not compile in the sandbox toolchain.
Source
Thrown at src/open_r1/utils/competitive_programming/morph_client.py:182
return True
async def _compile_code(self, instance: Instance) -> InstanceExecResponse:
"""
Compile the code on the instance.
Args:
instance: The MorphCloud instance
Returns:
InstanceExecResponse: Result of compilation
Raises:
RuntimeError: If compilation fails
"""
compile_result = await instance.aexec("cd /workspace && ./compile")
if compile_result.exit_code != 0:
raise RuntimeError(f"Compilation error exit code {compile_result.exit_code}\n{compile_result.stderr}")
return compile_result
async def _run_tests(self, instance: Instance, data: Dict[str, Any]) -> Tuple[str, str]:
"""
Run tests and evaluate results.
Args:
instance: The MorphCloud instance
data: Dictionary containing runtime parameters
Returns:
tuple: (score, feedback)
Raises:
TimeoutError: If test execution times out
"""
hard_timeout = data["run_timeout"] / 1000 + 3View on GitHub (pinned to 1416fa0cf2)
Solutions
- Read stderr in the error message — it contains the compiler diagnostics; fix the offending lines in the submission.
- Compile the same source locally with the same compiler/standard the IOI package uses to reproduce and fix errors quickly.
- Verify all required files (solution + graders) were uploaded to /workspace with the layout ./compile expects.
- If you control the sandbox, ensure the compile script and toolchain version match the expected IOI environment.
Example fix
// before: fails on older sandbox gcc
for (auto x : views::iota(0, n)) { ... }
// after: C++17-compatible loop
for (int i = 0; i < n; ++i) { ... } Defensive patterns
Strategy: validation
Validate before calling
import subprocess
res = subprocess.run(['g++', '-std=c++17', '-fsyntax-only', solution_path], capture_output=True, text=True)
if res.returncode != 0:
raise RuntimeError(f'Pre-submission compile check failed:\n{res.stderr}') Type guard
def compile_ok(result) -> bool:
return getattr(result, 'exit_code', 1) == 0 Try / catch
try:
score, feedback = await morph_client.execute(data)
except RuntimeError as e:
if 'Compilation error' in str(e):
logger.error('Submission failed to compile in sandbox:\n%s', e)
return '0', 'Compilation error'
raise Prevention
- Compile locally with the sandbox's compiler standard before batch submission
- Avoid bleeding-edge language features not guaranteed on the worker image
- Ensure grader sources are uploaded with the correct paths
- Run a smoke submission per problem before full evaluation
When it happens
Trigger: instance.aexec('cd /workspace && ./compile') returns exit_code != 0 — submitted C++/C source has compile errors, uses unsupported flags/standard, or the task's grader sources are missing/incompatible so the compile script aborts.
Common situations: Solution uses C++20 features while the sandbox compiler defaults to an older standard; missing #include for functions used; grader files not uploaded to /workspace; compile script failing because problem files were placed in the wrong paths.
Related errors
- {response['message']}
- {response}
- Could not determine problem ID from files
- MorphCloud is not available and required for this function.
- MORPH_API_KEY environment variable is required
AI-assisted analysis of huggingface/open-r1@1416fa0cf2 (2026-08-30).
Data as JSON: /api/errors/abed27562922efc0.
Report an issue: GitHub.