{"record":{"id":"55cba60817a1a870","repo":"apache/beam","slug":"error-in-creating-relative-path-w","errorCode":null,"errorMessage":"error in creating relative path: %w","messagePattern":"error in creating relative path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go","lineNumber":277,"sourceCode":"\n\t// fetch jars required in classpath\n\tclasspaths := strings.Split(classpath, \" \")\n\tclasspathJars := []string{}\n\tfor _, jar := range classpaths {\n\t\tpath := expandJar(jar)\n\t\tif j, err := getLocalJar(path); err == nil {\n\t\t\tclasspathJars = append(classpathJars, j)\n\t\t} else {\n\t\t\treturn \"\", fmt.Errorf(\"error in getLocal(): %w\", err)\n\t\t}\n\t}\n\n\t// classpath jars should have relative path\n\trelClasspath := []string{}\n\tfor _, path := range classpathJars {\n\t\trelPath, err := filepath.Rel(cacheDir, path)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"error in creating relative path: %w\", err)\n\t\t}\n\t\trelClasspath = append(relClasspath, relPath)\n\t}\n\n\ttmpDir := filepath.Join(cacheDir, \"tmpDir\")\n\n\tif err := extractJar(mainJar, tmpDir); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error in extractJar(): %w\", err)\n\t}\n\n\tmanifest, err := os.ReadFile(tmpDir + \"/META-INF/MANIFEST.MF\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error readingf: %w\", err)\n\t}\n\n\t// trim the empty lines present at the end of MANIFEST.MF file.\n\tmanifestLines := strings.Split(string(manifest), \"\\n\")\n\tmanifestLines = manifestLines[:len(manifestLines)-2]","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go#L259-L295","documentation":"After collecting cached classpath JARs, MakeJar computes each jar's path relative to the jar cache directory via filepath.Rel(cacheDir, path); this fails only when the two paths cannot be made relative (e.g. different roots, or the jar sits outside the cacheDir). The wrapped error aborts JAR repackaging because the Class-Path manifest entries must be relative.","triggerScenarios":"filepath.Rel(cacheDir, path) returns an error, classically 'Rel: can't make X relative to Y' when a getLocalJar result lives on a different mount/root than cacheDir ($HOME/.beam661bea09-...), or cacheDir couldn't be derived correctly from user.HomeDir (empty HOME).","commonSituations":"HOME unset or overridden so cacheDir is computed differently from where jars were actually cached; jars placed on a different drive/root than the cache dir; cross-volume symlinks resolving outside the cache.","solutions":["Ensure $HOME is set and consistent for the process so cacheDir matches where getLocalJar caches jars.","Keep the jar cache and all classpath jars on the same filesystem root/drive.","Check for symlinks resolving classpath jars outside the cache dir; resolve or relocate them.","If HOME cannot be fixed, pre-cache jars under the exact cacheDir MakeJar will compute."],"exampleFix":"// before: HOME unset in service environment\nExecStart=/opt/worker/worker\n// after: pin HOME so cacheDir is deterministic\nEnvironment=HOME=/home/beam\nExecStart=/opt/worker/worker","handlingStrategy":"validation","validationCode":"cacheDir := filepath.Join(usr.HomeDir, jarCache[2:])\nif usr.HomeDir == \"\" { return errors.New(\"HOME is unset; cannot compute jar cache dir\") }\nfor _, p := range classpathJars {\n    if _, err := filepath.Rel(cacheDir, p); err != nil {\n        return fmt.Errorf(\"jar %s outside cache dir %s\", p, cacheDir)\n    }\n}","typeGuard":null,"tryCatchPattern":"relPath, err := filepath.Rel(cacheDir, path)\nif err != nil {\n    return \"\", fmt.Errorf(\"error in creating relative path: %w\", err)\n}","preventionTips":["Always set HOME (or USERPROFILE) for the worker process.","Keep the jar cache and all classpath jars on the same filesystem root.","Avoid symlinks that resolve jars outside the cache directory.","Compute cacheDir once and reuse it for both caching and Rel computations."],"tags":["go","filesystem","path","jar"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}