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 source priority is ignored #1541

Open
daveschafer opened this issue Apr 18, 2018 · 24 comments · Fixed by #2286 or #2420
Open

choco source priority is ignored #1541

daveschafer opened this issue Apr 18, 2018 · 24 comments · Fixed by #2286 or #2420

Comments

@daveschafer
Copy link

What You Are Seeing?

If you have multiple chocolatey sources, the priority which you give them is not applied.

Quote from the Choco Wiki:

Priority - The priority order of this source as compared to other
sources, lower is better. Defaults to 0 (no priority). All priorities
above 0 will be evaluated first, then zero-based values will be
evaluated in config file order

This issue happens if you have the default source set to 0 or to a higher number than your prefered source.

What is Expected?

The expectation is that every source with priority > 0 is prefered and that the lower the the priority number, the higher the priority. Nevertheless this does not seem to be the case.

Another Quote from Gary Ewan Parker regarding the default behaviour:

Each source can have a priority, which defines the order that Chocolatey searches the sources to find a package. If a package is found on a higher priority source, that package version is used even if there is a newer version on another lower priority source.

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

In this Example we have ccleaner 5.35.6210 on our own source, the public source provides the version 5.41.6446. Here you can see, that the "chocolatey" priority is set to 2 (same behaviour with 0) and our "tkcloud" source is set to 1 (lower so it should be prefered):

2018-04-18_10h56_00
Nevertheless, the public version is selected.

If we disable the default repository, the correct version from our source is selected:
2018-04-18_10h58_13

We could verify this faulty behaviour on multiple systems. Even a remove and readd of the sources does not resolve this

Output Log

On another note, the choco list commands provides the packages in the correct order:

2018-04-18 12_21_58-auswahlen windows powershell

The only problem seems to be the install commands.

@ferventcoder
Copy link
Member

Hi @daveschafer, very well documented. This was first discovered as #1190, and we verified what you are seeing back in September timeframe. We have this in the backlog to fix so it works as documented. It turns out it was a bug in NuGet.Core that wasn't respecting this setting correctly.

@ferventcoder ferventcoder added this to the 0.10.11 milestone Apr 19, 2018
@ferventcoder ferventcoder modified the milestones: 0.10.11, 0.10.12 May 3, 2018
@sudoturnkey
Copy link

Hi @ferventcoder
We also have this problem with different customers and can't rollout any controlled softwareupdates with chocolatey. When do you expect that this bug is fixed.
thank you

@bcurran3
Copy link

bcurran3 commented Aug 3, 2018

@sudoturnkey
I played with this months ago and I THINK if you edit chocolatey.config and change the sources to the order of your preferences, you'll get the results you want.

i.e. move your source above:
<source id="chocolatey" value="https://chocolatey.org/api/v2/" disabled="false" bypassProxy="false" selfService="false" adminOnly="false" priority="0" />

I could be wrong. Try it and see what results you get.

@bcurran3

This comment has been minimized.

@mwallner
Copy link
Member

mwallner commented Dec 7, 2018

as long as this issue persists, you could "automatically" fix the sources by doing something like

$ErrorActionPreference = "Stop"

$cfgLocation = (Join-Path $env:ChocolateyInstall "config/chocolatey.config")
if (-Not (Test-Path $cfgLocation)) {
  throw "no config found at $cfgLocation"
}

[xml]$cfgXML = Get-Content $cfgLocation

$sources = $cfgXML.chocolatey.sources
$sources.source | Sort-Object -Property priority | ForEach-Object { 
	$sources.AppendChild($_) | Out-Null
}

$cfgXML.Save($cfgLocation)

@pauby pauby added the Customer label Dec 7, 2018
@ferventcoder ferventcoder modified the milestones: 0.10.12, 0.10.13 Mar 9, 2019
@martinisoft1
Copy link

I am just getting into Chocolatey and bumped into this issue. After searching the net I found this report. Based on the info I found here I tried to work arround it by changing the Repo order in the chocolatey.config by removing the public Repo all together, adding my private repo's and then adding the public repo back again. As a result my private Repo's are positioned above the default chocolatey public repo in the chocolatey.config. I even gave my two private Repo's a priority of 1 and 2 and gave the public one a prio of 99. For some reason the Public repo still seems to take precedense over my privates. Am I doing something wrong or is this workarround not fixing the issue? Or could the fact that my privates are UNC based repo's have something to do with this? Thanks in advance..

@ferventcoder ferventcoder modified the milestones: 0.10.13, 0.10.14 Mar 15, 2019
@daveschafer
Copy link
Author

@martinisoft1 No, this workaround never worked for me (or anyone else?) either. The priority and the order of repos does not seem to have an impact, Choco Repo gets choosen any way.
This issue is still open and I hope that @ferventcoder takes a look at it sometime.

When I find the time I will take a look into the code.

@mwallner
Copy link
Member

mwallner commented Mar 19, 2019

@daveschafer I'm quite certain the workaround I've suggested above has been working for me in the past.
have you checked the contents of your chocolatey.config file?

edit: not so sure anymore..

  • just tried reproducing the above presented "solution", it looks as if the source priority is just being ignored, changing the order of the sources in chocolatey.config doesn't seem to have any effect.

@ferventcoder
Copy link
Member

@daveschafer @martinisoft1 @sudoturnkey currently the best way to handle this is to remove or disable the sources that don't apply.

@martinisoft1
Copy link

@daveschafer @martinisoft1 @sudoturnkey currently the best way to handle this is to remove or disable the sources that don't apply.

Well, the thing is that I do need the public repo for some standard applications. At the moment I am using a prefix for the packages in my private repo's to prevent duplicates, not ideal but good enough for now.

The thing that I find strange about the behavior is that I don't see why Choco would even know that it deals with its own Public repo. Even when I change the Prio, the Order and even the name (and yes I checked the chocolatey.config) the issue persist. One would think that in this case Choco would handle it as just an other Repo but in some way it seems to recognizie it as its Public Repo and give it the highest priority.

@ferventcoder
Copy link
Member

@martinisoft1 I don't think it is that. I think it is that it is checking all the repos instead of giving priority, I know it is in fact - I've seen the code in NuGet.Core that does this - it's a NuGet.Core code base bug.

@daveschafer
Copy link
Author

@ferventcoder Is this issue linked to this NuGet issues?

I took a look into the code and played around with some choco commands, I think a good workaround for this problem, which I verified, is the use of the --source parameter.

# list sources
choco source
chocolatey - https://chocolatey.org/api/v2/ | Priority 0|Bypass Proxy - False|Self-Service - False|Admin Only - False.
bob - http://1.1.1.1/api/v2 | Priority 0|Bypass Proxy - False|Self-Service - False|Admin Only - False.

-----

# to install a new package from YOUR source
choco install --source=bob packagexyz

#and to update only from YOUR repo
choco update --source=bob all/packagexyz

What does not work is when you install "package X" from your source and run a "choco update" without specifying a source. The source with the newest packages gets chosen, priority does not matter here.

So like in the NuGet issue mentioned, you would need like a 'source' or 'priority' tag for every choco package seperately, to distinguish from where it should get its updates, which is kinda overkill (but a possible solution).

@ferventcoder
Copy link
Member

I hate to have this roll another release, but we have some fixes that need to get out soon and this may be a big undertaking on its own. This is something we want to get fixed sooner than later though!

@ferventcoder ferventcoder modified the milestones: 0.10.14, 0.10.15 May 20, 2019
@gep13 gep13 modified the milestones: 0.10.15, 0.10.16 May 31, 2019
@daveschafer
Copy link
Author

Are there any news about this topic?

@jpylypiw
Copy link

Maybe this will help someone who has the same issue:
I have a local source on a UNC path which has the priority 1 and kept the default "chocolatey" source with priority 0. When I installed a package, the default chocolatey source was used.
The reason for me was, that the version of the package was higher on the default chocolatey source, than the version of my source. The solution was to specify the version of the package and everything worked fine.

Maybe there are other issues with your source. You can check this using this command:

choco list -s \\SOMEFILESVR\networkinstallation

@mike406
Copy link

mike406 commented Aug 6, 2020

Hello, is there any status update on this? In my organization we really need the ability to have priority respected properly. We have the following use case:

