Skip to content

PATH环境变量中%VMR_VERSIONS%失效问题 #229

@eleven-binary

Description

@eleven-binary

Platform Info

windows 11

Image

Description

在windows上出现环境变量VMR_VERSIONS创建成功,但是在PATH中引用出现%VMR_VERSIONS%没有替换为具体路径的问题;表现现象为通过环境变量管理界面查看PATH变量为%VMR_VERSIONS%\go_versions\go\bin;通过PowerShell通过Get-Content Env:path 查看path变量,%VMR_VERSIONS%没有替换为对应的路径;

Screen Shot

猜测问题原因

在internal/shell/win.go文件中,调用TidyWindowsPathEnv方法进行替换变量内容,但是TidyWindowsPathEnv方法中如果os.Getenv(VMR_VERSIONS_ENV) != VersionsDir,会新建一个shell,进行设置VMR_VERSIONS变量,而win.go文件中设置path环境变量的shell为旧的shell,设置path的值为%VMR_VERSIONS%\go_versions\go\bin时,找不到VMR_VERSIONS变量,导致path变量中的值为字符串的%VMR_VERSIONS%\go_versions\go\bin;

修复思路
在win.go文件中调用TidyWindowsPathEnv方法之后,设置path变量之前,重新new shell进行设置PATH变量;不知道这样修复是否可行?

@moqsien

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions