{"record":{"id":"7ca3b6dc28586ebf","repo":"siyuan-note/siyuan","slug":"writing-file-paths-to-clipboard-is-not-supported-o","errorCode":null,"errorMessage":"writing file paths to clipboard is not supported on this platform","messagePattern":"writing file paths to clipboard is not supported on this platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/clipboard.go","lineNumber":25,"sourceCode":"// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n//go:build (!windows && !darwin) || ios\n\npackage util\n\nimport \"errors\"\n\n// 当前仅在 Windows、macOS 上实现，其他平台返回错误\nfunc WriteFilePaths(paths []string) error {\n\treturn errors.New(\"writing file paths to clipboard is not supported on this platform\")\n}\n","sourceCodeStart":7,"sourceCodeEnd":27,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/clipboard.go#L7-L27","documentation":"This is the platform-stub build of util.WriteFilePaths (used on platforms other than Windows and macOS, e.g. Linux builds of the kernel). It always returns this error because writing file paths to the system clipboard is only implemented for Windows and macOS.","triggerScenarios":"Any call to util.WriteFilePaths on a non-Windows/non-macOS build of the kernel — e.g. a Linux desktop or server build invoking the 'copy file to clipboard' feature.","commonSituations":"Using the SiYuan 'copy asset/file' clipboard action on Linux where the kernel stub returns unsupported; embedding the kernel on an unsupported OS.","solutions":["Guard the feature with a platform check and hide the copy-files menu entry on unsupported platforms","Implement a clipboard_linux.go variant (e.g. via xclip/xdg or Freedesktop file-list targets) if support is needed","On Linux, copy paths as text via the existing text-clipboard API instead"],"exampleFix":"// before\nutil.WriteFilePaths(paths) // panics into error on Linux\n// after\nif runtime.GOOS == \"windows\" || runtime.GOOS == \"darwin\" {\n    util.WriteFilePaths(paths)\n} else {\n    util.WriteClipboard(fmt.Sprintf(\"file://%s\", strings.Join(paths, \"\\n\")))\n}","handlingStrategy":"fallback","validationCode":"if runtime.GOOS != \"windows\" && runtime.GOOS != \"darwin\" {\n    // use text-clipboard fallback or hide the feature\n}","typeGuard":"func canWriteFilePaths() bool { return runtime.GOOS == \"windows\" || runtime.GOOS == \"darwin\" }","tryCatchPattern":"if err := util.WriteFilePaths(paths); err != nil {\n    // fall back to copying paths as plain text\n    _ = util.WriteClipboard(strings.Join(paths, \"\\n\"))\n}","preventionTips":["Check runtime.GOOS before offering the copy-files-to-clipboard feature","Hide or disable the menu entry on Linux/other platforms","Provide a text-path fallback UX for unsupported platforms"],"tags":["clipboard","platform","unsupported"],"backgroundTag":"unsupported-platform","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}