Skip to content

Commit 99c64a5

Browse files
committed
fix
1 parent ab04e8c commit 99c64a5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

custom-domain/dstack-ingress/scripts/certman.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,23 @@ def _ensure_certbot_in_env(self) -> None:
186186
def _get_certbot_command(self) -> List[str]:
187187
"""Get the correct certbot command that uses the same Python environment."""
188188
import sys
189+
import os
189190

190-
# Always use Python module execution to ensure same environment
191-
# This guarantees that certbot runs in the same Python environment
192-
# where we installed the plugins
193-
cmd = [sys.executable, "-m", "certbot"]
194-
print(f"Using certbot via Python module: {' '.join(cmd)}")
195-
return cmd
191+
# Always use certbot from the same Python environment
192+
python_dir = os.path.dirname(sys.executable)
193+
venv_certbot = os.path.join(python_dir, "certbot")
194+
195+
if os.path.exists(venv_certbot):
196+
cmd = [venv_certbot]
197+
print(f"Using certbot from virtual environment: {venv_certbot}")
198+
return cmd
199+
200+
# If certbot doesn't exist in venv, this is an error condition
201+
raise RuntimeError(
202+
f"Certbot not found in virtual environment: {venv_certbot}. "
203+
f"This indicates the environment setup failed. "
204+
f"Python executable: {sys.executable}"
205+
)
196206

197207
def _debug_plugin_registration(self) -> None:
198208
"""Debug why plugin is not being registered by certbot."""

0 commit comments

Comments
 (0)