Skip to content

Commit 1c29984

Browse files
author
Developer
committed
Fix three bugs preventing ralph from running
- Rename ralph-loop.js → .cjs so consuming projects with "type": "module" in package.json don't break require() calls - Unset CLAUDECODE env var to prevent "nested session" rejection when ralph:start is run from within a Claude Code terminal - Fix missing && between env exports and cd in screen command; export was eating the path as an invalid identifier, aborting the chain before node could start
1 parent 0a55fdf commit 1c29984

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,14 @@ function truncate(str, maxLen) {
174174

175175
function runClaude(claudeArgs, logger) {
176176
return new Promise((resolve, reject) => {
177+
// Remove CLAUDECODE to prevent "nested session" detection when Ralph
178+
// is started from within a Claude Code terminal
179+
const env = { ...process.env };
180+
delete env.CLAUDECODE;
181+
177182
const proc = spawn("claude", claudeArgs, {
178183
stdio: ["inherit", "pipe", "pipe"],
179-
env: { ...process.env },
184+
env,
180185
});
181186

182187
let output = "";

src/Commands/StartCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function handle(SessionTracker $tracker, ScreenManager $screenManager): i
6565
// Build the ralph-loop command
6666
/** @var string|null $configScriptPath */
6767
$configScriptPath = config('ralph.script_path');
68-
$scriptPath = $configScriptPath ?? dirname(__DIR__, 2).'/scripts/ralph-loop.js';
68+
$scriptPath = $configScriptPath ?? dirname(__DIR__, 2).'/scripts/ralph-loop.cjs';
6969
$loopCmd = $this->buildLoopCommand($scriptPath, $prompt, $name, $iterations, $sessionId);
7070

7171
// Foreground (--once) mode
@@ -95,7 +95,8 @@ public function handle(SessionTracker $tracker, ScreenManager $screenManager): i
9595
$this->components->info("Starting ralph session '{$name}'...");
9696

9797
$envExports = $this->buildEnvExportString();
98-
$screenCmd = "{$envExports} cd {$workingDir} && {$loopCmd}";
98+
$parts = array_filter(['unset CLAUDECODE', $envExports, "cd {$workingDir}", $loopCmd]);
99+
$screenCmd = implode(' && ', $parts);
99100

100101
$screenManager->start($name, $screenCmd, $workingDir);
101102

0 commit comments

Comments
 (0)