RamblingCookieMonster / PSDepend

PowerShell Dependency Handler
MIT License
285 stars 76 forks source link

Importing modules makes requests to www.powershellgallery.com #51

Closed christianacca closed 6 years ago

christianacca commented 6 years ago

Consider the following requirements.psd1

@{ 
    PSDependOptions     = @{ Target = '$DependencyPath' } 
    '_LibraryTest1' = '1.0.0.3'
}

After running Invoke-PSDepend requirements.psd1 -Install, I see the single module _LibraryTest1 locally on the file system - great... but

Running Invoke-PSDepend requirements.psd1 -Import still results in 5 requests to www.powershellgallery.com

That is very unexpected and problematic:

Is there a reason why these requests to the gallery have to be made?

What code should be changed to remove the calls to psgallery (I had a little browse but couldn't pinpoint the spot)

Thanks Christian

christianacca commented 6 years ago

I have identified the problematic code.

I've implemented a solution (see PR https://github.com/RamblingCookieMonster/PSDepend/pull/52) so that Find-Module is called only when a dependency specifies 'latest' as it's required version.

Note...

This solution also applies to using Invoke-PSDepend -Install when a module(s) is already installed:

Previously, calls to a PS repository were always made. Now they're made only for those dependencies that specify 'latest' as their required version

RamblingCookieMonster commented 6 years ago

Merged #52 a while back, thanks again for the contribution!