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

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

Closed
ZhengQinyu opened this issue May 7, 2024 · 4 comments · Fixed by #256
Closed

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

ZhengQinyu opened this issue May 7, 2024 · 4 comments · Fixed by #256
Labels
bug Something isn't working
Milestone

Comments

@ZhengQinyu
Copy link

Version
0.4.2
OS
Linux

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

默认版本

image

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

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

image

@ZhengQinyu ZhengQinyu added the bug Something isn't working label May 7, 2024
@ZhengQinyu ZhengQinyu changed the title [BUG]: Some problem... [BUG]: 外部bash脚本文件中切换环境失败 May 7, 2024
@aooohan
Copy link
Member

aooohan commented May 9, 2024

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

参考下面的配置.

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

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

@ZhengQinyu
Copy link
Author

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

@ZhengQinyu
Copy link
Author

ZhengQinyu commented May 9, 2024

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

image

image

@aooohan
Copy link
Member

aooohan commented May 9, 2024

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

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

@aooohan aooohan changed the title [BUG]: 外部bash脚本文件中切换环境失败 [BUG]: Failed to switch environment in external bash script file May 9, 2024
@aooohan aooohan added this to the 0.5.0 milestone May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants