diff --git a/docs/site/manual/debugging.md b/docs/site/manual/debugging.md index 66ddd0c4c..de2675198 100644 --- a/docs/site/manual/debugging.md +++ b/docs/site/manual/debugging.md @@ -51,6 +51,20 @@ wintux If you're using VSCode, it has a handy feature that makes paths to source code files clickable in the integrated terminal. Combined with the previously mentioned techniques, this allows you to open a Clan in VSCode, execute a command like `clan machines list --debug`, and receive a printed path to the code that initiates the subprocess. With the `Ctrl` key (or `Cmd` on macOS) and a mouse click, you can jump directly to the corresponding line in the code file and add a `breakpoint()` function to it, to inspect the internal state. + + +## Finding Print Messages + +To identify where a specific print message comes from, you can enable a helpful feature. Simply set the environment variable `export TRACE_PRINT=1`. When you run commands with `--debug` mode, each print message will include information about its source location. + +If you need more details, you can expand the stack trace information that appears with each print by setting the environment variable `export TRACE_DEPTH=3`. + +## Analyzing Performance + +To understand what's causing slow performance, set the environment variable `export CLAN_CLI_PERF=1`. When you complete a clan command, you'll see a summary of various performance metrics, helping you identify what's taking up time. + + + ## See all possible packages and tests To quickly show all possible packages and tests execute: diff --git a/pkgs/clan-cli/clan_cli/templates.py b/pkgs/clan-cli/clan_cli/templates.py index 8c210b2c2..92e1fe7be 100644 --- a/pkgs/clan-cli/clan_cli/templates.py +++ b/pkgs/clan-cli/clan_cli/templates.py @@ -73,17 +73,6 @@ def get_clan_nix_attrset(clan_dir: Flake | None = None) -> ClanExports: log.debug(f"Evaluating flake {clan_dir} for Clan attrsets") - # from clan_cli.nix import nix_metadata - # from urllib.parse import urlencode - # myurl = f"path://{clan_dir}" - - # metadata = nix_metadata(myurl)["locked"] - # query_params = { - # "lastModified": metadata["lastModified"], - # "narHash": metadata["narHash"] - # } - # url = f"{myurl}?{urlencode(query_params)}" - # Nix evaluation script to compute find inputs that have a "clan" attribute eval_script = f""" let diff --git a/pkgs/clan-cli/clan_cli/vms/run.py b/pkgs/clan-cli/clan_cli/vms/run.py index 595d03ce2..b61dd5c87 100644 --- a/pkgs/clan-cli/clan_cli/vms/run.py +++ b/pkgs/clan-cli/clan_cli/vms/run.py @@ -129,6 +129,7 @@ def start_vm( env.update(extra_env) cmd = nix_shell(packages, args) machine.debug(f"Starting VM with command: {cmd}") + with subprocess.Popen( cmd, env=env, stdout=stdout, stderr=stderr, stdin=stdin ) as process: @@ -354,7 +355,7 @@ def run_vm( stdout=sys.stdout.buffer, stderr=sys.stderr.buffer, input_bytes=None, - log=Log.BOTH, + log=Log.NONE, ) args: list[str] = vm.process.args # type: ignore[assignment]