Skip to content

*** Goose deleting User Environment Path variables - Overwriting with System Environment Path Variables !!! using PS setx which has a character limit of 1024 #3276

@HydAu

Description

@HydAu

Describe the bug winShim.ts

When goose adds the environment path variable it is using $Env:Path which is both System Path Environment variables and User Path Environment variables. File WInshim.ts.
The code is using setx which updates the User path variables, however the code is using $Env:Path and replacing the user path variables with System path variables.

Currently it adds two entries to user path environment
ex
C:\Users\I9\AppData\Local\Goose\bin
and
C:\Users\I9\AppData\Local\Goose\bin
(where in my case I9 is the username)

Then replaces the user paths vars with system path vars.

Image up to 1024 characters truncates the last entry.

Test on the move code also point to missing the last variable as it does not have a ;
Which I expect keeps the last value from being updated.

Note: Please check the common issues on https://block.github.io/goose/docs/troubleshooting before filing a report

A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
    Check environment path variables System Properties / Environment variables user and system path.
Image Image

Expected behavior
A clear and concise description of what you expected to happen.
Expect it to add variable to user path environment variables not destroying any current or future user path environment variables.

Hurdles to replicate, PowerShell caching variables.

Can use
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")

To update $env:Path in PS.

$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
This will get current User path environment variables which then could be used as the list so not to overwrite with System values.

Sudo code

  $userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
  $bin = "c:\test"
  $l = ($bin.Length + $userPath.Length)
  if (-not ($userPath -split ';' | Where-Object { $_ -ieq $bin })) {
    # Add to beginning of PATH for priority
    if (($bin.Length + $userPath.Length) -lt 1024.)
    {
    setx PATH "$bin;$userPath" >$null
    Write-Host "Added Goose bin directory to beginning of user PATH"
  }
  else
  {
  echo "too long"
  }
  }

However, there is other code that would add to the front of the System path Environment variables.
Which doesn't have the length limitation.
I'll find and add later.

Now to try and work out all the user environment variables that have been lost.
Known - VSCode

OS WIndows

Screenshots
If applicable, add screenshots to help explain your problem.

Please provide following information:

  • OS & Arch: [e.g. Ubuntu 22.04 x86]
  • Interface: [UI/CLI]
  • Version: [e.g. v1.0.2]
  • Extensions enabled: [e.g. Computer Controller, Figma]
  • Provider & Model: [e.g. Google - gemini-1.5-pro]

Additional context
Add any other context about the problem here.

Quitting and restarting goose will re-add - can be used for investigation.

Metadata

Metadata

Assignees

Labels

onboardingSetup/configuration/first-time user experiencep0Priority 0 - Critical/Urgent

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions