Skip to content

Snippet isn't consistently being recognized #1280

@heckj

Description

@heckj

Description

I've been working to add the use of snippets to several projects, and one of them - swift-metrics - has the snippets, they're compiling, symbol graphs exist, but the @snippet directive is reporting an error attempting to read it.

The issue appears to be a regression specifically in release/6.2 - and works with both earlier versions (release/6.1, and the current main branch).

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue.

Expected Behavior

The command I'm using:

swift package --disable-sandbox plugin --allow-writing-to-package-directory preview-documentation --target CoreMetrics --verbose:

output:

Building for debugging...
[1/1] Write swift-version-53407C18AB967AC9.txt
Build of product 'snippet-extract' complete! (0.10s)
symbol graph options: 'SymbolGraphOptions(minimumAccessLevel: PackagePlugin.PackageManager.SymbolGraphOptions.AccessLevel.public, includeSynthesized: true, includeSPI: false, emitExtensionBlocks: true)'
Building for debugging...
[1/1] Write swift-version-53407C18AB967AC9.txt
Build of target: 'CoreMetrics' complete! (0.10s)
target symbol graph directory path: '/Users/joeheck/src/swift-metrics/.build/arm64-apple-macosx/extracted-symbols/swift-metrics/CoreMetrics'
snippet extractor provided, attempting to generate snippet symbol graph
snippet symbol graph file: '/Users/joeheck/src/swift-metrics/.build/plugins/Swift-DocC Preview/outputs/.build/symbol-graphs/snippet-symbol-graphs/swift-metrics-swift-metrics/swift-metrics-snippets.symbols.json'
unified symbol graphs directory path: '/Users/joeheck/src/swift-metrics/.build/plugins/Swift-DocC Preview/outputs/.build/symbol-graphs/unified-symbol-graphs/CoreMetrics-3'
docc invocation: '/Applications/Xcode-26beta6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/docc preview /Users/joeheck/src/swift-metrics/Sources/CoreMetrics/Docs.docc --emit-lmdb-index --fallback-display-name CoreMetrics --fallback-bundle-identifier CoreMetrics --additional-symbol-graph-dir /Users/joeheck/src/swift-metrics/.build/plugins/Swift-DocC Preview/outputs/.build/symbol-graphs/unified-symbol-graphs/CoreMetrics-3 --output-path /Users/joeheck/src/swift-metrics/.build/plugins/Swift-DocC Preview/outputs/CoreMetrics.doccarchive'
Input: /Users/joeheck/src/swift-metrics/Sources/CoreMetrics/Docs.docc
Template: /Applications/Xcode-26beta6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/docc/render
warning: 'swift-metrics' doesn't exist at '/CoreMetrics'
  --> index.md:42:3-42:16
40 |
41 | something here \\/
42 + @Snippet(path: "swift-metrics/Snippets/basics")
   |   ╰─suggestion: Replace 'swift-metrics' with 'Swift-Metrics-Extras'
43 | something there /\
44 |

========================================
Starting Local Preview Server
	 Address: http://localhost:8080/documentation/coremetrics
========================================
Monitoring /Users/joeheck/src/swift-metrics/Sources/CoreMetrics/Docs.docc for changes...

Actual behavior

The snippet isn't showing

Steps To Reproduce

git clone -b snippets https://github.com/heckj/swift-metrics
cd swift-metrics
swift package --disable-sandbox plugin --allow-writing-to-package-directory preview-documentation --target CoreMetrics --verbose

Swift-DocC Version Information

Swift 6.2

Swift Compiler Version Information

swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
Target: arm64-apple-macosx26.0

Metadata

Metadata

Labels

bugSomething isn't workingregressionThis used to work in earlier versions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions