1

I would like to get chocolatey onto multiple systems. The normal way I do this is:

if (!(Test-Path "C:\ProgramData\chocolatey\bin")) {
    Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
}

That's fine, but this will connect to the internet, pointlessly re-downloading the Chocolatey package that I should be able to keep pre-downloaded, then extracting and setting up Chocolatey. This is like having to download a setup.exe every single time that you just want to install a program (for 20 systems, you would then have to download setup.exe 20 times), which slows things down and feels wasteful when I just want to get the choco.exe command available on systems as quickly as possible. I also don't mind if I have a slightly older version of chocolatey, I can redownload the main copy whenever I need.

It occurs to me that it should be easy to have the components pre-downloaded, so that I can just point at those files:

  • What files do we need to pre-download to have everything required to setup Chocolatey?
  • What command would we run against those files to set it up?

Note that this is quite a different question from How do you setup an offline Chocolatey instance?

4
  • 1
    Looks like they list all this here: docs.chocolatey.org/en-us/choco/… does that help? There is a full PowerShell script there with more than just the download part. Commented Nov 12, 2022 at 13:51
  • Thanks, good find, but sadly, that's not it from what I can see; looking through that code, it's still downloading the setup package from the internet as part of the install process, it seems more about deleting online sources after install? I do want the end result to be a normal chocolatey install that can access internet sources, I just don't want to have to download the chocolatey packages on each and every install, as it's wasteful / pointless. I want to do this on fresh VM's, and this downloading at every install is wasteful and slow when I could install more quickly from a local setup).
    – YorSubs
    Commented Nov 12, 2022 at 13:59
  • 1
    I gotcha, reading through the code is just trivial but it should have the install piece in it you might have to copy out and do testing with to get it. I'll read over it some more, but it download a zip file—which you can store offline/not across Internet/internal network. See docs.chocolatey.org/en-us/choco/… and community.chocolatey.org/api/v2/package/chocolatey for some more starting points. I don't have time to poke through it, but it should be possible. Not sure about prerequisites, check those too and automate those for offline install too. Commented Nov 12, 2022 at 15:56
  • 1
    I think there is something in there from the page you sent, though I have to try it out - this section lower down. I think that might work, have to test it. docs.chocolatey.org/en-us/choco/…
    – YorSubs
    Commented Nov 12, 2022 at 15:59

1 Answer 1

0

Installing Chocolatey offline is pretty simple, these days!

You'll need two files:

By default, the script downloads the latest version of Chocolatey from the Chocolatey Community Repository.

It's not clear from the parameter name, but you can provide a local file path to use with the -ChocolateyDownloadUrl parameter (or by setting $env:chocolateyDownloadUrl before running the script).

The command(s) to run to install from local files:

Set-ExecutionPolicy Bypass -Scope Process -Force
.\Install.ps1 -ChocolateyDownloadUrl ~\Path\To\Chocolatey.nupkg

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .