{"record":{"id":"96f7ea241ca69029","repo":"sds/overcommit","slug":"unable-to-setup-environment-for-hook-script-name","errorCode":null,"errorMessage":"Unable to setup environment for #{hook_script_name} hook run:\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}","messagePattern":"Unable to setup environment for #(.+?) hook run:\nSTDOUT:#(.+?)\nSTDERR:#(.+?)","errorType":"exception","errorClass":"Overcommit::Exceptions::HookSetupFailed","httpStatus":null,"severity":"error","filePath":"lib/overcommit/hook_context/helpers/stash_unstaged_changes.rb","lineNumber":92,"sourceCode":"      def unstaged_changes?\n        result = Overcommit::Utils.execute(%w[git --no-pager diff --quiet])\n        !result.success?\n      end\n\n      def stash_changes\n        @stash_attempted = true\n\n        stash_message = \"Overcommit: Stash of repo state before hook run at #{Time.now}\"\n        result = Overcommit::Utils.with_environment('GIT_LITERAL_PATHSPECS' => '0') do\n          Overcommit::Utils.execute(\n            %w[git -c commit.gpgsign=false stash save --keep-index --quiet] + [stash_message]\n          )\n        end\n\n        unless result.success?\n          # Failure to stash in this case is likely due to a configuration\n          # issue (e.g. author/email not set or GPG signing key incorrect)\n          raise Overcommit::Exceptions::HookSetupFailed,\n                \"Unable to setup environment for #{hook_script_name} hook run:\" \\\n                \"\\nSTDOUT:#{result.stdout}\\nSTDERR:#{result.stderr}\"\n        end\n\n        @changes_stashed = `git stash list -1`.include?(stash_message)\n      end\n\n      # Restores the file modification times for all modified files to make it\n      # appear like they never changed.\n      def restore_modified_times\n        @modified_times.each do |file, time|\n          next if Overcommit::Utils.broken_symlink?(file)\n          next unless File.exist?(file)\n\n          File.utime(time, time, file)\n        end\n      end\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/sds/overcommit/blob/fee0cd74b26eb81f64b43b7fab17bbb541575cc4/lib/overcommit/hook_context/helpers/stash_unstaged_changes.rb#L74-L110","documentation":"Error \"Unable to setup environment for #{hook_script_name} hook run:\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}\" thrown in sds/overcommit.","triggerScenarios":"Thrown at lib/overcommit/hook_context/helpers/stash_unstaged_changes.rb:92 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the STDOUT/STDERR shown for the failing `git stash save` command; common causes are missing git author/email config or a broken GPG signing setup.","Set user.name and user.email in git config, or disable commit.gpgsign, so git can create the stash commit.","Clean up the working tree (commit, stash, or remove problematic files) and rerun the hook."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fee0cd74b26eb81f64b43b7fab17bbb541575cc4","analyzedAt":"2026-08-23T04:07:28.153Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}