fix(daytona): resolve cwd by detecting home directory inside the sandbox
This commit is contained in:
parent
df61054a84
commit
435530018b
1 changed files with 10 additions and 3 deletions
|
|
@ -35,9 +35,7 @@ class DaytonaEnvironment(BaseEnvironment):
|
||||||
persistent_filesystem: bool = True,
|
persistent_filesystem: bool = True,
|
||||||
task_id: str = "default",
|
task_id: str = "default",
|
||||||
):
|
):
|
||||||
# Resolve ~ to Daytona's default user home (matches Docker's ~ -> /root pattern)
|
self._requested_cwd = cwd
|
||||||
if cwd == "~":
|
|
||||||
cwd = "/home/daytona"
|
|
||||||
super().__init__(cwd=cwd, timeout=timeout)
|
super().__init__(cwd=cwd, timeout=timeout)
|
||||||
|
|
||||||
from daytona import (
|
from daytona import (
|
||||||
|
|
@ -86,6 +84,15 @@ class DaytonaEnvironment(BaseEnvironment):
|
||||||
logger.info("Daytona: created sandbox %s for task %s",
|
logger.info("Daytona: created sandbox %s for task %s",
|
||||||
self._sandbox.id, task_id)
|
self._sandbox.id, task_id)
|
||||||
|
|
||||||
|
# Resolve cwd: detect actual home dir inside the sandbox
|
||||||
|
if self._requested_cwd in ("~", "/home/daytona"):
|
||||||
|
try:
|
||||||
|
home = self._sandbox.process.exec("echo $HOME").result.strip()
|
||||||
|
self.cwd = home or "/root"
|
||||||
|
except Exception:
|
||||||
|
self.cwd = "/root"
|
||||||
|
logger.info("Daytona: resolved cwd to %s", self.cwd)
|
||||||
|
|
||||||
def _ensure_sandbox_ready(self):
|
def _ensure_sandbox_ready(self):
|
||||||
"""Restart sandbox if it was stopped (e.g., by a previous interrupt)."""
|
"""Restart sandbox if it was stopped (e.g., by a previous interrupt)."""
|
||||||
self._sandbox.refresh_data()
|
self._sandbox.refresh_data()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue