Skip to content

Windows 下 uv 换源方法错误 #196

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

Open
1 task done
xrgzs opened this issue May 13, 2025 · 4 comments
Open
1 task done

Windows 下 uv 换源方法错误 #196

xrgzs opened this issue May 13, 2025 · 4 comments
Assignees
Labels
pl_target pl target Windows Windows相关
Milestone

Comments

@xrgzs
Copy link
Contributor

xrgzs commented May 13, 2025

你操作了什么?

chsrc set uv

发生了什么?

换源没有生效,写 uv.toml 配置文件的位置错误。

本应该怎么样?

根据 文档

uv will also discover user-level configuration at ~/.config/uv/uv.toml (or $XDG_CONFIG_HOME/uv/uv.toml) on macOS and Linux, or %APPDATA%\uv\uv.toml on Windows; and system-level configuration at /etc/uv/uv.toml (or $XDG_CONFIG_DIRS/uv/uv.toml) on macOS and Linux, or %SYSTEMDRIVE%\ProgramData\uv\uv.toml on Windows.

Windows 的路径应该为 %APPDATA%\uv\uv.toml,如:C:\Users\Xiaoran\AppData\Roaming\uv\uv.toml

存放到 ~/.config/uv/uv.toml 则不会读取,换源失败。

chsrc 版本

chsrc: Change Source (GPLv3+) v0.2.1-2025/04/13 by RubyMetric

你使用的是哪个操作系统?

Windows

OS 版本 / OS 发行版

Microsoft Windows [版本 10.0.19045.5608]

Log 输出

PS> chsrc set uv
[chsrc 测速] 测速中

  ^ 上游默认源 (https://pypi.org/simple) ... 0.00 Byte/s | HTTP码 000
  - 北京外国语大学开源软件镜像站 ... 52.22 MByte/s
  - 兰州大学开源社区镜像站 ... 34.67 MByte/s
  - 吉林大学开源镜像站 ... 41.20 MByte/s
  - 上海交通大学致远镜像站 ... 39.38 MByte/s
  - 清华大学开源软件镜像站 ... 42.01 MByte/s
  - 阿里巴巴开源镜像站(公网) ... 491.14 KByte/s
  - 南京大学开源镜像站 ... 20.32 MByte/s
  - 北京大学开源镜像站 ... 39.73 MByte/s
  - 腾讯软件源(公网) ... 99.86 KByte/s
  - 华为开源镜像站 ... 56.51 MByte/s
  - 华中科技大学开源镜像站 ... 39.05 MByte/s

最快镜像站: 华为开源镜像站
[chsrc 提示] 目录不存在,已自动创建 C:\Users\Xiaoran\.config\uv\
[chsrc 提示] 文件不存在,跳过备份: ~/.config/uv/uv.toml
[chsrc 运行] printf '[[index]]
url = "https://mirrors.huaweicloud.com/repository/pypi/simple"
default = true
' >> ~/.config/uv/uv.toml
'[[index]][chsrc 运行] ✓ 命令执行成功

--------------------------------
chsrc: 全自动换源完成, 感谢镜像提供方: 华为开源镜像站
PS> uv add requests
⠸ charset-normalizer==3.4.2 ...等半天都没反应

防止重复问题

  • 我已在项目的 GitHub 和 Gitee 两个仓库分别搜索过类似的 issue
@xrgzs xrgzs added the Bug 存在缺陷 label May 13, 2025
@ccmywish ccmywish added this to the v0.2.2 milestone May 15, 2025
@ccmywish ccmywish added pl_target pl target Windows Windows相关 and removed Bug 存在缺陷 labels May 15, 2025
@happy-game happy-game self-assigned this May 20, 2025
@happy-game
Copy link
Collaborator

事实上不只是存在这一问题, 因为有些命令无法使用(printf, grep, sed), 在 windows 上为 uv换源的命令也无法很好地运行.

这个问题应该要花费较长的时间去解决.

@xrgzs
Copy link
Contributor Author

xrgzs commented Jun 2, 2025

有些命令无法使用(printf, grep, sed)

我的Windows环境中已安装busybox,printf命令运行正常。此issue的核心问题在于文件路径错误。不过,若能避免依赖第三方组件,直接采用 C 原生方法实现文件读写和内容替换功能会是更优的解决方案。

@happy-game
Copy link
Collaborator

我的Windows环境中已安装busybox,printf命令运行正常。此issue的核心问题在于文件路径错误。不过,若能避免依赖第三方组件,直接采用 C 原生方法实现文件读写和内容替换功能会是更优的解决方案。

感谢提醒, 已在 #200 中实现, 等合并后可以拉取最新的 dev 分支进行测试.

@happy-game
Copy link
Collaborator

但目前仍存在一些问题, 由于 grep, sed命令的行为在 windows 的 Cygwin环境下存在差异(busybox中没有测试), 故暂时不支持直接修改已存在的 uv.toml, 需等待后续解决.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pl_target pl target Windows Windows相关
Projects
None yet
Development

No branches or pull requests

3 participants