Skip to content

info: show if package exists in store - #18

Open
D-Berg wants to merge 1 commit into
stack/wmvkkyxrmpqmfrom
stack/pusonuvuowsw
Open

info: show if package exists in store#18
D-Berg wants to merge 1 commit into
stack/wmvkkyxrmpqmfrom
stack/pusonuvuowsw

Conversation

@D-Berg

@D-Berg D-Berg commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Package information now indicates when a package exists in the local store with a green status message.
  • Performance

    • Reduced redundant path handling while displaying package dependencies.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

printInfo now reports whether a package exists in /opt/packa/store. Dependency printing reuses the path buffer created by printInfo.

Changes

Package store status

Layer / File(s) Summary
Store check and buffer reuse
src/actions/info.zig
printInfo constructs the package store path and prints a green “Exists in store” status when accessible. The dependency printer reuses the existing path buffer.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: showing whether a package exists in the store.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stack/pusonuvuowsw

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/actions/info.zig`:
- Around line 90-101: Update the access handling in the path-checking block of
the info action to print an explicit missing-store status for
error.FileNotFound, while propagating or reporting any other access errors
instead of ignoring them; preserve the existing green “Exists in store” output
for successful access.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f1d9af5f-c28a-4e7b-be79-b27dd1f61f90

📥 Commits

Reviewing files that changed from the base of the PR and between 6fa7c60 and 4f67784.

📒 Files selected for processing (1)
  • src/actions/info.zig

Comment thread src/actions/info.zig
Comment on lines +90 to +101
var path_buf: [Io.Dir.max_path_bytes]u8 = undefined;
const path = try std.fmt.bufPrint(&path_buf, "/opt/packa/store/{s}-{f}-{s}", .{
pkg.name.slice(&state.string_state), pkg.version, pkg_id.slice(&state.string_state)[0..32],
});

// TODO: improve message
if (Io.Dir.cwd().access(io, path, .{})) {
try t.setColor(.green);
try t.writer.print("Exists in store\n", .{});
try t.setColor(.reset);
} else |_| {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 6 'Io\.Dir\.access|\.access\(io|catch \|_\|' --glob '*.zig' .
fd -H -t f -g 'build.zig' -g 'build.zig.zon' -g '.zig-version' -g '.tool-versions' . \
  -x rg -n -C 3 'zig|version|minimum' {}

Repository: D-Berg/packa

Length of output: 11127


🏁 Script executed:

set -euo pipefail

printf '%s\n' '--- manifest and toolchain references ---'
fd -H -t f . | sort | rg '(^|/)(build\.zig(\.zon)?|\.zig-version|\.tool-versions|README.*)$' | while read -r f; do
  printf '\n### %s\n' "$f"
  sed -n '1,80p' "$f"
done

printf '%s\n' '--- relevant source context ---'
sed -n '1,45p' src/util.zig
sed -n '80,170p' src/actions/info.zig

Repository: D-Berg/packa

Length of output: 9350


🌐 Web query:

Zig std.Io.Dir.access error.NotFound API Zig 0.14 0.15

💡 Result:

In Zig versions 0.14 and 0.15, std.fs.Dir.access is the standard function used to check for the existence or accessibility of a file or directory [1][2]. When the specified path does not exist, this function returns error.FileNotFound [3][2]. API Usage and Best Practices The function signature is pub fn access(dir: Dir, io: Io, sub_path: []const u8, options: AccessOptions) AccessError!void (often accessed via std.fs.cwd().access(...)) [3]. When using this function to check if a file exists, it is critical to handle error.FileNotFound explicitly [2]. A common pitfall is the Time-Of-Check-To-Time-Of-Use (TOCTOU) race condition [1][4]. The official Zig documentation and community best practices strongly advise against using access to check if a file exists before opening it [1][4][2]. Instead, you should simply attempt to open the file and handle the error.FileNotFound result from the open operation itself [1][4][2]. This approach is more robust and prevents potential race conditions between the check and the actual file access [4][2]. Context for Zig 0.14/0.15 Zig has been undergoing significant refactoring of its standard library, including moving toward an updated I/O API [5][6][7]. While std.fs.Dir.access remains a standard component for path testing, some older std.fs methods have been deprecated in favor of newer std.Io equivalents [7]. Always ensure you are checking the latest documentation for your specific Zig version, as the standard library continues to evolve [6]. If you encounter unexpected behavior, such as crashes or panics when passing specific paths (e.g., extremely long paths on Windows), be aware that these may be tracked as specific issues in the Zig issue tracker [8], rather than expected API behavior.

Citations:


🌐 Web query:

site:github.com/ziglang/zig 0.16.0 lib/std/Io/Dir.zig access error.FileNotFound

💡 Result:

In Zig 0.16.0, an error.FileNotFound returned by a function in lib/std/fs/Dir.zig (or lib/std/Io/Dir.zig) indicates that the requested file or directory path does not exist [1][2][3]. This error is a standard member of the error sets for various directory and file operations in the Zig standard library, including AccessError, OpenError, MakeError, and DeleteDirError [1][2][4]. If you are encountering this error when you believe the file should exist, consider the following common causes: 1. Incorrect Path: Verify that the sub_path provided to the function is correct relative to the Dir object being used [3]. 2. Race Conditions: If the file was expected to be created or accessed by another process, it may have been deleted or moved, resulting in a race condition [5][4]. 3. Permissions or Mounts: On some systems, especially when using tools like Wine or specific container environments, path resolution or permission settings can cause unexpected FileNotFound errors [6]. 4. Symlinks: If the path involves a symbolic link, ensure the target of the link exists and is accessible [3]. You can debug this by printing the path being accessed just before the call to ensure it matches your expectations, or by using std.fs.cwd.realpathAlloc(allocator, path) to resolve the absolute path for verification. If the error persists unexpectedly, check your operating system's specific behavior regarding the file system operations involved [6].

Citations:


Report the missing-store result explicitly.

When access returns error.FileNotFound, print an explicit missing status. Propagate or report all other errors instead of treating them as absence.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/actions/info.zig` around lines 90 - 101, Update the access handling in
the path-checking block of the info action to print an explicit missing-store
status for error.FileNotFound, while propagating or reporting any other access
errors instead of ignoring them; preserve the existing green “Exists in store”
output for successful access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant