Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

choco uninstall all does not honor dependencies #1822

Open
mkevenaar opened this issue May 10, 2019 · 11 comments
Open

choco uninstall all does not honor dependencies #1822

mkevenaar opened this issue May 10, 2019 · 11 comments

Comments

@mkevenaar
Copy link
Contributor

mkevenaar commented May 10, 2019

What You Are Seeing?

choco uninstall all -y uninstalling all on alphabet

What is Expected?

Uninstalling honoring the dependencies

How Did You Get This To Happen? (Steps to Reproduce)

NOTE Only try this on the chocolatey-test-environment or a test machine!

  1. choco install ci-cd-assets-vscode
  2. choco uninstall all -y

I would expect that it would uninstall

  1. ci-cd-assets-vscode
  2. chocolatey-vscode.extension
  3. vscode

Actual order is 2,1,3 (including chocolatey, as expected)

@ferventcoder
Copy link
Member

Does it error when it goes the wrong way?

@mkevenaar
Copy link
Contributor Author

@ferventcoder as choco currently first uninstalls the extension, the POSH module and it’s commands are removed before the uninstallation of the vscode add-on package.

In the add-on uninstaller, the one of the POSH module commandlets is used to remove the add-on from vscode.

@mkevenaar
Copy link
Contributor Author

@ferventcoder I’ll try to make a gist soon.

@mkevenaar
Copy link
Contributor Author

@ferventcoder https://gist.github.com/mkevenaar/9461720e59305b0b6602bda880fe2147

On line 554 you'll see the error message that Uninstall-VsCodeExtension is not found. It has been uninstalled on line 329.

/cc: @gep13

@ferventcoder
Copy link
Member

ferventcoder commented May 13, 2019

Oh I think I understand. The packages required extensions in other packages that were removed first. So I don't think NuGet supports dependency order by default - you can force dependencies on uninstall if you want it to attempt proper order.

@mkevenaar
Copy link
Contributor Author

@ferventcoder When you have things setup as mentioned above, and try to run choco uninstall vscode The installation tells you that you can't uninstall vscode as ci-cd-assets-vscode depends on it.

@ferventcoder
Copy link
Member

When you have things setup as mentioned above, and try to run choco uninstall vscode The installation tells you that you can't uninstall vscode as ci-cd-assets-vscode depends on it.

@mkevenaar that is correct behavior. You need to uninstall things in the proper order. Which is about what this issue is. What happens if you run choco uninstall ci-cd-assets-vscode --force-dependencies?

@mkevenaar
Copy link
Contributor Author

mkevenaar commented May 21, 2019

@ferventcoder that was not the point I was trying to make here.
I have given one example where I know it would go wrong when running choco uninstall all

I think this might be the location of the problem:

set_package_names_if_all_is_specified(config, () =>
{
// force remove the item, ignore the dependencies
// as those are going to be picked up anyway
config.Force = true;
config.ForceDependencies = false;
});

@ferventcoder
Copy link
Member

Do you think removing the force dependencies would work? Something we could do without #508

@mkevenaar
Copy link
Contributor Author

mkevenaar commented May 27, 2019

I think this needs to be tested, but it might work.

@VishalJadav
Copy link

Solution:

When you specify "all", chocolatey grabs packages from here:

private void set_package_names_if_all_is_specified(ChocolateyConfiguration config, Action customAction)

var packagesToUpdate = get_all_installed_packages(config).Select(p => p.Name).ToList();

The list "packagesToUpdate" needs to be ordered according to dependency flow. This can be done via Topological sorting using depth-first search (DFS) algorithm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants