clan-cli: Fix garbled clan vms run output. docs: Improve debugging guide
This commit is contained in:
@@ -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.
|
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
|
## See all possible packages and tests
|
||||||
|
|
||||||
To quickly show all possible packages and tests execute:
|
To quickly show all possible packages and tests execute:
|
||||||
|
|||||||
@@ -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")
|
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
|
# Nix evaluation script to compute find inputs that have a "clan" attribute
|
||||||
eval_script = f"""
|
eval_script = f"""
|
||||||
let
|
let
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ def start_vm(
|
|||||||
env.update(extra_env)
|
env.update(extra_env)
|
||||||
cmd = nix_shell(packages, args)
|
cmd = nix_shell(packages, args)
|
||||||
machine.debug(f"Starting VM with command: {cmd}")
|
machine.debug(f"Starting VM with command: {cmd}")
|
||||||
|
|
||||||
with subprocess.Popen(
|
with subprocess.Popen(
|
||||||
cmd, env=env, stdout=stdout, stderr=stderr, stdin=stdin
|
cmd, env=env, stdout=stdout, stderr=stderr, stdin=stdin
|
||||||
) as process:
|
) as process:
|
||||||
@@ -354,7 +355,7 @@ def run_vm(
|
|||||||
stdout=sys.stdout.buffer,
|
stdout=sys.stdout.buffer,
|
||||||
stderr=sys.stderr.buffer,
|
stderr=sys.stderr.buffer,
|
||||||
input_bytes=None,
|
input_bytes=None,
|
||||||
log=Log.BOTH,
|
log=Log.NONE,
|
||||||
)
|
)
|
||||||
args: list[str] = vm.process.args # type: ignore[assignment]
|
args: list[str] = vm.process.args # type: ignore[assignment]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user