Skip to content

fix package local dir#7445

Merged
waruqi merged 3 commits into
devfrom
package
Apr 4, 2026
Merged

fix package local dir#7445
waruqi merged 3 commits into
devfrom
package

Conversation

@waruqi

@waruqi waruqi commented Apr 1, 2026

Copy link
Copy Markdown
Member
  • Before adding new features and new modules, please go to issues to submit the relevant feature description first.
  • Write good commit messages and use the same coding conventions as the rest of the project.
  • Please commit code to dev branch and we will merge into master branch in feature
  • Ensure your edited codes with four spaces instead of TAB.

  • 增加新特性和新模块之前,请先到issues提交相关特性说明,经过讨论评估确认后,再进行相应的代码提交,避免做无用工作。
  • 编写友好可读的提交信息,并使用与工程代码相同的代码规范,代码请用4个空格字符代替tab缩进。
  • 请提交代码到dev分支,如果通过,我们会在特定时间合并到master分支上。
  • 为了规范化提交日志的格式,commit消息,不要用中文,请用英文描述。

@waruqi waruqi added this to the v3.0.9 milestone Apr 1, 2026

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

Copy link
Copy Markdown
Contributor

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 refactors the package installation logic to support local project package directories more consistently. It updates package.installdir to handle a localdir option and ensures that local packages pass their installation path to child processes via the XMAKE_PKG_INSTALLDIR environment variable. Review feedback highlighted a critical shadowing issue in xmake/modules/package/tools/xmake.lua where the imported package module conflicts with a function parameter, potentially causing runtime failures. Additionally, a placeholder issue reference in the comments needs to be corrected.

Comment thread xmake/modules/package/tools/xmake.lua Outdated
import("core.base.global")
import("core.tool.toolchain")
import("core.project.project")
import("core.package.package")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The module name package is shadowed by the package parameter in the install function (and other functions in this file). To avoid conflicts and ensure the module functions can be called correctly, please use an alias for this import.

import("core.package.package", {alias = "core_package"})

Comment thread xmake/modules/package/tools/xmake.lua Outdated
-- @see https://github.com/xmake-io/xmake/discussions/7441
if package:is_local() then
envs = table.clone(envs)
envs.XMAKE_PKG_INSTALLDIR = package.installdir({localdir = true})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Because the package parameter shadows the package module, this line is currently calling the installdir method on the package instance instead of the module function. Furthermore, it uses . instead of :, which would cause a crash as self would be the options table. Use the aliased module name to call the correct function.

        envs.XMAKE_PKG_INSTALLDIR = core_package.installdir({localdir = true})

-- if the package is installed locally, pass the local packages directory
-- to the child xmake process so it can find already-installed deps
-- without re-installing them to the global directory
-- @see https://github.com/xmake-io/xmake/discussions/7441

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The issue reference contains a placeholder xxx. Please update it with the correct issue number.

@waruqi waruqi merged commit 4633e0c into dev Apr 4, 2026
79 of 80 checks passed
@waruqi waruqi deleted the package branch April 4, 2026 10:15
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