{"record":{"id":"5b0bfd03741903e3","repo":"hasura/graphql-engine","slug":"could-not-create-staging-dir-q-w","errorCode":null,"errorMessage":"could not create staging dir %q: %w","messagePattern":"could not create staging dir %q: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/plugins/plugins.go","lineNumber":292,"sourceCode":"\treturn nil\n}\n\nfunc (c *Config) installPlugin(plugin Plugin, platform Platform) error {\n\tvar op errors.Op = \"plugins.Config.installPlugin\"\n\n\tdownloadStagingDir := filepath.Join(c.Paths.DownloadPath(), plugin.Name)\n\tinstallDir := c.Paths.PluginVersionInstallPath(plugin.Name, plugin.Version)\n\tbinDir := c.Paths.BinPath()\n\n\t// check if install dir already exists\n\t_, err := os.Stat(installDir)\n\tif err != nil {\n\t\t// Download and extract\n\t\terr := os.MkdirAll(downloadStagingDir, 0o755)\n\t\tif err != nil {\n\t\t\treturn errors.E(\n\t\t\t\top,\n\t\t\t\tfmt.Errorf(\"could not create staging dir %q: %w\", downloadStagingDir, err),\n\t\t\t)\n\t\t}\n\t\tdefer func() {\n\t\t\tc.Logger.Debugf(\"Deleting the download staging directory %s\", downloadStagingDir)\n\n\t\t\terr := os.RemoveAll(downloadStagingDir)\n\t\t\tif err != nil {\n\t\t\t\tc.Logger.Debugf(\"failed to clean up download staging directory: %s\", err)\n\t\t\t}\n\t\t}()\n\n\t\terr = downloadAndExtract(downloadStagingDir, platform.URI, platform.Sha256)\n\t\tif err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"failed to unpack into staging dir: %w\", err))\n\t\t}\n\n\t\terr = moveToInstallDir(downloadStagingDir, installDir, platform.Files)\n\t\tif err != nil {","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/plugins/plugins.go#L274-L310","documentation":"installPlugin() downloads the plugin into a staging directory under the CLI's download path; before downloading it creates that directory with os.MkdirAll. Any error creating the staging dir aborts the install immediately with this message naming the offending path.","triggerScenarios":"MkdirAll(DownloadPath()/plugin.Name) failing: the download path exists as a regular file, a parent directory lacks write permission, disk quota exceeded, or a read-only filesystem.","commonSituations":"Plugins download cache dir owned by root from earlier sudo use; home directory over quota; the download path was accidentally created as a file; container/CI environments with read-only volumes for the config dir.","solutions":["Check the exact path named in the error message with ls -la; if a file exists where a directory is expected, remove it","Fix ownership/permissions of the download path and its parents so the current user can create directories","Free disk space / raise quota if the mkdir fails with ENOSPC","Ensure the plugins data/download directory is on a writable filesystem (relevant in containers and CI)"],"exampleFix":"# before: download path is a regular file\n$ ls -la ~/.cli/downloads\n-rw-r--r-- 1 user user 0 downloads\n$ rm ~/.cli/downloads\n# after: install recreates it as a directory and succeeds","handlingStrategy":"validation","validationCode":"staging := filepath.Join(cfg.Paths.DownloadPath(), plugin.Name)\nif fi, err := os.Stat(staging); err == nil && !fi.IsDir() {\n\t_ = os.Remove(staging) // clear a stray file blocking MkdirAll\n}\nif err := os.MkdirAll(filepath.Dir(staging), 0o755); err != nil {\n\t// repair permissions before calling Install\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.Install(plugin); err != nil && strings.Contains(err.Error(), \"could not create staging dir\") {\n\t// fix ownership/permissions on the named path, remove conflicting file, retry\n}","preventionTips":["Ensure the CLI's download cache directory is writable and is a directory, not a file","Check disk space/quota before installs","Never manually create files where the tool expects cache directories"],"tags":["plugins","install","filesystem","permissions"],"backgroundTag":"staging-directory-create-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}