Skip to content

fix(init): honor RTK_TELEMETRY_DISABLED in consent prompt (#1307) - #2477

Merged
KuSh merged 3 commits into
rtk-ai:developfrom
ousamabenyounes:fix/issue-1307
Jul 20, 2026
Merged

KuSh merged 3 commits into
rtk-ai:developfrom
ousamabenyounes:fix/issue-1307

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1307.

rtk init's telemetry consent prompt only bailed on a non-TTY check. Some non-interactive environments (devcontainer postCreateCommand, certain CI agents) hand rtk a pseudo-TTY, so is_terminal() returns true and the prompt blocks forever waiting on stdin. RTK_TELEMETRY_DISABLED=1 is the documented opt-out and is honoured by telemetry::maybe_ping, but the consent prompt ignored it.

Fix

Add a telemetry_disabled_by_env() helper and short-circuit prompt_telemetry_consent() with return Ok(()) when RTK_TELEMETRY_DISABLED=1, before the TTY heuristic — mirroring the check already used in maybe_ping.

Test verification (RED → GREEN)

The hang itself only reproduces under a real pseudo-TTY, which the test harness can't provide; the original regression remains guarded by the unit test on telemetry_disabled_by_env().

RED - patch reverted (helper removed):

error[E0425]: cannot find function `telemetry_disabled_by_env` in this scope
error: could not compile `rtk` (bin "rtk" test) due to 4 previous errors

GREEN - with the original fix:

running 1 test
test result: ok. 1 passed; 0 failed

Reviewer follow-up RED - with the test-location change reverted:

FAIL: test missing from telemetry_cmd.rs

Reviewer follow-up GREEN - after moving the test to telemetry_cmd:

207:    fn test_telemetry_disabled_by_env_honors_opt_out() {
PASS: test lives in telemetry_cmd.rs
PASS: test removed from init.rs

Full gate after rebase onto current develop:

cargo fmt --all --check && cargo clippy --all-targets && cargo test
test result: ok. 2363 passed; 0 failed; 8 ignored
test result: ok. 6 passed; 0 failed
test result: ok. 11 passed; 0 failed
test result: ok. 6 passed; 0 failed
test result: ok. 14 passed; 0 failed
test result: ok. 5 passed; 0 failed
test result: ok. 11 passed; 0 failed

(Re-proposes the accidentally-closed #1369, rebased onto current develop.)

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM, thanks

Comment thread src/hooks/init.rs Resolved
@KuSh KuSh self-assigned this Jun 18, 2026
ousamabenyounes added a commit to ousamabenyounes/rtk that referenced this pull request Jun 18, 2026
Address KuSh review on rtk-ai#2477: export the `RTK_TELEMETRY_DISABLED`
opt-out check as a public `telemetry_cmd::telemetry_disabled_by_env()`
instead of a private copy in `init.rs`. Collapses the three duplicated
`std::env::var("RTK_TELEMETRY_DISABLED") == "1"` checks (init prompt,
`telemetry status`, `telemetry::maybe_ping`) into one function, so the
accepted values can evolve (e.g. "true"/"y") in a single place without
divergence.

Behavior-preserving: the rtk-ai#1307 regression test (env opt-out
short-circuits the consent prompt) is unchanged and still green; suite
2200/2200.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread src/hooks/init.rs Resolved
ousamabenyounes added a commit to ousamabenyounes/rtk that referenced this pull request Jul 6, 2026
Address KuSh review on rtk-ai#2477: export the `RTK_TELEMETRY_DISABLED`
opt-out check as a public `telemetry_cmd::telemetry_disabled_by_env()`
instead of a private copy in `init.rs`. Collapses the three duplicated
`std::env::var("RTK_TELEMETRY_DISABLED") == "1"` checks (init prompt,
`telemetry status`, `telemetry::maybe_ping`) into one function, so the
accepted values can evolve (e.g. "true"/"y") in a single place without
divergence.

Behavior-preserving: the rtk-ai#1307 regression test (env opt-out
short-circuits the consent prompt) is unchanged and still green; suite
2200/2200.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
ousamabenyounes and others added 3 commits July 9, 2026 12:38
`rtk init -g --hook-only --auto-patch` hangs in non-interactive
environments (devcontainer postCreateCommand, some CI agents) when
`is_terminal()` returns true on a pseudo-TTY that nobody can answer.
Setting `RTK_TELEMETRY_DISABLED=1` used to only gate `telemetry::maybe_ping`,
so the documented workaround still hit the blocking prompt.

Short-circuit `prompt_telemetry_consent` on that env var before the TTY
heuristic so the init flow exits cleanly in any non-interactive context.

Fixes rtk-ai#1307
Address KuSh review on rtk-ai#2477: export the `RTK_TELEMETRY_DISABLED`
opt-out check as a public `telemetry_cmd::telemetry_disabled_by_env()`
instead of a private copy in `init.rs`. Collapses the three duplicated
`std::env::var("RTK_TELEMETRY_DISABLED") == "1"` checks (init prompt,
`telemetry status`, `telemetry::maybe_ping`) into one function, so the
accepted values can evolve (e.g. "true"/"y") in a single place without
divergence.

Behavior-preserving: the rtk-ai#1307 regression test (env opt-out
short-circuits the consent prompt) is unchanged and still green; suite
2200/2200.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@ousamabenyounes

