Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`cf complete zsh >> .zshrc` fails on vanilla zsh

Open Beginner friendly
#340 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #341 by @couetilc — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
zsh
Domain
cli

Research direction

Start with the cf complete zsh command, which prints the completion script, and find where that script is generated. Reproduce with zsh -f -c "$(cf complete zsh)", which should fail with command not found: compdef. Done when the generated script loads in a bare zsh with no .zshrc, for example by initializing the completion system itself before calling compdef, and the reporter's workaround is no longer needed.

Written by the indexing model from the issue text.

Description

Summary of the issue

I use vanilla zsh on my macbook. Nothing in the .zshrc. When I try to install the cf completion script for zsh, I get the following error.

% zsh -f -c "$(cf complete zsh)"
zsh:2: command not found: compdef
%

Current workaround: initialize completions only if compdef is unavailable.

if (( ! $+functions[compdef] )); then
  autoload -Uz compinit
  compinit
fi

eval "$(cf complete zsh)"
Expected behaviour

I expect the generated completion script to work when sourced in an unconfigured Zsh shell.

Version of cf used

1.0.0-beta.18

System information and package versions
  System:
    OS: macOS 26.6.2
    CPU: (14) arm64 Apple M4 Pro
    Memory: 5.64 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 26.12.0 - /opt/homebrew/bin/node
    npm: 11.20.0 - /opt/homebrew/bin/npm
$ zsh --version
zsh 5.9 (arm64-apple-darwin25.0)
Reproduction (optional)
% cf complete zsh >> .vanilla.zshrc
% RCS=.vanilla.zshrc  zsh 
Possible Fix
if (( ! $+functions[compdef] )); then
  autoload -Uz compinit
  compinit
fi
Dominant language
TypeScript
Stars
853
Forks
42
Avg merge
17h 59m
Merged PRs (30d)
145

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudflare/cf

All issues in cloudflare/cf

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.