Skip to content

fix rootdir #6995#6999

Merged
waruqi merged 1 commit intodevfrom
rootdir
Nov 6, 2025
Merged

fix rootdir #6995#6999
waruqi merged 1 commit intodevfrom
rootdir

Conversation

@waruqi
Copy link
Member

@waruqi waruqi commented Nov 6, 2025

@waruqi waruqi added this to the v3.0.5 milestone Nov 6, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @waruqi, 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 focuses on enhancing the robustness and consistency of path handling within the xmake interpreter. It specifically targets an issue where the rootdir might not be correctly interpreted due to unnormalized paths, ensuring that all file paths are canonicalized. Additionally, it refines the internal mechanism for managing the current working directory during script execution, leading to cleaner and potentially more reliable code.

Highlights

  • Rootdir Path Normalization: Implemented path normalization for the rootdir variable when loading files in the interpreter, directly addressing and resolving issue --project does not properly handle absolute paths with . or .. components #6995 related to inconsistent path handling.
  • Directory Change Refactoring: Refactored the logic for changing directories within the interpreter, streamlining the process of saving the current directory and moving to a new script directory into a single, more concise operation.
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
Contributor

@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 aims to fix an issue with rootdir by normalizing the script path. The main change in interpreter:load correctly uses path.normalize to ensure path consistency. However, this introduces a potential issue when handling nil paths, which I've commented on with a suggestion for a fix. The pull request also includes a nice refactoring in interpreter:api_builtin_includes to make the code more concise by utilizing the return value of os.cd. Overall, the change is in the right direction, but the edge case with nil paths needs to be addressed.

-- translate to absolute file path for scriptdir/rootdir
file = path.absolute(file)
-- we need to normalize path for rootdir, @see https://github.com/xmake-io/xmake/issues/6995
file = path.normalize(path.absolute(file))
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This change introduces a potential issue. If path.absolute(file) returns nil (for example, with an empty input file), path.normalize(nil) will be called. Inside path.normalize, tostring(nil) evaluates to the string "nil", causing the function to operate on a file named "nil" instead of propagating the nil value. This alters the behavior for invalid paths and could lead to unexpected errors later.

To fix this, you should check if the result of path.absolute(file) is not nil before calling path.normalize.

    local abspath = path.absolute(file)
    file = abspath and path.normalize(abspath)

@waruqi waruqi merged commit 842f360 into dev Nov 6, 2025
44 checks passed
@waruqi waruqi deleted the rootdir branch November 6, 2025 23:19
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