Copy link
Copy Markdown
Contributor Author

Rebased this PR onto current develop and pushed 46ca979.

It is mergeable again with no base lag. Waiting for review when you have a moment, @aeppling.

@KuSh
KuSh merged commit 66e09cb into rtk-ai:develop Jul 20, 2026
9 of 10 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
agogo233 pushed a commit to agogo233/rtk that referenced this pull request Jul 21, 2026
Address KuSh review on rtk-ai#2477: export the `RTK_TELEMETRY_DISABLED`
opt-out check as a public `telemetry_cmd::telemetry_disabled_by_env()`
instead of a private copy in `init.rs`. Collapses the three duplicated
`std::env::var("RTK_TELEMETRY_DISABLED") == "1"` checks (init prompt,
`telemetry status`, `telemetry::maybe_ping`) into one function, so the
accepted values can evolve (e.g. "true"/"y") in a single place without
divergence.

Behavior-preserving: the rtk-ai#1307 regression test (env opt-out
short-circuits the consent prompt) is unchanged and still green; suite
2200/2200.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
gatezh added a commit to gatezh/devcontainers that referenced this pull request Sep 8, 2026
rtk-ai/rtk#1307 is fixed: PR rtk-ai/rtk#2477 (in v0.44.0+, and #121 has now
pinned the images to 0.48.0) makes RTK_TELEMETRY_DISABLED=1 short-circuit the
telemetry consent prompt before the TTY heuristic. The env var is therefore no
longer a workaround but the documented opt-out, so the three "remove when
upstream fixes it" comments were actively misleading.

Upstream deliberately did not add non-TTY auto-detection — the original TTY
check is what failed, because a devcontainer postCreateCommand is handed a
pseudo-TTY and the prompt believes it is interactive. Record that, so nobody
drops the env var on the assumption that rtk now detects CI by itself.

Keep the `timeout` guard as a deliberate backstop rather than deleting it as
redundant: rtk-ai/rtk#3693 (open, priority:high) is a live bug against this same
`rtk init -g` invocation, and the root .devcontainer/Dockerfile resolves rtk from
releases/latest at build time, so a future regression would land unpinned.

Comment-only; no behaviour change.

Refs #117
gatezh added a commit to gatezh/devcontainers that referenced this pull request Sep 9, 2026
…) (#125)

* docs(rtk): record RTK_TELEMETRY_DISABLED as the supported opt-out (#117)

rtk-ai/rtk#1307 is fixed: PR rtk-ai/rtk#2477 (in v0.44.0+, and #121 has now
pinned the images to 0.48.0) makes RTK_TELEMETRY_DISABLED=1 short-circuit the
telemetry consent prompt before the TTY heuristic. The env var is therefore no
longer a workaround but the documented opt-out, so the three "remove when
upstream fixes it" comments were actively misleading.

Upstream deliberately did not add non-TTY auto-detection — the original TTY
check is what failed, because a devcontainer postCreateCommand is handed a
pseudo-TTY and the prompt believes it is interactive. Record that, so nobody
drops the env var on the assumption that rtk now detects CI by itself.

Keep the `timeout` guard as a deliberate backstop rather than deleting it as
redundant: rtk-ai/rtk#3693 (open, priority:high) is a live bug against this same
`rtk init -g` invocation, and the root .devcontainer/Dockerfile resolves rtk from
releases/latest at build time, so a future regression would land unpinned.

Comment-only; no behaviour change.

Refs #117

* fix(rtk): restore exec bits and correct the ralphex-fe scope comment

Review follow-ups on this branch.

The previous commit silently flipped .devcontainer/init-plugins.sh and
ralphex-fe/init-docker.sh from 100755 to 100644. Neither is executed via its
exec bit (the first two are templates invoked as `bash <path>`, the third is
chmod +x'd at ralphex-fe/Dockerfile:154), so nothing broke — but the change was
undeclared, and the "every changed line begins with #" check that vouched for
this branch cannot see mode bits. Restored both.

ralphex-fe/init-docker.sh claimed the rtk init covers "standalone usage (no
host mount)", but the block sits inside `if [ -d /mnt/claude ]` — precisely the
condition that is false without the mount, so rtk is silently inert there. Say
what the code actually does instead. The behavioural gap is left alone: fixing
it needs the mkdir/chown above moved out of the guard too, which is more than a
docs branch should carry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk init hangs in non-interactive environments (v0.36.0 telemetry consent gate)

3 participants