version-fox / vfox

A cross-platform and extendable version manager with support for Java, Node.js, Flutter, .Net & more

Home Page:https://vfox.lhan.me

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]: Failed to switch environment in external bash script file

ZhengQinyu opened this issue · comments

commented

Version
0.4.2
OS
Linux

Describe the bug
在bash脚本中使用 vfox use -s java@17.0.2+8,打印出来还是之前版本的jdk

默认版本

image

创建一个demo.sh脚本,内容如下

image
打印结果如下,没有成功切换版本

image

因为vfox的机制是利用shell hook进行刷新. 你这么写shell是不会执行hook的. 所以需要手动刷新一下.

参考下面的配置.

https://github.com/version-fox/vfox-php/blob/ab95a5a317c6e5f7fc9e8622c3978c14d890ce35/.github/workflows/test-linux.yaml#L34-L37

另外你的使用场景是什么?

commented

我需要的功能是:在shell脚本中切换jdk版本,进行不同java项目的打包。我以为这种需求应该很常用吧?

commented

手动刷新是可以的,但是感觉有些麻烦。

image

image

我需要的功能是:在shell脚本中切换jdk版本,进行不同java项目的打包。我以为这种需求应该很常用吧?

是的, 有解决方案了. 0.5.0下个版本修复.