{"record":{"id":"f4309c2ec750b7f9","repo":"pulumi/pulumi","slug":"copy-source-directory-w","errorCode":null,"errorMessage":"copy source directory: %w","messagePattern":"copy source directory: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/pcl/cmd/pulumi-language-pcl/main.go","lineNumber":594,"sourceCode":"\tif err := os.WriteFile(filepath.Join(req.TargetDirectory, \"Pulumi.yaml\"), projectBytes, 0o600); err != nil {\n\t\treturn nil, fmt.Errorf(\"write Pulumi.yaml: %w\", err)\n\t}\n\n\t// If main is set the Main.yaml file should be in a subdirectory\n\tdirectory := req.TargetDirectory\n\tif project.Main != \"\" {\n\t\tdirectory = path.Join(directory, project.Main)\n\t\terr := os.MkdirAll(directory, 0o700)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"create output directory: %w\", err)\n\t\t}\n\t}\n\n\tfilter := func(info os.FileInfo) bool {\n\t\treturn info.Name() != \"Pulumi.yaml\"\n\t}\n\tif err := aferoutil.CopyDir(afero.NewOsFs(), req.SourceDirectory, directory, filter); err != nil {\n\t\treturn nil, fmt.Errorf(\"copy source directory: %w\", err)\n\t}\n\n\t// Only copy local dependencies that the program actually references.\n\treferencedPackages := map[string]bool{}\n\tfor _, ref := range program.PackageReferences() {\n\t\treferencedPackages[ref.Name()] = true\n\t}\n\tfor name, content := range req.LocalDependencies {\n\t\tif !referencedPackages[name] {\n\t\t\tcontinue\n\t\t}\n\t\toutPath := path.Join(directory, name+\".pp\")\n\t\terr := fsutil.CopyFile(outPath, content, nil)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"copy local dependency: %w\", err)\n\t\t}\n\t}\n","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/pcl/cmd/pulumi-language-pcl/main.go#L576-L612","documentation":"GenerateProject copies the PCL source tree (excluding Pulumi.yaml) into the output directory with aferoutil.CopyDir; any copy failure is wrapped as \"copy source directory\". Typical causes are unreadable source files or unwritable destination paths.","triggerScenarios":"aferoutil.CopyDir(afero.NewOsFs(), req.SourceDirectory, directory, filter) returns an error.","commonSituations":"Source directory containing files without read permission; destination on a full or read-only volume; symlinks pointing outside the tree failing to resolve.","solutions":["Verify all files in the source directory are readable by the current user.","Ensure the destination directory exists and is writable.","Check for problematic symlinks or special files in the source tree and exclude/repair them."],"exampleFix":"// before\nchmod 000 secrets.pp && pulumi convert --out ./out\n// after\nchmod 644 secrets.pp && pulumi convert --out ./out","handlingStrategy":"validation","validationCode":"err := filepath.Walk(sourceDir, func(p string, info os.FileInfo, err error) error {\n    if err != nil {\n        return err\n    }\n    if info.Mode()&0o400 == 0 {\n        return fmt.Errorf(\"unreadable file: %s\", p)\n    }\n    return nil\n})","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the PCL source tree free of unreadable or broken symlink files.","Ensure destination volume has space and write access."],"tags":["filesystem","copy","pcl"],"backgroundTag":"copy-dir-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}