Fix: Unset CLAUDECODE env var za child claude procese
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
80cf1d73ce
commit
695bd24d1d
@ -6,8 +6,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -140,11 +142,24 @@ func (s *Server) handleConsoleExec(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cleanEnv returns the current environment with CLAUDECODE removed,
|
||||||
|
// so child claude processes don't inherit the parent's session.
|
||||||
|
func cleanEnv() []string {
|
||||||
|
var env []string
|
||||||
|
for _, e := range os.Environ() {
|
||||||
|
if !strings.HasPrefix(e, "CLAUDECODE=") {
|
||||||
|
env = append(env, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return env
|
||||||
|
}
|
||||||
|
|
||||||
// runCommand executes a command and streams output to listeners.
|
// runCommand executes a command and streams output to listeners.
|
||||||
func (s *Server) runCommand(session *sessionState, command, execID string) {
|
func (s *Server) runCommand(session *sessionState, command, execID string) {
|
||||||
// Build the claude command
|
// Build the claude command
|
||||||
cmd := exec.Command("claude", "--dangerously-skip-permissions", "-p", command)
|
cmd := exec.Command("claude", "--dangerously-skip-permissions", "-p", command)
|
||||||
cmd.Dir = s.projectRoot()
|
cmd.Dir = s.projectRoot()
|
||||||
|
cmd.Env = cleanEnv()
|
||||||
|
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -158,6 +158,7 @@ func (s *Server) handleChatSubmit(c *gin.Context) {
|
|||||||
func (s *Server) runChatCommand(chat *chatState, prompt string) {
|
func (s *Server) runChatCommand(chat *chatState, prompt string) {
|
||||||
cmd := exec.Command("claude", "--dangerously-skip-permissions", "-p", prompt)
|
cmd := exec.Command("claude", "--dangerously-skip-permissions", "-p", prompt)
|
||||||
cmd.Dir = s.projectRoot()
|
cmd.Dir = s.projectRoot()
|
||||||
|
cmd.Env = cleanEnv()
|
||||||
|
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user