Skip to content

Comments

Fix: Remove directory creation before pkgutil --expand#1

Open
serahug wants to merge 2 commits intomise-plugins:mainfrom
serahug:main
Open

Fix: Remove directory creation before pkgutil --expand#1
serahug wants to merge 2 commits intomise-plugins:mainfrom
serahug:main

Conversation

@serahug
Copy link

@serahug serahug commented Feb 1, 2026

pkgutil --expand creates the target directory itself and fails with "Error 17: File exists" if it already exists.

Reproduction:

mise install carthage --verbose
# Shows: Error encountered while creating .../expanded. Error 17: File exists
# But reports: "Carthage installed successfully!"
carthage version
# zsh: command not found: carthage

@gemini-code-assist
Copy link

Summary of Changes

Hello @serahug, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the carthage installation process by correcting how the target directory for pkgutil --expand is handled. Previously, the installation would fail because the directory was pre-created, causing a conflict with pkgutil's own directory creation logic. The change ensures a successful and reliable installation by clearing the directory beforehand.

Highlights

  • Installation Fix: Resolved an issue where pkgutil --expand would fail during installation if the target directory already existed, leading to an "Error 17: File exists" message.
  • Directory Management: Modified the post_install hook to explicitly remove (clean) the target expansion directory using rm -rf before pkgutil --expand is executed, ensuring a clean state for the package expansion.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug where the Carthage installation fails because pkgutil --expand cannot handle a pre-existing destination directory. The fix, which involves removing the directory before expansion, is correct. I've included one suggestion to enhance error handling by checking the outcome of the directory removal command. This will help in providing more precise error messages if that step fails, improving the script's robustness.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an issue where pkgutil --expand would fail if the target directory already exists. The change replaces mkdir -p with rm -rf to ensure the directory is removed before expansion. While this fix is appropriate, I've added a suggestion to improve the robustness of the script by adding error handling for the new rm -rf command, as it is a destructive operation and any failures should be caught early with a clear message.

@serahug
Copy link
Author

serahug commented Feb 1, 2026

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes a bug where the Carthage installation would fail because pkgutil --expand cannot expand into a pre-existing directory. The change correctly replaces the directory creation (mkdir -p) with directory removal (rm -rf) before the expansion, ensuring the target directory does not exist. This is a good fix. I've added one suggestion to improve the robustness of the shell command by properly escaping the path, which would prevent potential issues if the installation path contains special characters.

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