Skip to content

fix(create): quiet git-init, silence version-check warning, gate next-steps hint#1263

Draft
DaveHanns wants to merge 1 commit into
apify:masterfrom
DaveHanns:fix/f77-cli-output-noise
Draft

fix(create): quiet git-init, silence version-check warning, gate next-steps hint#1263
DaveHanns wants to merge 1 commit into
apify:masterfrom
DaveHanns:fix/f77-cli-output-noise

Conversation

@DaveHanns

Copy link
Copy Markdown
Contributor

Summary

Three small, closely related cosmetic-but-noisy defects in the CLI's user-facing output. All hit any first-time apify create user and any user running multiple apify commands in a row.

1. apify create emits ~13 lines of Git's "master branch" hint

Because git init runs with default flags, modern Git prints its multi-line advice about the initial branch name every time:

$ apify create my-actor -t ts-crawlee-playwright
...
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>
Initialized empty Git repository in /.../my-actor/.git/

Fix: invoke git -c init.defaultBranch=main init -q. On Git 2.28+ the -c config overrides the default so no hint is printed, and -q silences the "Initialized empty Git repository" line. Older Git versions ignore the unknown config key and still work — the branch just happens to be master there.

2. Version-check warning fires on every invocation when the GitHub API trips

useCLIVersionCheck already debounces the fetch to 24h via ~/.apify/state.json, but on failure it does not update lastChecked. That means whenever the GitHub API returns non-200 (rate limit / captive portal / transient DNS), every subsequent apify invocation retries the fetch and prints:

Warning: Failed to fetch latest version of Apify CLI, using the cached version instead.

I've seen 5+ of these in one script run. The warning also isn't actionable — nothing changes if the user reads it.

Fix:

  • Update lastChecked even on failure, so the 24h debounce covers failed attempts too.
  • Drop the user-facing warning; the failure remains visible via APIFY_CLI_DEBUG.
  • Catch synchronous fetch errors (previously they would bubble up and crash the check silently but noisily).

3. Post-scaffold "Next steps: apify run" can point to a broken next step

For TypeScript templates whose package.json start script is tsx main.ts, the success message unconditionally says:

✅ Actor 'my-actor' created successfully!

Next steps:

cd "my-actor"
apify run

If devDependencies were skipped during install (NODE_ENV=production in CI, npm ci --omit=dev, or a Dockerfile that does npm install --omit=dev before the user runs the Actor), apify run fails immediately with:

sh: tsx: not found

Fix: after a Node install, read the runner named by scripts.start, check whether it resolves in node_modules/.bin/, and if it's declared as a dependency but missing, replace the run hint with:

⚠️  Dev dependencies do not appear to be fully installed (missing 'tsx' in node_modules/.bin).

Next steps:

cd "my-actor"
npm install --include=dev
apify run

The check is scoped to the runner declared in the template's own package.json, so it doesn't false-positive on system-provided commands (node, python, etc.).

Files changed

  • src/commands/create.ts — pass -c init.defaultBranch=main -q to git init; call the new helper before formatting the success message.
  • src/lib/create-utils.ts — add findMissingRunnerBinary; extend formatCreateSuccessMessage with missingRunnerBinary.
  • src/lib/hooks/useCLIVersionCheck.ts — record lastChecked on failure, drop the warning, catch fetch rejections.

Test plan

  • Existing test/local/commands/create.test.ts passes (9/9).
  • tsc --noEmit clean.
  • oxlint --type-aware + oxfmt --check clean on the touched files.
  • Manual: apify create foo -t ts-crawlee-playwright — success message has <3 lines of git output.
  • Manual: run apify create while offline / with Authorization: Bearer bogus proxying api.github.com — no repeated "Failed to fetch latest version" warnings.
  • Manual: NODE_ENV=production apify create bar -t ts-crawlee-playwright — success message points at npm install --include=dev instead of apify run.

Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.

…-steps hint

`apify create` currently emits ~13 lines of git's "using master as the initial
branch" hint plus a bare "Initialized empty Git repository" line, and every
subsequent `apify` invocation can print "Failed to fetch latest version of
Apify CLI" whenever the GitHub API call trips (rate limits, transient DNS,
captive portals). The Success banner also unconditionally suggests
`apify run`, which then fails with `sh: tsx: not found` when devDependencies
were skipped during install (NODE_ENV=production or `--omit=dev`).

- `git -c init.defaultBranch=main init -q` avoids the master-branch hint on
  Git 2.28+ and silences the confirmation line; older Git versions ignore the
  unknown config key.
- `getLatestVersion` now records `lastChecked` even on failure so the 24h
  debounce also covers failed attempts, and no longer surfaces a warning to
  the user — transient network errors here are not actionable.
- After a JS/TS install we check whether the runner named by
  `package.json`'s `scripts.start` (e.g. `tsx`) resolves in
  `node_modules/.bin`. If not, the success message points the user at
  `npm install --include=dev` instead of the misleading `apify run` hint.

Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@DaveHanns DaveHanns requested a review from l2ysho as a code owner July 4, 2026 23:05
@DaveHanns DaveHanns marked this pull request as draft July 5, 2026 11:21
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.

2 participants