feat(run): debug Python on SSH run targets (#6696)

Debug on a Python configuration with an SSH run target now starts the program under the debugpy bootstrap listening on the host's loopback interface, forwards a local port through the SSH session and attaches with the project root mapped onto the target folder. When the host's interpreter has no debugpy, the IDE's copy is uploaded once to ~/.openidea/debug/<version> (written to a temporary folder and renamed into place so concurrent runs don't see partial files); without a local copy the error offers to install it. The check times out after 30 s, and the run fails if debugpy is not ready 120 s after start. The launch parameter containerDebug is renamed targetDebug.

Closes #6695

Co-authored-by: wildcatDownstairs <[email protected]>
Цей коміт міститься в:
LU XIANGRUIтаwildcatDownstairs authored and GitHub committed 2026-11-29 14:03:48 +08:00
1 джерело f151498e07
коміт df40f0befe
25 files changed
+545 -150

No files matched your search

+5 -1
Переглянути файл
@@ -475,7 +475,11 @@ async fn start_inner(
);
}
let out = on_output.clone();
return host.remote.run(&settings, &project.root, &config, sink.clone(), Box::new(move |c| out(c))).await;
let debugpy = container::ide_debugpy(&host.data_dir);
return host
.remote
.run(&settings, &project.root, &config, debugpy.as_deref(), sink.clone(), Box::new(move |c| out(c)))
.await;
}
let mut config = config;
let (root, settings, fallback) = settings_for(host, &project, &mut config)?;
+10 -9
Переглянути файл
@@ -9,16 +9,13 @@ use ide_remote::docker::{
ComposeService, ContainerDebug, ContainerRun, DEBUG_BOOTSTRAP, DEBUG_BOOTSTRAP_NAME, compose_container_root,
compose_service, container_config, container_name, default_container_root,
};
use ide_remote::target::DEBUG_PARAM;
use ide_run::RunConfig;
use std::collections::{BTreeMap, HashMap};
use std::path::{Path, PathBuf};
use std::sync::{LazyLock, Mutex};
use std::time::SystemTime;
/// Set by the Debug action on a configuration that runs on a container target: the
/// program starts under debugpy and waits for the debugger.
const DEBUG_PARAM: &str = "containerDebug";
/// `config` rewritten to run in a new container of `target`'s image or service.
pub(super) async fn prepare(host: &Host, root: &Path, target: RunTarget, config: RunConfig) -> IdeResult<RunConfig> {
if config.kind == "dotnet" || config.kind == "dotnet-test" {
@@ -177,14 +174,18 @@ impl Debugging {
let bootstrap_dir = data_dir.join("container-debug");
std::fs::create_dir_all(&bootstrap_dir)?;
std::fs::write(bootstrap_dir.join(DEBUG_BOOTSTRAP_NAME), DEBUG_BOOTSTRAP)?;
// The managed install the local debugger falls back to (`ide_dap::adapter::prepare_debugpy`).
let tools = ide_dap::adapter::tools_root().unwrap_or_else(|| ide_tools::tools_dir(data_dir));
let lib = ide_tools::python_lib_dir(&tools, ide_dap::adapter::DEBUGPY_TOOL);
let debugpy = lib.join("debugpy").join("__init__.py").is_file().then_some(lib);
Ok(Self { port: free_port()?, bootstrap_dir, debugpy })
Ok(Self { port: free_port()?, bootstrap_dir, debugpy: ide_debugpy(data_dir) })
}
}
/// The managed install the local debugger falls back to (`ide_dap::adapter::prepare_debugpy`):
/// the folder holding the `debugpy` package, when it is installed.
pub(super) fn ide_debugpy(data_dir: &Path) -> Option<PathBuf> {
let tools = ide_dap::adapter::tools_root().unwrap_or_else(|| ide_tools::tools_dir(data_dir));
let lib = ide_tools::python_lib_dir(&tools, ide_dap::adapter::DEBUGPY_TOOL);
lib.join("debugpy").join("__init__.py").is_file().then_some(lib)
}
/// A port nobody listens on here: debugpy listens on the same port in the container,
/// published on the loopback interface.
fn free_port() -> IdeResult<u16> {
+1 -1
Переглянути файл
@@ -116,7 +116,7 @@ async fn docker_targets_run_through_the_docker_cli() {
std::fs::write(lib.join("debugpy/__init__.py"), "").unwrap();
let mut debug = config("py", &root);
debug.debug_adapter = Some("debugpy".into());
debug.extras.params.insert("containerDebug".into(), "true".into());
debug.extras.params.insert("targetDebug".into(), "true".into());
let out = output_of(&host, debug.clone()).await;
let args: Vec<&str> = out.lines().filter_map(|l| l.strip_prefix("arg:")).collect();
let publish = args[args.iter().position(|a| *a == "--publish").unwrap() + 1];
+1 -1
Переглянути файл
@@ -240,7 +240,7 @@ async fn debugs_python_in_a_container() {
let mut debug = config("debug-main", "py", &root, &[&main.to_string_lossy()]);
debug.debug_adapter = Some("debugpy".into());
debug.extras.params.insert("containerDebug".into(), "true".into());
debug.extras.params.insert("targetDebug".into(), "true".into());
let (_, out) = start(&host, debug).await;
let mut ready = None;
for _ in 0..1200 {
+15 -6
Переглянути файл
@@ -268,7 +268,15 @@ pub fn container_config(config: &RunConfig, run: &ContainerRun) -> IdeResult<Run
}
(Some(line), None) => args.extend(["sh".into(), "-c".into(), line]),
(None, Some(debug)) => {
args.extend(debug_command(&command.program, &command.args, target, debug.port, run.container_root)?)
let bootstrap = format!("{DEBUG_DIR}/{DEBUG_BOOTSTRAP_NAME}");
args.extend(debug_command(
&command.program,
&command.args,
target,
debug.port,
run.container_root,
&bootstrap,
)?)
}
(None, None) => {
args.push(command.program);
@@ -339,16 +347,17 @@ fn is_python(program: &str) -> bool {
name == "python" || name == "python2" || name.starts_with("python3")
}
/// The container's command line that runs `program args` under [`DEBUG_BOOTSTRAP`]:
/// `python [options] <bootstrap> <port> <folder> (script | -m module | -c code) args`.
/// The command line that runs `program args` under [`DEBUG_BOOTSTRAP`] (at `bootstrap` in the
/// container or on the SSH host): `python [options] <bootstrap> <port> <folder> (script | -m module | -c code) args`.
/// A console script (`pytest`) runs as a module of the interpreter next to it, or of the
/// target's; `uv run …` and the like keep the manager in front.
fn debug_command(
pub(crate) fn debug_command(
program: &str,
args: &[String],
target: &RunTarget,
port: u16,
folder: &str,
bootstrap: &str,
) -> IdeResult<Vec<String>> {
let tool_module = |tool: &str, rest: &[String]| -> Vec<String> {
let module = tool.rsplit('/').next().unwrap_or(tool).to_owned();
@@ -362,7 +371,7 @@ fn debug_command(
{
if args[1].starts_with('-') {
return Err(IdeError::invalid(
"container debugging does not support runner options before the executable: use `uv run python script.py` or `uv run pytest` with options after the script or module",
"debugging on a run target does not support runner options before the executable: use `uv run python script.py` or `uv run pytest` with options after the script or module",
));
}
if is_python(&args[1]) {
@@ -398,7 +407,7 @@ fn debug_command(
}
_ => {}
}
line.extend([format!("{DEBUG_DIR}/{DEBUG_BOOTSTRAP_NAME}"), port.to_string(), folder.to_owned()]);
line.extend([bootstrap.to_owned(), port.to_string(), folder.to_owned()]);
line.extend(rest.iter().cloned());
Ok(line)
}
+1 -1
Переглянути файл
@@ -16,6 +16,6 @@ pub use deploy::{
};
pub use mapping::{Excludes, Mappings, ResolvedMapping};
pub use service::{DeployedPath, DeploymentRoot, RemoteService, default_targets};
pub use target::{RemoteRuns, RemoteStart};
pub use target::{RemoteDebug, RemoteRuns, RemoteStart};
pub mod plugin_target;
+18 -11
Переглянути файл
@@ -1,34 +1,41 @@
"""Debugs a run configuration in a container, for OpenIDEA's Docker and Compose run targets.
"""Debugs a run configuration on an OpenIDEA run target: in a Docker or Compose container, or on an SSH host.
openidea_debug.py PORT PROJECT_FOLDER (SCRIPT | -m MODULE | -c CODE) [ARGS...]
debugpy listens on PORT (published on the host's loopback interface) and the IDE
attaches once the line below is printed. The image's debugpy is used when it has
one, else the IDE's copy mounted read-only next to this script.
debugpy listens on PORT and the IDE attaches once the line below is printed. In a
container, PORT is published on the host's loopback interface; on an SSH host,
debugpy listens on its loopback interface (OPENIDEA_DEBUG_HOST) and the IDE connects
through an SSH port forward. The interpreter's debugpy is used when it has one, else
the IDE's copy: mounted read-only in a container, uploaded to OPENIDEA_DEBUGPY_LIB on an SSH host.
"""
import os
import runpy
import sys
IDE_COPY = "/opt/openidea/debugpy-lib"
def main():
del sys.path[0] # This script's folder, not the program's.
# Popped: the program and its children don't see them.
ide_copy = os.environ.pop("OPENIDEA_DEBUGPY_LIB", "/opt/openidea/debugpy-lib")
host = os.environ.pop("OPENIDEA_DEBUG_HOST", "0.0.0.0")
port, folder, argv = int(sys.argv[1]), sys.argv[2], sys.argv[3:]
# Uploads are over: the IDE waits a limited time for the line below from here on.
print("debugpy is starting", file=sys.stderr, flush=True)
try:
import debugpy
except ImportError:
sys.path.append(IDE_COPY)
sys.path.append(ide_copy)
try:
import debugpy
except ImportError:
sys.exit(
"debugpy is not installed in the image. Install OpenIDEA's copy (Settings > Tools) "
"or add debugpy to the image."
"debugpy is not installed for %s. Install OpenIDEA's copy (Settings > Tools) "
"or install debugpy for this interpreter." % sys.executable
)
debugpy.listen(("0.0.0.0", port))
try:
debugpy.listen((host, port))
except RuntimeError as e: # The port is taken (on an SSH host, the IDE picked a port free on its machine).
sys.exit("debugpy cannot listen on port %d: %s. Start debugging again to use another port." % (port, e))
print(
"debugpy is waiting for the debugger on port %d, project folder %s" % (port, folder),
file=sys.stderr,
+156 -2
Переглянути файл
@@ -3,7 +3,10 @@
use crate::deploy::{Deployment, FileStamp, SyncEntry, SyncStatus, SyncStep, TransferError, TransferReport, status};
use crate::mapping::{Excludes, Mappings, ResolvedMapping, posix};
use crate::target::{RemoteRuns, RemoteStart, SyncFn, rewrite_external_classpath};
use crate::target::{
DEBUG_PARAM, PROBE_NO_FOLDER, RemoteDebug, RemoteRuns, RemoteStart, SyncFn, debug_interpreter, debugpy_probe,
remote_command, rewrite_external_classpath, ssh_debug_command,
};
use ide_core::remote_settings::{AutoUpload, DeploymentServer, DeploymentType, RunTarget};
use ide_core::settings::Settings;
use ide_core::{CancellationToken, IdeError, IdeResult, SharedSink};
@@ -421,11 +424,14 @@ impl RemoteService {
// --- run targets ---------------------------------------------------------------
/// Starts `config` on its run target.
/// `debugpy_lib`: the IDE's debugpy (the folder holding the `debugpy` package), uploaded for
/// a debug run when the target's interpreter has none.
pub async fn run(
&self,
settings: &Settings,
root: &Path,
config: &RunConfig,
debugpy_lib: Option<&Path>,
sink: SharedSink,
on_output: Box<dyn Fn(OutputChunk) + Send + Sync>,
) -> IdeResult<RunInfo> {
@@ -470,6 +476,17 @@ impl RemoteService {
)));
}
}
let (debug, upload) = if config.extras.params.get(DEBUG_PARAM).is_some_and(|v| v == "true") {
match prepare_debug(&session, &fs, &target, &config, root, &remote_root, debugpy_lib).await {
Ok((debug, upload)) => (Some(debug), upload),
Err(e) => {
fs.close().await;
return Err(e);
}
}
} else {
(None, None)
};
let sync: Option<SyncFn> = if target.sync_before_run {
let deployment = settings.deployment.clone();
let root = root.to_path_buf();
@@ -532,11 +549,137 @@ impl RemoteService {
fs.close().await;
None
};
let start = RemoteStart { session, target, root: root.to_path_buf(), remote_root, sync };
// The project first, then the IDE's debugpy.
let sync = match (sync, upload) {
(sync, None) => sync,
(None, upload) => upload,
(Some(sync), Some(upload)) => {
let both: SyncFn = Box::new(move |out| {
Box::pin(async move {
sync(out.clone()).await?;
upload(out).await
})
});
Some(both)
}
};
let start = RemoteStart { session, target, root: root.to_path_buf(), remote_root, sync, debug };
Ok(self.runs.start(start, &config, sink, on_output))
}
}
/// Where the debug bootstrap and the IDE's debugpy go on an SSH host, under its home folder.
const DEBUG_FOLDER: &str = ".openidea/debug";
/// How long the check for debugpy on an SSH host may take.
const PROBE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
/// `openidea_debug-<hash of script>.py`: each version of the bootstrap gets its own file.
fn bootstrap_name(script: &str) -> String {
let hash = script.bytes().fold(0xcbf2_9ce4_8422_2325_u64, |h, b| (h ^ u64::from(b)).wrapping_mul(0x100_0000_01b3));
format!("openidea_debug-{hash:016x}.py")
}
/// Renames the finished `partial` to `path`. SFTP refuses to rename onto an existing entry, so
/// when a concurrent run has put its copy there first, that one stays and `partial` goes.
async fn settle(fs: &RemoteFs, partial: &str, path: &str) -> IdeResult<()> {
match fs.rename(partial, path).await {
Ok(()) => Ok(()),
Err(_) if fs.stat(path).await?.is_some() => {
let _ = fs.remove(partial).await;
Ok(())
}
Err(e) => Err(e),
}
}
/// A debug run of `config` on an SSH target: writes the bootstrap to the host, picks the IDE's
/// debugpy for an interpreter without one (the upload, when the host doesn't have this version
/// yet, runs before the program) and forwards a free local port to the same port on the host's
/// loopback interface, where debugpy listens.
async fn prepare_debug(
session: &Arc<ide_ssh::Session>,
fs: &RemoteFs,
target: &RunTarget,
config: &RunConfig,
root: &Path,
remote_root: &str,
debugpy_lib: Option<&Path>,
) -> IdeResult<(RemoteDebug, Option<SyncFn>)> {
if config.debug_adapter.as_deref() != Some("debugpy") {
return Err(IdeError::invalid(format!(
"'{}' can't be debugged on an SSH run target: only Python run configurations can",
config.name
)));
}
let dir = join(&fs.home().await?, DEBUG_FOLDER);
let port = std::net::TcpListener::bind(("127.0.0.1", 0))?.local_addr()?.port();
// Unique among this machine's debug runs; other machines' runs use other temporary names too.
let temp = |path: &str| format!("{path}.{}-{port}.tmp", std::process::id());
// Named after its content and never rewritten: a concurrent run may be reading it.
let bootstrap = join(&dir, &bootstrap_name(crate::docker::DEBUG_BOOTSTRAP));
if fs.stat(&bootstrap).await?.is_none() {
let partial = temp(&bootstrap);
fs.write(&partial, crate::docker::DEBUG_BOOTSTRAP.as_bytes(), None).await?;
settle(fs, &partial, &bootstrap).await?;
}
let plain = remote_command(config, target, root, remote_root);
let mut command = ssh_debug_command(&plain, target, remote_root, port, &bootstrap, None)?;
let mut upload: Option<SyncFn> = None;
let probe = tokio::time::timeout(PROBE_TIMEOUT, session.exec(&debugpy_probe(&command, &bootstrap), None))
.await
.map_err(|_| {
IdeError::unavailable(format!(
"{} did not answer within {} seconds while checking for debugpy",
session.label(),
PROBE_TIMEOUT.as_secs()
))
})??
.code;
// Before the first sync the project's interpreter can't be asked: the IDE's copy is the fallback
// when there is one, else the bootstrap reports a missing debugpy itself.
let unknown = probe == Some(PROBE_NO_FOLDER);
if probe != Some(0) && !(unknown && debugpy_lib.is_none()) {
let Some(lib) = debugpy_lib else {
return Err(IdeError::unavailable(format!(
"debugpy is not installed for {} on {}. Install OpenIDEA's copy, which is uploaded to the host for debugging, or install debugpy there",
debug_interpreter(&command, &bootstrap).display(),
session.label()
)));
};
// One folder per debugpy version (its `.dist-info` name), renamed into place once complete.
let version = std::fs::read_dir(lib)?
.flatten()
.filter_map(|e| e.file_name().to_str()?.strip_suffix(".dist-info").map(str::to_owned))
.next()
.unwrap_or_else(|| "debugpy".into());
let remote_lib = join(&dir, &version);
command = ssh_debug_command(&plain, target, remote_root, port, &bootstrap, Some(&remote_lib))?;
if fs.stat(&remote_lib).await?.is_none() {
let copy = RemoteFs::new(session.sftp().await?);
let lib = lib.to_path_buf();
let partial = temp(&remote_lib);
upload = Some(Box::new(move |out| {
Box::pin(async move {
out(OutputChunk::System { text: format!("Uploading OpenIDEA's debugpy to {remote_lib}...\n") });
let result = match sync_external_libraries(&copy, &[(lib, partial.clone())], true).await {
Ok(_) => settle(&copy, &partial, &remote_lib).await,
Err(e) => Err(e),
};
copy.close().await;
result
})
}));
}
}
let tunnel = ide_ssh::Tunnel::listen_on(session.clone(), Some(port), "127.0.0.1", port).await?;
if tunnel.port() != port {
return Err(IdeError::unavailable(format!(
"local port {port} for the debugger was taken meanwhile; try again"
)));
}
Ok((RemoteDebug { command, tunnel }, upload))
}
/// Uploads outside-root classpath entries to their mirrored remote copies,
/// skipping files the remote already has (same size and time). Returns the
/// uploaded count. Missing locals are rejected in `run` before the sync starts.
@@ -774,3 +917,14 @@ mod download_into_tests {
assert_eq!(download_target(dir, "/srv/..", "/srv/.."), None);
}
}
#[cfg(test)]
mod tests {
#[test]
fn each_bootstrap_version_gets_its_own_file() {
let name = super::bootstrap_name("print(1)\n");
assert_eq!(name, super::bootstrap_name("print(1)\n"));
assert_ne!(name, super::bootstrap_name("print(2)\n"));
assert!(name.starts_with("openidea_debug-") && name.ends_with(".py"), "{name}");
}
}
+108 -1
Переглянути файл
@@ -118,6 +118,64 @@ pub fn argv_command(config: &RunConfig, target: &RunTarget, root: &Path, remote_
target_command(config, target, root, remote_root, false)
}
/// Set by the Debug action on a configuration that runs on a run target: the Python program
/// starts under debugpy and waits for the debugger.
pub const DEBUG_PARAM: &str = "targetDebug";
/// `command` (an SSH target's) under the debug bootstrap at `bootstrap`: debugpy listens on the
/// host's loopback `port`, which the IDE reaches through an SSH forward. `debugpy_lib` is the
/// IDE's uploaded copy, for an interpreter without debugpy.
pub fn ssh_debug_command(
command: &RemoteCommand,
target: &RunTarget,
remote_root: &str,
port: u16,
bootstrap: &str,
debugpy_lib: Option<&str>,
) -> IdeResult<RemoteCommand> {
if command.shell_line.is_some() {
return Err(IdeError::invalid(
"a shell command line can't be debugged on a run target: set Command to the Python executable and put the script or -m module in Arguments",
));
}
let line = crate::docker::debug_command(&command.program, &command.args, target, port, remote_root, bootstrap)?;
let mut env = command.env.clone();
env.insert("OPENIDEA_DEBUG_HOST".into(), "127.0.0.1".into());
if let Some(lib) = debugpy_lib {
env.insert("OPENIDEA_DEBUGPY_LIB".into(), lib.into());
}
Ok(RemoteCommand {
program: line[0].clone(),
args: line[1..].to_vec(),
cwd: command.cwd.clone(),
env,
shell_line: None,
})
}
/// The interpreter of an [`ssh_debug_command`] (with its options, or behind `uv run`).
pub fn debug_interpreter(debug: &RemoteCommand, bootstrap: &str) -> RemoteCommand {
let end = debug.args.iter().position(|a| a == bootstrap).unwrap_or(debug.args.len());
RemoteCommand { args: debug.args[..end].to_vec(), ..debug.clone() }
}
/// Exit status of [`debugpy_probe`] when the project folder is not on the host yet (the first
/// sync runs later): a project interpreter or `uv run` can't be asked before it.
pub const PROBE_NO_FOLDER: u32 = 97;
/// The command line that exits with 0 when the interpreter of an [`ssh_debug_command`] has
/// debugpy, [`PROBE_NO_FOLDER`] when its folder does not exist yet.
pub fn debugpy_probe(debug: &RemoteCommand, bootstrap: &str) -> String {
let probe = debug_interpreter(debug, bootstrap);
let mut args = probe.args;
args.extend(["-c".into(), "import debugpy".into()]);
format!(
"cd {} 2>/dev/null || exit {PROBE_NO_FOLDER}; {}",
ide_ssh::shell::quote(&probe.cwd),
ide_ssh::shell::command_line(None, &probe.env, &probe.program, &args)
)
}
/// `java` flags whose value is a path list that may point outside the project
/// (`~/.m2` jars, `--module-path` entries): deployment sync only uploads the
/// project root, so these entries need their own sync + rewrite (#2641).
@@ -291,6 +349,15 @@ pub struct RemoteStart {
pub remote_root: String,
/// Uploads local changes first (`sync_before_run`).
pub sync: Option<SyncFn>,
/// A debug run: started under debugpy instead of the configuration's own command.
pub debug: Option<RemoteDebug>,
}
/// The command of a debug run and the SSH forward the debugger connects through,
/// which closes when the run ends.
pub struct RemoteDebug {
pub command: RemoteCommand,
pub tunnel: ide_ssh::Tunnel,
}
impl RemoteRuns {
@@ -329,7 +396,10 @@ impl RemoteRuns {
});
self.runs.lock().insert(id, run.clone());
let on_output: OutputFn = Arc::from(on_output);
let command = remote_command(config, &start.target, &start.root, &start.remote_root);
let command = match &start.debug {
Some(debug) => debug.command.clone(),
None => remote_command(config, &start.target, &start.root, &start.remote_root),
};
tokio::spawn(async move {
let code = run_remote(&run, start, command, pty, on_output.clone()).await;
let message = match &code {
@@ -486,6 +556,43 @@ mod tests {
assert_eq!(c.program, "make");
}
#[cfg(unix)]
#[test]
fn debugs_python_on_an_ssh_host_through_its_loopback_port() {
let target = RunTarget { python: "/opt/py/bin/python".into(), ..Default::default() };
let root = Path::new("/work/proj");
let bootstrap = "/home/me/.openidea/debug/openidea_debug.py";
let plain = remote_command(
&config("/work/proj/.venv/bin/python", &["-u", "/work/proj/src/main.py", "--n", "1"], None),
&target,
root,
"/home/me/proj",
);
let debug = ssh_debug_command(&plain, &target, "/home/me/proj", 50123, bootstrap, None).unwrap();
assert_eq!(debug.program, "/opt/py/bin/python");
// Interpreter options stay in front of the bootstrap; the project folder is the remote one.
assert_eq!(debug.args, ["-u", bootstrap, "50123", "/home/me/proj", "/home/me/proj/src/main.py", "--n", "1"]);
assert_eq!(debug.env["OPENIDEA_DEBUG_HOST"], "127.0.0.1");
assert!(!debug.env.contains_key("OPENIDEA_DEBUGPY_LIB"));
// A folder the first sync has yet to create is told apart from a missing debugpy.
assert_eq!(
debugpy_probe(&debug, bootstrap),
"cd /home/me/proj 2>/dev/null || exit 97; exec env DATA=/home/me/proj/data OPENIDEA_DEBUG_HOST=127.0.0.1 /opt/py/bin/python -u -c 'import debugpy'"
);
// A console script runs as a module; the IDE's uploaded copy is the fallback.
let pytest = remote_command(&config("pytest", &["tests"], None), &target, root, "/home/me/proj");
let lib = "/home/me/.openidea/debug/debugpy-1.8.22";
let debug = ssh_debug_command(&pytest, &target, "/home/me/proj", 50123, bootstrap, Some(lib)).unwrap();
assert_eq!(debug.program, "/opt/py/bin/python");
assert_eq!(debug.args, [bootstrap, "50123", "/home/me/proj", "-m", "pytest", "tests"]);
assert_eq!(debug.env["OPENIDEA_DEBUGPY_LIB"], lib);
assert_eq!(debug_interpreter(&debug, bootstrap).display(), "/opt/py/bin/python");
let shell = remote_command(&config("python main.py", &[], None), &target, root, "/home/me/proj");
assert!(ssh_debug_command(&shell, &target, "/home/me/proj", 50123, bootstrap, None).is_err());
}
#[test]
fn maps_the_root_only_as_a_whole_path() {
assert_eq!(replace_root("/work/proj2/x:/work/proj/y", "/work/proj", "/srv"), "/work/proj2/x:/srv/y");
+1
Переглянути файл
@@ -443,6 +443,7 @@ async fn runs_a_configuration_on_a_target() {
root: env.project.clone(),
remote_root: "/home/dev/demo".into(),
sync: None,
debug: None,
};
let info = runs.start(
start,
+1 -1
Переглянути файл
@@ -115,7 +115,7 @@ The debugger adds attach-only types such as **Remote JVM Debug**, **Go Remote**,
### Common fields
- **Run on**: the local machine, or an SSH host defined in **Settings › Build, Execution, Deployment › Run Targets**. Debugging is not available on run targets. See [SSH](/en/guide/remote/ssh).
- **Run on**: the local machine, or an SSH host defined in **Settings › Build, Execution, Deployment › Run Targets**. Only Python configurations can be debugged on a run target; see [Python debugging](/en/languages/python#debugging). See [SSH](/en/guide/remote/ssh).
- **Working directory**: relative to the project root; empty means the project root. It may use the path macros `$PROJECT_DIR$`, `$ContentRoot$`, `$MODULE_DIR$`, `$MODULE_WORKING_DIR$` and `$USER_HOME$`, expanded when the configuration starts, so a shared configuration works on every machine.
- **Environment variables**: `VAR=value` pairs separated by `;`. The list button opens the **Environment Variables** dialog, where **Include system environment variables** can be turned off.
- **Debug adapter**: which debugger **Debug** uses for this configuration (for example `debugpy`, `js-debug`, `codelldb`, `delve`).
+1
Переглянути файл
@@ -156,6 +156,7 @@ Python debugging uses debugpy. If it is missing when you start a debug session,
- Scripts, `python -m` modules and console scripts such as `pytest` or `uvicorn` can be debugged. Programs started through `uv run`, `poetry run`, `pdm run`, `pipenv run`, `hatch run` or `rye run` run in that manager's environment.
- Debugging `manage.py` enables Django support in debugpy.
- A configuration that runs on an SSH, Docker or Compose run target is debugged there: the program starts under debugpy on the target and the debugger attaches with the project folder mapped onto the target's. On an SSH host, debugpy listens on the host's loopback interface and the IDE connects through the SSH connection. When the host's interpreter has no debugpy, the IDE uploads its own copy to `~/.openidea/debug` on the host (once per debugpy version). As with `debugpy --listen`, other users of the host can connect to that port until the debugger has attached.
- **Attach to Process…** (`⌥⇧F5` / `Ctrl+Alt+F5`) lists local Python processes under **Python (debugpy)**.
- The **Python Remote Debug (debugpy)** configuration attaches to a process started with `python -m debugpy --listen`, locally or on another machine, with local and remote root mapping.
- The **Python Debug Server** configuration works the other way round: the IDE listens and the program connects with `import debugpy; debugpy.connect(("localhost", 5678)); debugpy.wait_for_client()`, from a container or another machine too. Install the IDE debugger's debugpy version where the program runs; the Debug console warns when they differ. A VS Code `attach` with `"listen"` imports as this configuration; its `listen.host` `0.0.0.0` is where VS Code binds, so it imports as `localhost`. For a program in a container or on another machine, set the IDE host name to an address it can reach, such as `host.docker.internal`.
+1 -1
Переглянути файл
@@ -111,7 +111,7 @@ description: "创建、编辑和启动运行配置,从装订区运行代码,
### 通用字段
- **运行于**:本地计算机,或在 **设置 › 构建、执行、部署 › 运行目标** 中添加的 SSH 主机。运行目标上不支持调试。参见 [SSH](/zh/guide/remote/ssh)。
- **运行于**:本地计算机,或在 **设置 › 构建、执行、部署 › 运行目标** 中添加的 SSH 主机。运行目标上只能调试 Python 配置,见 [Python 调试](/zh/languages/python#调试)。参见 [SSH](/zh/guide/remote/ssh)。
- **工作目录**:相对于项目根目录,留空即项目根目录。可以使用路径宏 `$PROJECT_DIR$`、`$ContentRoot$`、`$MODULE_DIR$`、`$MODULE_WORKING_DIR$` 和 `$USER_HOME$`,在配置启动时展开,因此共享的配置在每台机器上都能用。
- **环境变量**:`VAR=value` 形式,用 `;` 分隔。点旁边的列表按钮打开“环境变量”对话框,可以关闭 **包括系统环境变量**。
- **调试适配器**:按“调试”时这个配置使用哪个调试器(如 `debugpy`、`js-debug`、`codelldb`、`delve`)。
+1
Переглянути файл
@@ -156,6 +156,7 @@ Python 调试使用 debugpy。开始调试时如果缺少 debugpy,OpenIDEA 会
- 可以调试脚本、`python -m` 模块,以及 `pytest`、`uvicorn` 这类命令行入口。通过 `uv run`、`poetry run`、`pdm run`、`pipenv run`、`hatch run` 或 `rye run` 启动的程序会在对应管理器的环境中运行。
- 调试 `manage.py` 时会开启 debugpy 的 Django 支持。
- 在 SSH、Docker 或 Compose 运行目标上运行的配置,会在目标上调试:程序在目标上以 debugpy 启动,调试器附加时把项目文件夹映射到目标上的文件夹。在 SSH 主机上,debugpy 只监听主机的回环地址,IDE 通过 SSH 连接访问它。主机的解释器没有 debugpy 时,IDE 会把自己的那份上传到主机的 `~/.openidea/debug`(每个 debugpy 版本上传一次)。和 `debugpy --listen` 一样,在调试器附加之前,主机上的其他用户也能连接这个端口。
- **附加到进程…**(`⌥⇧F5` / `Ctrl+Alt+F5`)会在 **Python (debugpy)** 分组下列出本机的 Python 进程。
- **Python 远程调试 (debugpy)** 配置可以附加到用 `python -m debugpy --listen` 启动的进程,本机或远程机器都可以,并支持本地与远程根目录映射。
- **Python 调试服务器** 配置方向相反:由 IDE 监听,程序用 `import debugpy; debugpy.connect(("localhost", 5678)); debugpy.wait_for_client()` 连接进来,也可以从容器或其他机器连接。程序所在环境要安装与 IDE 调试器相同版本的 debugpy,版本不同时调试控制台会给出警告。VS Code 里带 `"listen"` 的 `attach` 会导入成这种配置;其中 `listen.host` 的 `0.0.0.0` 是 VS Code 的绑定地址,所以导入成 `localhost`。程序在容器或其他机器上时,要把 IDE 主机名改成程序能访问到的地址,例如 `host.docker.internal`。
+1 -1
Переглянути файл
@@ -430,7 +430,7 @@ function debugpyAttach(
});
}
/** A Python program debugged in a run target's container, waiting for the debugger (Run's `debugInContainer`). */
/** A Python program debugged on a run target (SSH host or container), waiting for the debugger (Run's `debugOnTarget`). */
export interface PythonAttachTarget {
name: string;
adapter: "debugpy";
-92
Переглянути файл
@@ -1,92 +0,0 @@
/**
* Debugging Python on Docker / Compose run targets: the run starts the program in a new
* container under debugpy (the bootstrap of `ide_remote::docker`), which prints its port
* once it listens; the debugger then attaches like a Python Remote Debug configuration,
* with the project folder mapped. Output stays in the Run tab; stopping the debugger
* stops the container.
*/
import { executeAction } from "@/platform/actions";
import type { RunConfig } from "@/platform/ipc";
import { tx } from "@/platform/i18n";
import { notifications } from "@/workbench/contributions";
import { isLive, startRun, stopSession, useRun } from "./store";
/** The bootstrap's line (`ide_remote::docker::DEBUG_READY`). */
const READY = /^debugpy is waiting for the debugger on port (\d+), project folder (.+)$/;
interface Ready {
port: number;
remoteRoot: string;
}
/** Where the debugger attaches, from an output line of a container debug run. */
export function debugpyReady(line: string): Ready | null {
const m = READY.exec(line.trim());
return m ? { port: Number(m[1]), remoteRoot: m[2]! } : null;
}
/** `config` as the backend runs it for debugging: under debugpy, waiting for the debugger. */
export function containerDebugLaunch(config: RunConfig): RunConfig {
return { ...config, params: { ...config.params, containerDebug: "true" } };
}
/** Runs `config` in its container under debugpy and attaches the debugger. */
export async function debugInContainer(config: RunConfig): Promise<void> {
let sessionId: string | null = null;
let ready: Ready | null = null;
let done = false;
const pending: { timer?: ReturnType<typeof setTimeout>; unsubscribe?: () => void } = {};
const finish = () => {
done = true;
clearTimeout(pending.timer);
pending.unsubscribe?.();
};
const fail = (body: string) => {
finish();
notifications().notify({ group: "run", level: "error", title: tx("Cannot start container debugging"), body });
};
const attach = ({ port, remoteRoot }: Ready) => {
if (done) return;
finish();
const runId = useRun.getState().sessions.find((s) => s.id === sessionId)?.runId ?? null;
void executeAction("debug.attach", {
name: config.name,
adapter: "debugpy",
hostName: "127.0.0.1",
port,
remoteRoot,
process: runId,
runConfig: config,
});
};
const session = await startRun(config, undefined, undefined, {
launch: containerDebugLaunch(config),
onLine: (line) => {
if (done) return;
const parsed = debugpyReady(line);
if (!parsed) return;
ready = parsed;
if (sessionId) attach(ready);
},
});
if (!session) return;
sessionId = session.id;
const check = () => {
const current = useRun.getState().sessions.find((s) => s.id === sessionId);
if (!current || current.stopped || current.status === "failed") finish();
else if (!isLive(current))
fail(tx("The container exited before debugpy was ready. Check the Run console for errors."));
};
pending.unsubscribe = useRun.subscribe(check);
check();
if (done) return;
pending.timer = setTimeout(() => {
fail(
tx(
"debugpy did not become ready within 120 seconds. Check the Run console and the container's Python interpreter.",
),
);
void stopSession(session.id);
}, 120_000);
if (ready) attach(ready);
}
+5 -5
Переглянути файл
@@ -71,8 +71,8 @@ import { selectedBuildTarget } from "./buildTarget";
import { configurationChecks } from "./configurationChecks";
import { runBeforeLaunch } from "./beforeLaunch";
import { compoundChildren, createdConfigs } from "./configs";
import { containerDebuggable, remoteDebugBlocked } from "./remote";
import { debugInContainer } from "./containerDebug";
import { targetDebuggable, remoteDebugBlocked } from "./remote";
import { debugOnTarget } from "./targetDebug";
import { isDebugOnly, registerBuiltinTypes } from "./types";
import { isZigBuildStep, zigDebugTarget } from "./zigDebug";
import { junitType } from "./junitType";
@@ -208,9 +208,9 @@ async function debugLaunch(config: RunConfig, chain: readonly string[], show?: b
}
if (!(await prepareLaunch(config, chain, show))) return;
if (config.kind === UNITY_CONFIG_KIND) return showUnityAttach(config);
// Python on a Docker / Compose target: debugpy in the container, the debugger attaches.
if (containerDebuggable(config) && getAction("debug.attach")) {
await debugInContainer(config);
// Python on an SSH / Docker / Compose target: debugpy there, the debugger attaches.
if (targetDebuggable(config) && getAction("debug.attach")) {
await debugOnTarget(config);
return;
}
// A plugin configuration whose debugger attaches to a process the run starts.
+63 -2
Переглянути файл
@@ -213,10 +213,71 @@ describe("remote debugging", () => {
await executeAction("run.debugConfig", remote.id);
expect(startConfig).not.toHaveBeenCalled();
expect(notify).toHaveBeenCalledWith(
expect.objectContaining({ title: "Debugging on run targets is not supported", level: "warning" }),
expect.objectContaining({ title: "Only Python can be debugged on SSH run targets", level: "warning" }),
);
});
it("runs Python on an SSH host under debugpy and attaches through the forwarded port", async () => {
const attach = vi.fn();
const off = registerActions([{ id: "debug.attach", title: "Attach", run: ({ arg }) => attach(arg) }]);
vi.useFakeTimers();
try {
const py = cfg("app", { target: "box", debugAdapter: "debugpy" });
useRun.setState({ configs: [py], loaded: true });
ipc.runStart.mockResolvedValueOnce(ok);
await executeAction("run.debugConfig", py.id);
expect(ipc.runStart).toHaveBeenCalledWith(
expect.objectContaining({ id: "app", params: { targetDebug: "true" } }),
expect.anything(),
expect.any(Number),
);
// Uploading the project and debugpy may take longer than a container start: no timeout.
await vi.advanceTimersByTimeAsync(300_000);
expect(ipc.runStop).not.toHaveBeenCalled();
const channel = ipc.runStart.mock.calls.at(-1)![1] as { onmessage: (m: unknown) => void };
channel.onmessage({
kind: "stderr",
text: "debugpy is waiting for the debugger on port 50123, project folder /home/me/app\n",
});
await vi.waitFor(() =>
expect(attach).toHaveBeenCalledWith(
expect.objectContaining({ hostName: "127.0.0.1", port: 50123, remoteRoot: "/home/me/app", process: 3 }),
),
);
expect(notify).not.toHaveBeenCalled();
} finally {
vi.useRealTimers();
off();
}
});
it("stops an SSH debug run whose program never announces debugpy", async () => {
const off = registerActions([{ id: "debug.attach", title: "Attach", run: () => undefined }]);
vi.useFakeTimers();
try {
const py = cfg("app", { target: "box", debugAdapter: "debugpy" });
useRun.setState({ configs: [py], loaded: true });
ipc.runStart.mockResolvedValueOnce(ok);
await executeAction("run.debugConfig", py.id);
const channel = ipc.runStart.mock.calls.at(-1)![1] as { onmessage: (m: unknown) => void };
// Uploads take as long as they take; the wait starts with the program.
await vi.advanceTimersByTimeAsync(300_000);
expect(ipc.runStop).not.toHaveBeenCalled();
channel.onmessage({ kind: "stderr", text: "debugpy is starting\n" });
await vi.advanceTimersByTimeAsync(121_000);
expect(ipc.runStop).toHaveBeenCalledWith(3);
expect(notify).toHaveBeenCalledWith(
expect.objectContaining({
title: "Cannot start debugging on the SSH host",
body: expect.stringContaining("SSH host's Python interpreter"),
}),
);
} finally {
vi.useRealTimers();
off();
}
});
describe("in containers", () => {
const container: RunTargetValid = { ...DEFAULT_RUN_TARGET, kind: "docker", id: "py", name: "Python", image: "x" };
const attach = vi.fn();
@@ -312,7 +373,7 @@ describe("remote debugging", () => {
await executeAction("run.debugConfig", py.id);
expect(startConfig).not.toHaveBeenCalled();
expect(ipc.runStart).toHaveBeenCalledWith(
expect.objectContaining({ id: "app", params: { containerDebug: "true" } }),
expect.objectContaining({ id: "app", params: { targetDebug: "true" } }),
expect.anything(),
expect.any(Number),
);
+11 -12
Переглянути файл
@@ -78,32 +78,31 @@ export function containerTarget(
return target && inContainer(target) ? target.id : null;
}
/** A Python configuration on a Docker / Compose target: debugged in its container (`debugInContainer`). */
export function containerDebuggable(
config: RunConfig,
targets: readonly RuntimeRunTarget[] = allRunTargets(),
): boolean {
/** A Python configuration on an SSH, Docker or Compose target: debugged there (`debugOnTarget`). */
export function targetDebuggable(config: RunConfig, targets: readonly RuntimeRunTarget[] = allRunTargets()): boolean {
const target = targetOf(config, targets);
return !!target && inContainer(target) && config.debugAdapter === "debugpy";
return !!target && (target.kind === "ssh" || inContainer(target)) && config.debugAdapter === "debugpy";
}
/**
* Debugging on run targets isn't supported, except Python in containers: tells so
* (offering Run) and returns true when `config` can't be debugged where it runs.
* Debugging on run targets is supported for Python on SSH and container targets: tells
* so (offering Run) and returns true when `config` can't be debugged where it runs.
*/
export function remoteDebugBlocked(config: RunConfig, targets: readonly RuntimeRunTarget[] = allRunTargets()): boolean {
config = withRunTarget(config);
if (!config.target || containerDebuggable(config, targets)) return false;
if (!config.target || targetDebuggable(config, targets)) return false;
const target = targetName(config, targets) ?? config.target;
const container = targetOf(config, targets);
const where = targetOf(config, targets);
notifications().notify({
group: "run",
level: "warning",
key: "run.remoteDebug",
title:
container && inContainer(container)
where && inContainer(where)
? "Only Python can be debugged in containers"
: "Debugging on run targets is not supported",
: where?.kind === "ssh"
? "Only Python can be debugged on SSH run targets"
: "Debugging on run targets is not supported",
body: txTemplate(
`'${config.name}' runs on ${target}. Run it, or choose “Local machine” under “Run on” to debug it.`,
),
+3 -3
Переглянути файл
@@ -1,8 +1,8 @@
import { describe, expect, it } from "vitest";
import type { RunConfig } from "@/platform/ipc";
import { containerDebugLaunch, debugpyReady } from "./containerDebug";
import { debugpyReady, targetDebugLaunch } from "./targetDebug";
describe("container debugging", () => {
describe("debugging on run targets", () => {
it("reads the port and the project folder from the bootstrap's line", () => {
expect(
debugpyReady("debugpy is waiting for the debugger on port 41234, project folder /workspaces/my app\r"),
@@ -15,7 +15,7 @@ describe("container debugging", () => {
it("asks the backend for a debug run, keeping the configuration's parameters", () => {
const config = { id: "a", params: { module: "app" } } as unknown as RunConfig;
expect(containerDebugLaunch(config).params).toEqual({ module: "app", containerDebug: "true" });
expect(targetDebugLaunch(config).params).toEqual({ module: "app", targetDebug: "true" });
expect(config.params).toEqual({ module: "app" });
});
});
+119
Переглянути файл
@@ -0,0 +1,119 @@
/**
* Debugging Python on run targets: the run starts the program under debugpy (the bootstrap
* of `ide_remote::docker`) in a new container, or on the SSH host with an SSH forward of
* the port, and the bootstrap prints the port once debugpy listens; the debugger then
* attaches like a Python Remote Debug configuration, with the project folder mapped.
* Output stays in the Run tab; stopping the debugger stops the program.
*/
import { executeAction } from "@/platform/actions";
import type { RunConfig } from "@/platform/ipc";
import { tx } from "@/platform/i18n";
import { notifications } from "@/workbench/contributions";
import { inContainer } from "@/platform/remoteSettings";
import { targetOf } from "./remote";
import { isLive, startRun, stopSession, useRun } from "./store";
/** The bootstrap's first line, once the program has started. */
const STARTING = "debugpy is starting";
/** The bootstrap's line (`ide_remote::docker::DEBUG_READY`). */
const READY = /^debugpy is waiting for the debugger on port (\d+), project folder (.+)$/;
interface Ready {
port: number;
remoteRoot: string;
}
/** Where the debugger attaches, from an output line of a container debug run. */
export function debugpyReady(line: string): Ready | null {
const m = READY.exec(line.trim());
return m ? { port: Number(m[1]), remoteRoot: m[2]! } : null;
}
/** `config` as the backend runs it for debugging: under debugpy, waiting for the debugger. */
export function targetDebugLaunch(config: RunConfig): RunConfig {
return { ...config, params: { ...config.params, targetDebug: "true" } };
}
/** Runs `config` on its run target under debugpy and attaches the debugger. */
export async function debugOnTarget(config: RunConfig): Promise<void> {
const target = targetOf(config);
const container = !target || inContainer(target);
let sessionId: string | null = null;
let ready: Ready | null = null;
let done = false;
const pending: { timer?: ReturnType<typeof setTimeout>; unsubscribe?: () => void } = {};
const finish = () => {
done = true;
clearTimeout(pending.timer);
pending.unsubscribe?.();
};
const fail = (body: string) => {
finish();
notifications().notify({
group: "run",
level: "error",
title: container ? tx("Cannot start container debugging") : tx("Cannot start debugging on the SSH host"),
body,
});
};
const attach = ({ port, remoteRoot }: Ready) => {
if (done) return;
finish();
const runId = useRun.getState().sessions.find((s) => s.id === sessionId)?.runId ?? null;
void executeAction("debug.attach", {
name: config.name,
adapter: "debugpy",
hostName: "127.0.0.1",
port,
remoteRoot,
process: runId,
runConfig: config,
});
};
const startTimer = () => {
if (done || pending.timer) return;
pending.timer = setTimeout(() => {
fail(
container
? tx(
"debugpy did not become ready within 120 seconds. Check the Run console and the container's Python interpreter.",
)
: tx(
"debugpy did not become ready within 120 seconds. Check the Run console and the SSH host's Python interpreter.",
),
);
if (sessionId) void stopSession(sessionId);
}, 120_000);
};
const session = await startRun(config, undefined, undefined, {
launch: targetDebugLaunch(config),
onLine: (line) => {
if (done) return;
// Over SSH the project and debugpy may be uploaded first, for as long as the link needs:
// the wait starts with the program.
if (line.trim() === STARTING) startTimer();
const parsed = debugpyReady(line);
if (!parsed) return;
ready = parsed;
if (sessionId) attach(ready);
},
});
if (!session) return;
sessionId = session.id;
const check = () => {
const current = useRun.getState().sessions.find((s) => s.id === sessionId);
if (!current || current.stopped || current.status === "failed") finish();
else if (!isLive(current))
fail(
container
? tx("The container exited before debugpy was ready. Check the Run console for errors.")
: tx("The program exited before debugpy was ready. Check the Run console for errors."),
);
};
pending.unsubscribe = useRun.subscribe(check);
check();
if (done) return;
if (ready) return attach(ready);
if (container) startTimer();
}
+8
Переглянути файл
@@ -66,3 +66,11 @@ it("explains a plugin prefix Maven cannot resolve offline and links Maven settin
result.actions[0]!.run();
expect(executeAction).toHaveBeenCalledWith("file.settings", "build.maven");
});
it("offers OpenIDEA's debugpy when an SSH target's interpreter has none", () => {
const message = "debugpy is not installed for python3 on me@box. Install OpenIDEA's copy";
const result = buildToolRecovery(message);
expect(result.body).toBe(message);
result.actions[0]!.run();
expect(executeAction).toHaveBeenCalledWith("tools.install", "debugpy");
});
+5
Переглянути файл
@@ -11,6 +11,11 @@ export function buildToolRecovery(message: string) {
};
return { body: message, actions: [settings] };
}
// Debugging on an SSH run target whose interpreter has no debugpy: OpenIDEA's copy is uploaded there.
if (message.startsWith("debugpy is not installed")) {
const install = { label: tx("Install debugpy"), run: () => void executeAction("tools.install", "debugpy") };
return { body: message, actions: [install] };
}
const actions = downloadJdkActions(message);
if (/No plugin found for prefix '[^']+'/.test(message)) {
// Offline, or without the user's mirrors: the plugin group metadata is not in the local repository.
+5
Переглянути файл
@@ -1417,6 +1417,11 @@
"Open in HTTP Client": "Open in HTTP Client",
"Cannot generate the HTTP request": "Cannot generate the HTTP request",
"Cannot start container debugging": "Cannot start container debugging",
"Cannot start debugging on the SSH host": "Cannot start debugging on the SSH host",
"debugpy did not become ready within 120 seconds. Check the Run console and the SSH host's Python interpreter.": "debugpy did not become ready within 120 seconds. Check the Run console and the SSH host's Python interpreter.",
"The program exited before debugpy was ready. Check the Run console for errors.": "The program exited before debugpy was ready. Check the Run console for errors.",
"Only Python can be debugged on SSH run targets": "Only Python can be debugged on SSH run targets",
"Install debugpy": "Install debugpy",
"The container exited before debugpy was ready. Check the Run console for errors.": "The container exited before debugpy was ready. Check the Run console for errors.",
"debugpy did not become ready within 120 seconds. Check the Run console and the container's Python interpreter.": "debugpy did not become ready within 120 seconds. Check the Run console and the container's Python interpreter.",
"Only Python can be debugged in containers": "Only Python can be debugged in containers",
+5
Переглянути файл
@@ -8182,6 +8182,11 @@
"Cannot choose a directory": "无法选择目录",
"Open in HTTP Client": "在 HTTP 客户端中打开",
"Cannot start container debugging": "无法启动容器调试",
"Cannot start debugging on the SSH host": "无法在 SSH 主机上启动调试",
"debugpy did not become ready within 120 seconds. Check the Run console and the SSH host's Python interpreter.": "debugpy 在 120 秒内未就绪。请检查运行控制台和 SSH 主机上的 Python 解释器。",
"The program exited before debugpy was ready. Check the Run console for errors.": "程序在 debugpy 就绪前已退出。请检查运行控制台中的错误。",
"Only Python can be debugged on SSH run targets": "SSH 运行目标上只能调试 Python",
"Install debugpy": "安装 debugpy",
"The container exited before debugpy was ready. Check the Run console for errors.": "容器在 debugpy 就绪前已退出。请检查运行控制台中的错误。",
"debugpy did not become ready within 120 seconds. Check the Run console and the container's Python interpreter.": "debugpy 未在 120 秒内就绪。请检查运行控制台和容器的 Python 解释器。",
"Use Project JDK": "使用项目 SDK",