[BUG]: shell hook settings not working in non-interactive shell environments
Closed this issue · 12 comments
Version
0.6.6
OS
macOS、Linux、Windows
Describe the bug
0.6.6 版本使用 Invoke-Expression "$(vfox activate pwsh)" 在类似 GitHub Actions 的 CI 非交互式 Shell 环境,去 Hook Shell 无法正常工作,但是 0.6.5 版本可以正常工作 .
The hook in the shell cannot work properly using
Invoke-Expression "$(vfox activate pwsh)"in a non-interactive Shell environment like GitHub Actions for version 0.6.6, but version 0.6.5 works properly.
在 vfox-elixir 插件的自动化测试中可以复现:
vfox v0.6.6 版本的表现 (Hook Shell 失败):https://github.com/version-fox/vfox-elixir/actions/runs/14919027834/job/41910769190
vfox v0.6.5 版本的表现(Hook Shell 成功):https://github.com/version-fox/vfox-elixir/actions/runs/14697942165/job/41242382955
This issue can be reproduced in the automated tests of the vfox-elixir plugin:
Behavior with vfox 0.6.6 version(Hook Shell Succ): https://github.com/version-fox/vfox-elixir/actions/runs/14919027834/job/41910769190
Behavior with vfox 0.6.5 version(Hook Shell Failure): https://github.com/version-fox/vfox-elixir/actions/runs/14697942165/job/41242382955
Ubuntu, MacOS 的非交互式环境使用 eval "$(vfox activate bash)" or eval "$(vfox activate zsh)" 去 Hook Shell 均有此问题出现。
会导致 vfox use 不成功。
Ubuntu, MacOS non-interactive environments both have this problem when using
eval "$(vfox activate bash)"oreval "$(vfox activate zsh)"
两个原因导致了这个问题.
- vfox本身引入了bug, 应该打开新进程,而不是执行命令.
- scoop安装的vfox自带shim, 导致vfox获取ppid拿到的是shim的pid,而不是powershell的pid.
尝试从源码构建出 vfox,仍然还有其他问题,$PATH 中没有注入 vfox 相关的路径,导致插件安装的 bin 或者 exe 文件找不到.
There are still other problems in trying to build vfox from the source code; $PATH does not have the path related to vfox injected, resulting in the inability to find the bin or exe files installed by the plugin.
复现 (reporduce):https://github.com/version-fox/vfox-erlang/actions/runs/15068818061/job/42359752544
v0.6.5 (没有问题的)版本 $PATH 如下,来自 action:
The
$PATHfor version v0.6.5 (problem-free) is as follows, from the action:
vfox main 分支构建出来的版本 $PATH 如下:
The
$PATHof the version built from thevfox mainbranch is as follows:
看起来是自己构建的 vfox 在使用 vfox activate 后,会调用 powershell 创建一个新终端
跟这个没关系,正常这样,也是可以使用的.
很奇怪, 我本地没有复现出来
Please use vfox use erlang@25.3.2.12 to use it.
当前进程 ID (PID): 1736
Use SDK version: 25.3.2.12, scope:session
Load SDK package item: name:erlang, version: 25.3.2.12
PreUseHookCtx: {Cwd:D:\a\vfox-erlang\vfox-erlang Scope:session Version:25.3.2.12 PreviousVersion: InstalledSdks:map[25.3.2.12:0xc0001311d0]}
CallFunction: PreUse
Warning: The current shell lacks hook support or configuration. It has switched to global scope automatically.
Removing old package path: C:\Users\runneradmin\.version-fox\cache\erlang\current
Create symlink C:\Users\runneradmin\.version-fox\cache\erlang\v-25.3.2.12\erlang-25.3.2.12 -> C:\Users\runneradmin\.version-fox\cache\erlang\current
EnvKeysHookCtx: &{Main:0xc0001312c0 Path:C:\Users\runneradmin\.version-fox\cache\erlang\current SdkInfo:map[]}
CallFunction: EnvKeys
EnvKeysHookResult: &{Variables:map[] BinPaths:<nil> Paths:C:\Users\runneradmin\.version-fox\cache\erlang\current\release\bin}
Write shim binary to C:\Users\runneradmin\.version-fox\shims\ct_run.exeWrite shim file to C:\Users\runneradmin\.version-fox\shims\ct_run.shimWrite shim binary to C:\Users\runneradmin\.version-fox\shims\dialyzer.exeWrite shim file to C:\Users\runneradmin\.version-fox\shims\dialyzer.shimWrite shim binary to C:\Users\runneradmin\.version-fox\shims\erl.exeWrite shim file to C:\Users\runneradmin\.version-fox\shims\erl.shimWrite shim binary to C:\Users\runneradmin\.version-fox\shims\erl_call.exeWrite shim file to C:\Users\runneradmin\.version-fox\shims\erl_call.shimWrite shim binary to C:\Users\runneradmin\.version-fox\shims\erlc.exeWrite shim file to C:\Users\runneradmin\.version-fox\shims\erlc.shimWrite shim binary to C:\Users\runneradmin\.version-fox\shims\escript.exeWrite shim file to C:\Users\runneradmin\.version-fox\shims\escript.shimWrite shim binary to C:\Users\runneradmin\.version-fox\shims\typer.exeWrite shim file to C:\Users\runneradmin\.version-fox\shims\typer.shimWrite shim binary to C:\Users\runneradmin\.version-fox\shims\werl.exeWrite shim file to C:\Users\runneradmin\.version-fox\shims\werl.shimopen a new shell: 1736
open a new shell: C:\Program Files\PowerShell\7\pwsh.EXE
PowerShell 7.4.7
PS D:\a\vfox-erlang\vfox-erlang> 当前进程 ID (PID): 1736vfox 会打开新shell并将输入输出链接到当前vfox进程. 从日志来看, action的ci显然没有将后续命令放到新输入下执行.
之前没问题,是因为碰巧scoop使用了shim, vfox打开进程的时候不是powershell, 而是vfox本身, 外加手动调用了activate命令.
@yeshan333 修复了, 根因是因为 #449 引入的bug, {{.EnvContent}}移动到了moudle里, 导致环境变量设置失败引起的. 现在ci已经正常了.
https://github.com/version-fox/vfox-erlang/actions/runs/15068818061
bro, 我试跑了下新发布的 0.6.9, 还是不行 ( ╯□╰ ):https://github.com/version-fox/vfox-erlang/actions/runs/15116029066/job/42487183718?pr=11 @aooohan
@yeshan333 修了, 纯手残,加了两行注释导致的。 你再试试,没问题,晚上在发一版。
可以了,Thank you bro~





