google/python-fire · error · ValueError
Cannot make completion script without command name
Error message
Cannot make completion script without command name
What it means
Requesting a completion script (-- --completion [shell]) requires knowing the installed command name so the generated script can hook into it. If fire.Fire() is called without the `name` parameter while completion is requested, this ValueError is raised.
Source
Thrown at fire/core.py:599
elif component is not last_component:
remaining_args = [separator] + saved_args
else:
# It was an unnecessary separator.
remaining_args = saved_args
if component is last_component and remaining_args == initial_args:
# We're making no progress.
break
if remaining_args:
component_trace.AddError(
FireError('Could not consume arguments:', remaining_args),
initial_args)
return component_trace
if show_completion is not None:
if name is None:
raise ValueError('Cannot make completion script without command name')
script = CompletionScript(name, initial_component, shell=show_completion)
component_trace.AddCompletionScript(script)
if interactive:
variables = context.copy()
if name is not None:
variables[name] = initial_component
variables['component'] = initial_component
variables['result'] = component
variables['trace'] = component_trace
if instance is not None:
variables['self'] = instance
interact.Embed(variables, verbose)
component_trace.AddInteractiveMode()View on GitHub (pinned to 716bbc23d7)
Solutions
- Pass the command name: fire.Fire(component, name='mytool')
- Use fire.Fire(component=component, name=str(sys.argv[0])) or the module name in the entry point
- Avoid -- --completion when no name is provided
Example fix
// before fire.Fire(component) # user runs: mytool -- --completion bash // after fire.Fire(component, name='mytool')
Defensive patterns
Strategy: validation
Validate before calling
if show_completion and name is None:
raise ValueError('pass name= to fire.Fire to enable --completion') Try / catch
try:
fire.Fire(component, name=name)
except ValueError as e:
if 'completion script' in str(e):
sys.exit('completion requires name=')
raise Prevention
- Always pass name='yourcmd' in console_script entry points
- Smoke-test `yourcmd -- --completion bash` in CI
- Derive name from sys.argv[0] if hardcoded names are undesirable
When it happens
Trigger: Running `mytool -- --completion bash` when the entry was fire.Fire(component) with no name= argument; calling fire.Fire(component, show_completion='bash') programmatically with name=None.
Common situations: Tools installed via console_scripts that forgot to pass name=__file__ or the command name; tests invoking Fire without a name but exercising completion.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- Given file path does not exist.
- Unable to load module from specified path.
- Fire can only be called on .py files.
- Fire was passed a filename which could not be found.
- The command argument must be a string or a sequence of argum
AI-assisted analysis of google/python-fire@716bbc23d7 (2026-08-28).
Data as JSON: /api/errors/a5a36f83facdcfef.
Report an issue: GitHub.