pry/pry · warning · Pry::CommandError
No docs found for: #{obj_name || 'current context'}
Error message
No docs found for: #{obj_name || 'current context'} What it means
Thrown by `show-doc` when the requested code object is found but its documentation string is empty. render_doc_markup_for calls docs_for(code_object); for non-command objects, an empty docs string triggers this error — i.e. the method/class simply has no comment above it (or no YARD docs where relevant).
Source
Thrown at lib/pry/commands/show_doc.rb:42
# The docs for code_object prepared for display.
def content_for(code_object)
Code.new(
render_doc_markup_for(code_object),
start_line_for(code_object),
:text
).with_line_numbers(use_line_numbers?).to_s
end
# process the markup (if necessary) and apply colors
def render_doc_markup_for(code_object)
docs = docs_for(code_object)
if code_object.command?
# command '--help' shouldn't use markup highlighting
docs
else
if docs.empty?
raise CommandError, "No docs found for: #{obj_name || 'current context'}"
end
process_comment_markup(docs)
end
end
# Return docs for the code_object, adjusting for whether the code_object
# has yard docs available, in which case it returns those.
# (note we only have to check yard docs for modules since they can
# have multiple docs, but methods can only be doc'd once so we
# dont need to check them)
def docs_for(code_object)
if code_object.module_with_yard_docs?
# yard docs
code_object.yard_doc
else
# normal docs (i.e comments above method/module/command)
code_object.docView on GitHub (pinned to 1356402628)
Solutions
- Install pry-doc to get docs for C-defined core/stdlib methods: `gem install pry-doc`
- For your own code, add a comment above the method/class and retry
- Use `show-source <name>` instead when you want the implementation rather than the docs
Example fix
# before show-doc Array#map # No docs found for: Array#map # after (shell) gem install pry-doc # in a new pry session show-doc Array#map
Defensive patterns
Strategy: validation
Validate before calling
# confirm non-empty docs before show-doc
obj = Pry::CodeObject.lookup('Array#map', _pry_)
obj && !obj.doc.to_s.strip.empty? Type guard
def documented?(name, pry) obj = Pry::CodeObject.lookup(name, pry) !obj.nil? && !obj.doc.to_s.strip.empty? end
Try / catch
begin
pry_instance.run 'show-doc', name
rescue Pry::CommandError => e
raise unless e.message.include?('No docs found')
pry_instance.run 'show-source', name # fall back to the implementation
end Prevention
- Install pry-doc alongside pry in dev environments
- Comment your methods if you expect to browse docs for them
- Use show-source when docs are absent — the code is the truth
When it happens
Trigger: Running `show-doc Array#map`, `show-doc String#gsub` or other core methods without the pry-doc gem installed (no C-source comments available); calling show-doc on your own undocumented methods or classes.
Common situations: Fresh Pry installs without pry-doc; inspecting C-defined core/stdlib methods; codebases that don't comment methods.
Related errors
- Cannot locate this method: #{name}.
- Exception has no associated file.
- Cannot edit exceptions raised in REPL.
- No help found for '#{args.first}'
- Must provide a file name.
AI-assisted analysis of pry/pry@1356402628 (2026-08-21).
Data as JSON: /api/errors/59755534b0153f43.
Report an issue: GitHub.