Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to fetch repository if an empty folder is present #2159

Closed
xq114 opened this issue Mar 13, 2022 · 22 comments
Closed

Fail to fetch repository if an empty folder is present #2159

xq114 opened this issue Mar 13, 2022 · 22 comments
Labels

Comments

@xq114
Copy link
Contributor

xq114 commented Mar 13, 2022

Xmake 版本

2.6.4

操作系统版本和架构

Windows 10

描述问题

在xmake fetching remote repo过程中如果中途ctrl+c打断,会在~/.xmake/repositories文件夹留下一个build-artifacts的空文件夹;存在空文件夹时再执行xmake只会报错fatal: not a git repository,只能靠手动删除空文件夹解决

期待的结果

xmake应自动修复此类问题。例如,在更新remote repositories时,先检查目标文件夹是否包含.git,如果不包含则删除目标文件夹重新git clone;或者运行git pull失败,则删除目标文件夹重新clone

工程配置

No response

附加信息和错误日志

> xmake -vD
checking for ...
...
updating repositories ..
pulling repository(build-artifacts): https://gitee.com/xmake-mirror/build-artifacts.git to C:\Users\xq114\AppData\Local\.xmake\repositories\build-artifacts ..
git pull origin main
fatal: not a git repository (or any of the parent directories): .git
error: @programdir\core\main.lua:280: @... failed
stack traceback:
...
[@programdir\plugins\repo\main.lua:137]: in function '_update'
[@programdir\plugins\repo\main.lua:233]:
@xq114 xq114 added the bug label Mar 13, 2022
@waruqi
Copy link
Member

waruqi commented Mar 13, 2022

可以了,再试试,不过没测过

@xq114 xq114 closed this as completed Mar 13, 2022
@xq114
Copy link
Contributor Author

xq114 commented Sep 27, 2022

这里光检测空文件夹还不够,中间打断之后不一定是空文件夹,也可能是有一些文件的损坏文件夹

image

最好用git来检测,如果pull失败那就删掉整个文件夹再试

@xq114 xq114 reopened this Sep 27, 2022
@waruqi
Copy link
Member

waruqi commented Sep 27, 2022

删非空还安全点,删非空有点危险哈,要是有个其他的 bug ,删错目录就蛋疼了。

而且每次都得用 git 去判断,感觉有点重

@xq114
Copy link
Contributor Author

xq114 commented Sep 28, 2022

那能不能提供一个命令一键清理无效的仓库呢?有很多人都遇到了这个问题

@xq114
Copy link
Contributor Author

xq114 commented Sep 28, 2022

fe366efeb6cc4266ead1cb8373cb07a
他们目录长这样

@waruqi
Copy link
Member

waruqi commented Sep 28, 2022

fe366efeb6cc4266ead1cb8373cb07a 他们目录长这样

这个不是有 .git 么,啥问题呢?

@xq114
Copy link
Contributor Author

xq114 commented Sep 28, 2022

好像还不是打断的问题,因为这里clone下来的仓库是完整的;可能是并行的问题,出现了数据冲突,报错fatal: not a repository (or any of the parent directories) : .git

@xq114
Copy link
Contributor Author

xq114 commented Sep 28, 2022

是不是同时运行多个git命令引起的?

@waruqi
Copy link
Member

waruqi commented Sep 28, 2022

是不是同时运行多个git命令引起的?

是的,目前是并行拉的。

runjobs("update repo", task, {progress = true})

带 -v 禁用并行,为了看 verbose logs

@waruqi
Copy link
Member

waruqi commented Sep 28, 2022

你可以这里改成这样试下,加上 {isolate = true} ,对 curdir 和 envs 进行 task 隔离,看看是否还有这个问题

        runjobs("update repo", task, {progress = true, isolate = true})

@waruqi waruqi added this to the v2.7.2 milestone Sep 28, 2022
@xq114
Copy link
Contributor Author

xq114 commented Sep 28, 2022

这个问题也不是人人都有的,随机出现,很可能就是并行的问题,刚刚那个情况build-artifacts是好的,但xmake-repo里面只有一个不完整的.git文件夹

@xq114
Copy link
Contributor Author

xq114 commented Sep 28, 2022

我这也不能稳定复现。要么检测一下只有.git的文件夹删掉?

waruqi added a commit that referenced this issue Sep 28, 2022
@waruqi
Copy link
Member

waruqi commented Sep 28, 2022

我这也不能稳定复现。要么检测一下只有.git的文件夹删掉?

如果有 .git ,就不会提示 not a git repo 的错误了,我 dev 先加了 isolate ,后面先观察一段时间吧,看看还会不会出现

@waruqi waruqi removed this from the v2.7.2 milestone Oct 8, 2022
@xq114
Copy link
Contributor Author

xq114 commented Oct 12, 2022

问题还是在,能不能加个命令手动清理所有repository?

@waruqi
Copy link
Member

waruqi commented Oct 12, 2022

xrepo rm-repo --all
xrepo update-repo

@waruqi
Copy link
Member

waruqi commented Nov 25, 2022

不知道是否跟这个有没有关系,比如并行拉取 repo 时候,互相占用对方 repo 目录,导致拉取失败等等。#2902 (comment)

我 dev 改进了进程启动,收敛了 handles 继承范围,可以尝试更新到 dev,然后再观察一段时间看看。

@xq114
Copy link
Contributor Author

xq114 commented Nov 26, 2022

https://github.com/xmake-mirror/build-artifacts/actions/runs/3548938402/jobs/5961867476

这里报handle is invalid,不知道是不是改动的副作用

@waruqi
Copy link
Member

waruqi commented Nov 26, 2022

看着像是,但是很奇怪,xmake-repo 和 xmake 的 ci 上也都在跑 dev ,就没遇到这个问题,我这暂时无法本地复现

@waruqi
Copy link
Member

waruqi commented Nov 26, 2022

修复了 应该可以了

@waruqi
Copy link
Member

waruqi commented Nov 27, 2022

https://github.com/xmake-mirror/build-artifacts/actions/runs/3548938402/jobs/5961867476

这里报handle is invalid,不知道是不是改动的副作用

这个 job 我重新跑过了

@waruqi
Copy link
Member

waruqi commented Feb 23, 2024

最近还有这个问题么,没有的话,可以先关了。。

@Issues-translate-bot
Copy link

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


Have you had this problem recently? If not, you can turn it off first. .

@xq114 xq114 closed this as completed Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants