{"record":{"id":"f9ae809106e3351f","repo":"wavetermdev/waveterm","slug":"could-not-create-symlink-s-s-w","errorCode":null,"errorMessage":"could not create symlink %s -> %s: %w","messagePattern":"could not create symlink (.+?) -> (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshremote/wshremote.go","lineNumber":124,"sourceCode":"func (impl *ServerImpl) ConnServerInitCommand(ctx context.Context, data wshrpc.CommandConnServerInitData) error {\n\tif data.ClientId == \"\" {\n\t\treturn fmt.Errorf(\"clientid is required\")\n\t}\n\tif impl.SockName == \"\" {\n\t\treturn fmt.Errorf(\"sockname not set in server impl\")\n\t}\n\tsymlinkPath, err := wavebase.ExpandHomeDir(wavebase.GetPersistentRemoteSockName(data.ClientId))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot expand symlink path: %w\", err)\n\t}\n\tsymlinkDir := filepath.Dir(symlinkPath)\n\n\tif err := os.MkdirAll(symlinkDir, 0700); err != nil {\n\t\treturn fmt.Errorf(\"could not create client directory %s: %w\", symlinkDir, err)\n\t}\n\tos.Remove(symlinkPath)\n\tif err := os.Symlink(impl.SockName, symlinkPath); err != nil {\n\t\treturn fmt.Errorf(\"could not create symlink %s -> %s: %w\", symlinkPath, impl.SockName, err)\n\t}\n\timpl.Log(\"created symlink %s -> %s\\n\", symlinkPath, impl.SockName)\n\treturn nil\n}\n\nfunc (impl *ServerImpl) getWshPath() (string, error) {\n\tif impl.IsLocal {\n\t\treturn filepath.Join(wavebase.GetWaveDataDir(), \"bin\", \"wsh\"), nil\n\t}\n\twshPath, err := wavebase.ExpandHomeDir(\"~/.waveterm/bin/wsh\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"cannot expand wsh path: %w\", err)\n\t}\n\treturn wshPath, nil\n}\n\nfunc (impl *ServerImpl) BadgeWatchPidCommand(ctx context.Context, data wshrpc.CommandBadgeWatchPidData) error {\n\tif data.Pid <= 0 {","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshremote/wshremote.go#L106-L142","documentation":"ConnServerInitCommand could not create the wsh socket symlink on the remote (or local) host, so the wsh server endpoint is not reachable at the expected path. os.Symlink failed and the target paths are included in the message.","triggerScenarios":"os.Symlink(impl.SockName, symlinkPath) fails: path already exists as a file/dir, stale dangling symlink the OS still refuses, unsupported filesystem (Windows/FAT), or missing parent dir permissions despite MkdirAll.","commonSituations":"Leftover symlink from a crashed previous session on a filesystem that disallows overwrite (os.Remove raced or failed silently), NFS/SSHFS mounts without symlink support, read-only ~/.waveterm dir.","solutions":["Manually remove the stale symlink: rm ~/.waveterm/.../sockname then restart connection","Check the target filesystem supports symlinks (not FAT/some network mounts)","Verify symlinkDir permissions and that MkdirAll succeeded (0700)","Check the wrapped cause (EEXIST/EPERM/ENOSYS) for the exact OS reason"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if fi, err := os.Lstat(symlinkPath); err == nil {\n    if err := os.Remove(symlinkPath); err != nil {\n        return fmt.Errorf(\"cannot clear stale symlink: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := ConnServerInitCommand(ctx, data); err != nil {\n    if strings.Contains(err.Error(), \"could not create symlink\") {\n        // fall back: log and retry after removing stale link\n        os.Remove(symlinkPath)\n        return ConnServerInitCommand(ctx, data)\n    }\n    return err\n}","preventionTips":["Always remove stale symlinks before creating (already done via os.Remove — check its error too)","Avoid placing sockets/symlinks on non-symlink-capable filesystems","Ensure the remote user owns ~/.waveterm"],"tags":["go","filesystem","symlink","remote"],"backgroundTag":"symlink-creation-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}