{"record":{"id":"ea9d09952c96e37b","repo":"asdf-vm/asdf","slug":"failed-to-run-pre-install-hook-w","errorCode":null,"errorMessage":"failed to run pre-install hook: %w","messagePattern":"failed to run pre-install hook: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/versions/versions.go","lineNumber":189,"sourceCode":"\n\terr = os.MkdirAll(downloadDir, 0o777)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to create download dir: %w\", err)\n\t}\n\n\terr = hook.RunWithOutput(conf, fmt.Sprintf(\"pre_asdf_download_%s\", plugin.Name), []string{version.Value}, stdOut, stdErr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to run pre-download hook: %w\", err)\n\t}\n\n\terr = plugin.RunCallback(\"download\", []string{}, env, stdOut, stdErr)\n\tif _, ok := err.(plugins.NoCallbackError); err != nil && !ok {\n\t\treturn fmt.Errorf(\"failed to run download callback: %w\", err)\n\t}\n\n\terr = hook.RunWithOutput(conf, fmt.Sprintf(\"pre_asdf_install_%s\", plugin.Name), []string{version.Value}, stdOut, stdErr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to run pre-install hook: %w\", err)\n\t}\n\n\terr = os.MkdirAll(installDir, 0o777)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to create install dir: %w\", err)\n\t}\n\n\terr = plugin.RunCallback(\"install\", []string{}, env, stdOut, stdErr)\n\tif err != nil {\n\t\tif rmErr := os.RemoveAll(installDir); rmErr != nil {\n\t\t\tfmt.Fprintf(stdErr, \"failed to clean up '%s' due to %s\\n\", installDir, rmErr)\n\t\t}\n\t\treturn fmt.Errorf(\"failed to run install callback: %w\", err)\n\t}\n\n\t// Reshim\n\terr = shims.GenerateAll(conf, stdOut, stdErr)\n\tif err != nil {","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/asdf-vm/asdf/blob/074a1722ca88d6677f228541ce06efaf4f9924d4/internal/versions/versions.go#L171-L207","documentation":"After download, InstallOneVersion runs the pre_asdf_install hook via hook.RunWithOutput; failure of this user-configured hook aborts the install with this wrapped error, before the install directory is created and the plugin's install callback runs. Like error 47 but at the install stage rather than the download stage.","triggerScenarios":"hook.RunWithOutput(conf, \"pre_asdf_install_<plugin>\", [version], ...) returns an error — a configured pre_asdf_install or pre_asdf_install_<plugin> hook exits non-zero or fails to execute.","commonSituations":"Pre-install hooks enforcing policies (approved versions, disk checks) that reject the version, hook scripts broken or missing, environment differences for the user running the install.","solutions":["Read the hook's output on stdOut/stdErr to see the real reason","Fix or remove the pre_asdf_install hook in asdf config","Ensure the hook command is present and executable in PATH","Choose a version that satisfies the hook's policy if it is intentionally blocking"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if err := hook.RunWithOutput(conf, \"pre_asdf_install_\"+plugin, []string{ver}, buf, buf); err != nil {\n    return fmt.Errorf(\"pre-install hook will fail: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to run pre-install hook\") {\n    // inspect hook output, fix hook or pick another version\n}","preventionTips":["Keep pre_asdf_install hooks simple and tested","Log hook output during installs","Align installed versions with hook policy allowlists"],"tags":["hooks","install","asdf"],"backgroundTag":"hook-execution-failed","analyzedSha":"074a1722ca88d6677f228541ce06efaf4f9924d4","analyzedAt":"2026-08-30T19:56:42.972Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}