xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.1k stars 784 forks source link

[BUG] xmake运行结果不一致 #5144

Closed KarryCharon closed 5 months ago

KarryCharon commented 5 months ago

Xmake Version

2.8.9

Operating System Version and Architecture

macOS 14.3.1 (23D60)

Describe Bug

当使用 vscode的xmake插件提供的build 按钮构建项目时, xmake内置工具 os.iorunv 运行结果与外部终端运行结果有差异 图1(外部终端运行): image

图2(vscode插件运行): image

图4(vscode插件运行): image

Expected Behavior

-

Project Configuration

-

Additional Information and Error Logs

-

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


Title: [BUG] xmake running results are inconsistent

waruqi commented 5 months ago

可以对比两边的 envs

xmake l os.getenvs
print(os.getenvs())
Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


You can compare envs on both sides

xmake l os.getenvs
print(os.getenvs())
KarryCharon commented 5 months ago

这里对比了两个运行情况下的 envs, 目前发现有差异的是这几条(PATH相关的变量包含的条目均相互等价但顺序不同): image

以下是envs打印的原始文件: env_terminal.txt env_vscode.txt

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


Here is a comparison of envs under two running conditions. The differences found so far are these items (the entries contained in PATH-related variables are equivalent to each other but in different orders): image

The following is the original file printed by envs: env_terminal.txt env_vscode.txt

waruqi commented 5 months ago

是 PATH 不同,导致优先找到的 python3 不同。。具体为什么会有这些路径,这就不清楚了,你可以自己调下 vscode 的 envs 。。

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


It's because PATH is different, which leads to different python3 being found first. . It's not clear why there are these paths. You can adjust vscode's envs yourself. .

KarryCharon commented 5 months ago

是 PATH 不同,导致优先找到的 python3 不同。。具体为什么会有这些路径,这就不清楚了,你可以自己调下 vscode 的 envs 。。

断点看了vscode的 xmake 插件, ShellExecution 没传env 进去, 即使传递了 自定义的 env 结果仍然不正确

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


The PATH is different, causing the python3 found first to be different. . It's not clear why there are these paths. You can adjust vscode's envs yourself. .

I checked vscode's xmake plug-in with a breakpoint. ShellExecution did not pass env. Even if a custom env was passed, the result was still incorrect.

waruqi commented 5 months ago

估计 vscode 下,PATH 有差异,导致内部的 xmake 进程获取到的 PATH 也有区别,所以找的位置不对。。

你可以 vscode terminal 下看看 PATH 是否跟 外面的 terminal 不同。。

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


It is estimated that there is a difference in PATH under vscode, which leads to a difference in the PATH obtained by the internal xmake process, so the location found is wrong. .

You can run vscode terminal to see if PATH is different from the external terminal. .

KarryCharon commented 5 months ago

估计 vscode 下,PATH 有差异,导致内部的 xmake 进程获取到的 PATH 也有区别,所以找的位置不对。。

你可以 vscode terminal 下看看 PATH 是否跟 外面的 terminal 不同。。

image image
Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


It is estimated that the PATH under vscode is different, resulting in a difference in the PATH obtained by the internal xmake process, so the location found is wrong. .

You can run vscode terminal to see if PATH is different from the external terminal. .

image image
waruqi commented 5 months ago

那就是了么,就是你这 vscode terminal 的 PATH 不同给干扰了,这个这边也没办法,你只能自己调下 这个里面的 path 。。

KarryCharon commented 5 months ago

那就是了么,就是你这 vscode terminal 的 PATH 不同给干扰了,这个这边也没办法,你只能自己调下 这个里面的 path 。。

不是, 上面那个图里的3 个PATH 都是正确的, 但build 运行的lua脚本里的不对啊

KarryCharon commented 5 months ago

那就是了么,就是你这 vscode terminal 的 PATH 不同给干扰了,这个这边也没办法,你只能自己调下 这个里面的 path 。。

不是, 上面那个图里的3 个PATH 都是正确的, 但build 运行的lua脚本里的不对啊

上面三个PATH虽然有区别 但 我自己的pyenv( /Users/karrycharon/.pyenv/shims )都靠前, 当 build 运行时 却拿的 /Library/Frameworks/Python.framework/Versions/3.10/bin 作为python路径

