choco
choco copied to clipboard
Add PowerShell helper function to manage removing paths from $PATH
There is a useful helper Install-ChocolateyPath which I use to add directories to the PATH variable. I would like to see an Uninstall-ChocolateyPath as well to cleanup those directories from the PATH variable at uninstall time. I guess this would apply to quite a few other helpers which only have an "Install" part.
Yep, we had something logged somewhere for these.
Wanna open it up for grab?
@tirolo done.
Just for an idea, wouldn't it be nice if the auto-uninstaller would be able to take care of this as well? Either snapshot the environment before and after the install (or only PATH environment variable) or have Install-Chocolatey log something for the uninstall
Sounds nice - keep in mind it should only remove the added values and not restore the previous version (that would be bad).
Will start working on this one as soon as I get my read around the docs I have to read before start contributing + learn some github :smile: (shouldn't take long)
@ferventcoder Should I target master?
@tirolo master is set for 0.9.11.x, and stable is set for 0.9.10.x. I'd target stable if you can.
There was a PR for this in the old chocolatey repo https://github.com/chocolatey/chocolatey/pull/542
Moving discussion back over to here, @DarwinJS See - #303
Not sure if it's still relevant, but here is a link to the code I put together for this today. The code I did also handles removing duplicates (if the path to remove is in more than once), handles the path whether or not there is a trailing slash versus what is specified on the removal string and it handles removing extra ";' that are found. The code is not generalized to handle both user and machine path. https://github.com/DarwinJS/ChocoPackages/blob/master/ec2clitools/tools/chocolateyuninstall.ps1
This is related to https://github.com/chocolatey/choco/issues/303
I'll take this one.
I am wondering a few things about this code: *) Does it make sense to remove the requested string from both user and computer path? On one hand if I was requesting a removal I would just want it gone no matter what paths it appeared on if the software was just removed. On the other hand it may make uninstalls reach to things that weren't instended.
Hmmm - what if it could take params "user", "machine" and "all" ? Should it default to "All" if unspecified or just always require the param?
PR: https://github.com/chocolatey/choco/pull/1019
Are there any plans to merge the PR fixing this issue? Seems like this is being pushed to next milestones since Mar 22.
@improbablepiotr yes, there are plans to merge. We've had a few higher priority things come in during the interim.
What's the recommended way to remove a path installed with Install-ChocolateyPath? Not doing so pops a guideline warning when publishing a package.
Hi guys, do you have an ETA on when you are planing to merge this feature? I'm currently handling it manually but quite a bit of logic has to go in to make it reasonable robust (expand tokens, handle duplicated entries, handle empty paths, handle empty semicolons, etc)
So, 4 years later... still nothing? :)
I have a PR up at https://github.com/chocolatey/choco/pull/1663.
which was created over a year ago...
Another bump, this addition would be very helpful for package creation.
Just in case it may be helpful to anyone, this is how @DarwinJS did it - posting it here since the original repo was moved to GitLab: https://gitlab.com/DarwinJS/ChocoPackages/-/blob/master/ec2clitools/tools/chocolateyuninstall.ps1
I just tested it, works pretty well.
Thanks, but would be nice if #1663 can be merged (or at least reviewed). Currently that PR seems to be simply ignored, I assume because it never got priority.
Bumping with my vote for this. It's in the homestretch; someone just needs to put on the gloves and give it a little polish.
I suggested some changes on #1663 and have been using a modified version for over a year. Hasn't destroyed anyone's PATH
as far as I can tell.
:tada: This issue has been resolved in version 2.3.0 :tada:
The release is available on:
Your GitReleaseManager bot :package: :rocket: