version-fox / vfox

A cross-platform and extendable version manager with support for Java, Node.js, Flutter, .Net & more
https://vfox.lhan.me
Apache License 2.0
2.85k stars 102 forks source link

[BUG]: vfox 在iterm2中出现无法在会话中切换环境版本 #294

Closed fangzhengjin closed 4 months ago

fangzhengjin commented 5 months ago

Version 0.5.3 OS macOS

Describe the bug 使用vfox u -g java设置全局版本后,在会话中使用vfox u java临时切换版本无效 并且观察到在控制台只要有命令执行,并没有使用vofx命令vfox也会一直在temp下创建临时目录

Screenshots[optional] If applicable, add screenshots to help explain your problem.

aooohan commented 5 months ago

贴一下debug日志.

vfox --debug use java

你用的zulu吗

fangzhengjin commented 5 months ago
vfox --debug use java
Please select a version of java:
  -> 11.0.22+7-tem
Use SDK version: 11.0.22+7-tem, scope:session
plugin does not have PreUse function
Removing old package path: /Users/xxxxxx/.version-fox/temp/1716825600-17832/java
Create symlink /Users/xxxxxx/.version-fox/cache/java/v-11.0.22+7-tem/java-11.0.22+7-tem -> /Users/xxxxxx/.version-fox/temp/1716825600-17832/java
Now using java@11.0.22+7-tem.
image
fangzhengjin commented 5 months ago

下面是频繁创建目录的录屏

https://github.com/version-fox/vfox/assets/12680972/a1b25855-7108-4f81-83da-2636a777fc2e

aooohan commented 5 months ago

你用的这是什么shell, 正常来说这个临时目录只会在第一次打开shell的时候创建.

fangzhengjin commented 5 months ago

你用的这是什么shell, 正常来说这个临时目录只会在第一次打开shell的时候创建.

zsh + iterm2 + omzsh + starship

fangzhengjin commented 5 months ago

我试了下排除法,只要不用iterm2就可以。。。很奇怪

fangzhengjin commented 5 months ago

看起来是iterm2出了什么问题,退出重启iterm2恢复正常了

fangzhengjin commented 5 months ago

试了很多次,包括重装iterm2,还是会出现这种情况,不知道还有没有其他使用iterm2的朋友遇到这种

fangzhengjin commented 4 months ago

此问题出现的原因是有一些命令行智能补全工具,例如FigAmazon Q会在用户输入时启动子进程展示补全信息,子进程会重复初始化vfox环境,导致主进程的vfox异常

fangzhengjin commented 4 months ago

新版本发布前的临时解决方式是使用下方的初始化脚本控制vfox的初始化时机

if [[ -z "$__VFOX_PID" ]]; then
    eval "$(vfox activate zsh)"
fi
fangzhengjin commented 4 months ago

closed by #311