Computers on our internal network reach out to our hosted chocolatey source via our corporate proxy.
However due to COVID we have many people with laptops and VPN connections - the internal proxy does NOT work over our VPN and as such they cannot reach our hosted repo. Because we have the default chocolatey source disabled on all computers, the VPN laptops have no other source to pull from. If Chocolatey could follow source priority regardless of package version, we would be able to enable the default repo to allow laptops to reach out to the community repo while allowing internal workstations to still use our hosted repo.

@gep13 gep13 reopened this Oct 26, 2021
@gep13
Copy link
Member

gep13 commented Oct 26, 2021

There have been some performance related problems with the changes associated with this issue (choco outdated command taking much longer to run than normal), as such, we are going to back out the changes associated with this issue, and continue investigation on the problem.

@gep13 gep13 modified the milestones: 0.11.3, 0.11.x Oct 26, 2021
gep13 pushed a commit to gep13/choco that referenced this issue Oct 26, 2021
This commit re-adds the ability to order sources according to
a specified priority.
This ability seems to have been lost due to changes in the codebase in
the past and thus needed to be re-implemented when the repository optimization
is enabled.
gep13 added a commit to gep13/choco that referenced this issue Oct 26, 2021
This should have been included in the last commit where the associated
PR was merged in.
gep13 pushed a commit to gep13/choco that referenced this issue Oct 26, 2021
This commit updates the the acquiring of package from prioritized aggregate
repository to not add a package to the result list we iterate through
when a package could not be found.

This change was necessary in case an invalid identifier was used, or
the package exist but is only available on a disabled source.
@gep13 gep13 linked a pull request Oct 26, 2021 that will close this issue
7 tasks
gep13 added a commit that referenced this issue Oct 26, 2021
AdmiringWorm added a commit to gep13/choco that referenced this issue Nov 11, 2021
This commit updates the codebase to add support for ordering
sources according to priority for install, upgrade and outdated
command.
AdmiringWorm added a commit to gep13/choco that referenced this issue Nov 15, 2021
This commit updates the codebase to add support for ordering
sources according to priority for install, upgrade and outdated
command.
AdmiringWorm added a commit to gep13/choco that referenced this issue Nov 15, 2021
This commit updates the codebase to add support for ordering
sources according to priority for install, upgrade and outdated
command.
AdmiringWorm added a commit to gep13/choco that referenced this issue Nov 15, 2021
This commit updates the codebase to add support for ordering
sources according to priority for install, upgrade and outdated
command.
AdmiringWorm added a commit to gep13/choco that referenced this issue Mar 7, 2022
This commit updates the codebase to add support for ordering
sources according to priority for install, upgrade and outdated
command.
AdmiringWorm added a commit to gep13/choco that referenced this issue Mar 7, 2022
This commit updates the codebase to add support for ordering
sources according to priority for install, upgrade and outdated
command.
psi29a pushed a commit to OpenMW/openmw that referenced this issue May 3, 2022
This should work around chocolatey/choco#1541, which causes priority to be ignored and our proxy cache to be skipped
AdmiringWorm added a commit to AdmiringWorm/choco that referenced this issue Dec 15, 2022
This commit adds new tests for when we have support in
Chocolatey CLI in either the 1.x support branch or in
the develop vNext branch.

These tests are mostly ignored for now but can be easily
changed by updating the SourcePriorityAttribute in the
tinyspec file to inherit from a CategoryAttribute to make
these run.
AdmiringWorm added a commit to AdmiringWorm/choco that referenced this issue Dec 15, 2022
This commit updates the tests to be valid for the next
version of Chocolatey CLI
AdmiringWorm added a commit to AdmiringWorm/choco that referenced this issue Dec 15, 2022
This commit updates the tests to be valid for the next
version of Chocolatey CLI
AdmiringWorm added a commit to AdmiringWorm/choco that referenced this issue Dec 20, 2022
This commit adds new tests for when we have support in
Chocolatey CLI in either the 1.x support branch or in
the develop vNext branch.

These tests are mostly ignored for now but can be easily
changed by updating the SourcePriorityAttribute in the
tinyspec file to inherit from a CategoryAttribute to make
these run.
AdmiringWorm added a commit to AdmiringWorm/choco that referenced this issue Dec 20, 2022
This commit updates the tests to be valid for the next
version of Chocolatey CLI
gep13 added a commit that referenced this issue Dec 20, 2022
(#1541) Add tests for future implementation of source priority
@imm0rtalsupp0rt
Copy link

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