KarryCharon commented 5 months ago

那就是了么,就是你这 vscode terminal 的 PATH 不同给干扰了,这个这边也没办法,你只能自己调下 这个里面的 path 。。

而且 最关键的是 在xmake插件里调整env的 PATH是不起作用的, 好像跟没传一样

waruqi commented 5 months ago

那就是了么,就是你这 vscode terminal 的 PATH 不同给干扰了,这个这边也没办法,你只能自己调下 这个里面的 path 。。

而且 最关键的是 在xmake插件里调整env的 PATH是不起作用的, 好像跟没传一样

这个,你可以自己调下 插件看下 为啥没生效。。然后 插件里面执行 xmake l os.getenvs 看下 PATH 的结果。。以及实际 find——package 那个地方的 PATH 结果

也可以手动执行 xmake 命令编译时候,在那个位置看下 PATH 的结果

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


That's it, it's because the PATH of your vscode terminal is different and interferes with it. There is nothing you can do about it. You can only adjust the path in it yourself. .

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


That's it, it's just that the PATH of your vscode terminal is different and interferes with it. There is nothing you can do about it. You can only adjust the path in it yourself. .

No, the three PATHs in the picture above are all correct, but the ones in the Lua script run by build are wrong.

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


That's it, it's just that the PATH of your vscode terminal is different and interferes with it. There is nothing you can do about it. You can only adjust the path in it yourself. .

And the most important thing is that adjusting the PATH of env in the xmake plug-in does not work, as if it has not been passed.

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


That's it, it's because the PATH of your vscode terminal is different and interferes with it. There is nothing you can do about it. You can only adjust the path in it yourself. .

And the most important thing is that adjusting the PATH of env in the xmake plug-in does not work, as if it has not been passed.

For this, you can adjust the plug-in yourself and see why it doesn't take effect. . Then execute xmake l os.getenvs in the plug-in and see the result of PATH. . And the PATH result of the actual find-package place

You can also manually execute the xmake command to compile and check the PATH result at that location.

KarryCharon commented 5 months ago

那就是了么,就是你这 vscode terminal 的 PATH 不同给干扰了,这个这边也没办法,你只能自己调下 这个里面的 path 。。

而且 最关键的是 在xmake插件里调整env的 PATH是不起作用的, 好像跟没传一样

这个,你可以自己调下 插件看下 为啥没生效。。然后 插件里面执行 xmake l os.getenvs 看下 PATH 的结果。。以及实际 find——package 那个地方的 PATH 结果

也可以手动执行 xmake 命令编译时候,在那个位置看下 PATH 的结果

xmake插件里执行 xmake l os.getenvs 和 实际find_package的env完全一样, 都是错的. 这是我在xmake插件里写的命令行运行方法:

image

这是命令运行结果: image

waruqi commented 5 months ago

那就还是 插件执行 xmake 给的 PATH 不一致,跟 xmake 本身没啥关系了。。你可以调下插件,然后来个 pr

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


That's it, it's because the PATH of your vscode terminal is different and interferes with it. There is nothing you can do about it. You can only adjust the path in it yourself. .

And the most important thing is that adjusting the PATH of env in the xmake plug-in does not work, as if it has not been passed.

This, you can adjust the plug-in yourself and see why it doesn’t take effect. . Then execute xmake l os.getenvs in the plug-in and see the result of PATH. . And the PATH result of the actual find-package place

You can also manually execute the xmake command to compile and check the PATH result at that location.

The execution of xmake l os.getenvs in the xmake plug-in is exactly the same as the actual env of find_package, both of which are wrong. This is the command line running method I wrote in the xmake plug-in:

image

This is the result of running the command: image

Issues-translate-bot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically.


Then the PATH given by the plug-in when executing xmake is inconsistent, and it has nothing to do with xmake itself. . You can adjust the plug-in and do a PR

KarryCharon commented 5 months ago

那就还是 插件执行 xmake 给的 PATH 不一致,跟 xmake 本身没啥关系了。。你可以调下插件,然后来个 pr

我试了下, 非常奇怪, 我重写了PATH, 但 vscode运行Shell 会默认前面自动加一堆PATH

image

image