{"record":{"id":"db2ce44a69001f40","repo":"can1357/oh-my-pi","slug":"no-artifacts-directory-found-artifacts-dir-db2ce4","errorCode":null,"errorMessage":"No artifacts directory found: #{artifacts_dir}","messagePattern":"No artifacts directory found: #(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/eval/rb/prelude.rb","lineNumber":180,"sourceCode":"        current = current[value]\n      end\n    end\n    current\n  end\n\n  def output(*ids, format: \"raw\", query: nil, offset: nil, limit: nil)\n    artifacts_dir = ENV[\"PI_ARTIFACTS_DIR\"]\n    if artifacts_dir.nil? || artifacts_dir.empty?\n      session_file = ENV[\"PI_SESSION_FILE\"]\n      if session_file.nil? || session_file.empty?\n        __omp_emit_status(\"output\", \"error\" => \"No session file available\")\n        raise \"No session - output artifacts unavailable\"\n      end\n      artifacts_dir = session_file.sub(/\\.[^.]*\\z/, \"\")\n    end\n    unless File.directory?(artifacts_dir)\n      __omp_emit_status(\"output\", \"error\" => \"Artifacts directory not found\", \"path\" => artifacts_dir)\n      raise \"No artifacts directory found: #{artifacts_dir}\"\n    end\n    raise ArgumentError, \"At least one output ID is required\" if ids.empty?\n    if query && (!offset.nil? || !limit.nil?)\n      __omp_emit_status(\"output\", \"error\" => \"query cannot be combined with offset/limit\")\n      raise ArgumentError, \"query cannot be combined with offset/limit\"\n    end\n\n    results = []\n    not_found = []\n    ids.each do |output_id|\n      path = File.join(artifacts_dir, \"#{output_id}.md\")\n      unless File.exist?(path)\n        not_found << output_id\n        next\n      end\n      raw = File.read(path, encoding: Encoding::UTF_8)\n      raw_lines = raw.split(\"\\n\", -1)\n      total_lines = raw_lines.length","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/eval/rb/prelude.rb#L162-L198","documentation":"`output(*ids)` locates the artifacts directory from PI_ARTIFACTS_DIR or by stripping the extension off PI_SESSION_FILE. When that directory does not exist on disk (`File.directory?` fails), it emits an error status naming the path and raises this error — artifacts were expected there but nothing was created or the path points elsewhere.","triggerScenarios":"Calling `output(\"some-id\")` when PI_ARTIFACTS_DIR points to a nonexistent/removed directory, or PI_SESSION_FILE is set but the sibling directory (session path minus extension) was never created — e.g. artifacts from a completed/deleted session, or a session file path passed manually that does not match the real layout.","commonSituations":"Re-running an eval against an old session file whose artifacts dir was cleaned up; setting PI_ARTIFACTS_DIR to a typo'd or relative path from a different working directory; artifacts not yet written because the sub-agent/task producing them has not finished (or failed).","solutions":["Print/inspect the path in the message and create or correct PI_ARTIFACTS_DIR to point at the real artifacts directory before calling `output`","Confirm the session actually produced artifacts (list the derived directory from PI_SESSION_FILE minus extension); if the producing task hasn't run or failed, rerun it first","Set PI_ARTIFACTS_DIR explicitly to the correct absolute directory instead of relying on the session-file derivation"],"exampleFix":"// before\nENV[\"PI_ARTIFACTS_DIR\"] = \"artifacts\"\noutput(\"step1\")\n// after\nENV[\"PI_ARTIFACTS_DIR\"] = File.expand_path(\"~/.omp/sessions/abc123\")\noutput(\"step1\")","handlingStrategy":"validation","validationCode":"dir = ENV[\"PI_ARTIFACTS_DIR\"]\ndir ||= ENV[\"PI_SESSION_FILE\"].to_s.sub(/\\.[^.]*\\z/, \"\")\nraise \"artifacts dir missing: #{dir}\" unless dir.to_s.nonempty? && File.directory?(dir)\nresults = output(\"step1\")","typeGuard":null,"tryCatchPattern":"begin\n  artifacts = output(\"step1\")\nrescue RuntimeError => e\n  raise unless e.message.start_with?(\"No artifacts directory found: \")\n  artifacts = nil\nend","preventionTips":["Use absolute paths for PI_ARTIFACTS_DIR; relative paths break if cwd differs","Confirm the producing task completed before reading its outputs","Check the directory exists (File.directory?) before relying on session-file derivation"],"tags":["ruby","env","artifacts","filesystem"],"backgroundTag":"artifacts-directory-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}