vfox
vfox copied to clipboard
[BUG]: `vfox cd` doesn‘t work on Windows
Version 0.5.3
OS Windows
Describe the bug
The command vfox cd does not work on Windows. Instead of switching the shell directory as expected, it prints the usage instructions.
Screenshots[optional]
~/Documents/CodeRepo/Project/vfox> vfox cd 04/24/2024 03:15:38 PM
NAME:
vfox - vfox is a tool for runtime version management.
USAGE:
vfox [command] [command options]
VERSION:
0.4.1
DESCRIPTION:
vfox is a cross-platform version manager, extendable via plugins. It allows you to quickly install and switch between different environment you need via the command line.
COMMANDS:
config Setup, view config
cd Launch a shell in the VFOX_HOME or SDK directory
help, h Shows a list of commands or help for one command
Plugin:
info Show plugin info
available Show all available plugins
update Update specified plugin, use --all/-a to update all installed plugins
remove Remove a plugin
add Add a plugin or plugins
SDK:
install, i Install a version of the target SDK
current, c Show current version of the target SDK
use, u Use a version of the target SDK
list, ls List all versions of the target SDK
uninstall, un Uninstall a version of the target SDK
search Search a version of the target SDK
env
GLOBAL OPTIONS:
--debug show debug information (default: false)
--help, -h show help
--version, -v, -V print version (default: false)
COPYRIGHT:
Copyright 2024 Han Li. All rights reserved.
~/Documents/CodeRepo/Project/vfox>
Powershell and Clink are not reproduced, what shell are you using, gitbash?
PowershellandClinkare not reproduced, what shell are you using,gitbash?
I'm using Powershell, and it can reproduce stably.
PS C:\Users\Sunrise> $psversiontable
Name Value
---- -----
PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
vfox cd works for me both with PS and PS Core:
Name Value
PSVersion 5.1.22621.2506 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.2506 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Name Value
PSVersion 7.4.2 PSEdition Core GitCommitId 7.4.2 OS Microsoft Windows 10.0.22631 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
It doesn't work in git bash either.
Sunrise@Yane MINGW64 ~
$ echo $VFOX_HOME
C:\Users\Sunrise\.version-fox
Sunrise@Yane MINGW64 ~
$ vfox cd
open a new shell failed, err:exec: no command
Sunrise@Yane MINGW64 ~
$ vfox use [email protected]
Now using [email protected].
Sunrise@Yane MINGW64 ~
$ vfox cd ruby
open a new shell failed, err:exec: no command
After further exploration, I found that the vfox I compiled myself works in both powershell and nushell, with the path variable correctly assigned to the shell's executable. However, the behavior of vfox installed via Scoop is the same as in Git Bash, where the path variable is empty.
https://github.com/version-fox/vfox/blob/52ff51c973e1ae53429ac1e3693f20864c958bab/internal/shell/windows_process.go#L49
However, the behavior of vfox installed via Scoop is the same as in Git Bash, where the
pathvariable is empty.
Good catch!
scoop exposes vfox to PATH using a shim, which results in pid put in this function that is not the shell's but the scoop shim.
We may need to modify manifest provided to scoop to expose vfox directly to PATH without using a shim.
https://github.com/ScoopInstaller/Main/blob/2a4ee74939962bdc224e1a1554078e76ca089ca4/bucket/vfox.json#L27