How do I install Chocolatey packages offline?
Asked Answered
D

8

28

I am trying to automate to set up a developer machine software installation. Chocolatey is good to install packages when you connected to the Internet. Is there a way to install packages offline?

I just want to put all the packages in a shared network folder and use that packages to install. If you have an internal application, how do you convert them into a Chocolatey package?

Dyslogia answered 30/8, 2013 at 9:1 Comment(0)
T
10

Caching Downloads - Not Deterministic

While there are ways to set the original nupkg (with the version on it, not the one in the packages directory - use download from left side of packages page on the Chocolatey community package repository) and preset the downloaded binaries into the cache folder, it's not always deterministic that it will work. You can also override the cache location, so that the folder is somewhere not in TEMP. See choco config, choco config -h and choco config set cacheLocation c:\some\location to do this.

Create Your Own Packages - Better

For packages you need offline, you have the ability to manage your own packages and you can embed software right into the package. This is desired when you want to manage software offline as most things on the community repository are subject to copyright law and distribution rights (why they don't simply have the software they represent embedded).

Creating and working with your own packages is very secure, but it does tend to take up time. If you are doing this for yourself, then it could override any time-savings you get as a consumer using Chocolatey and the community repository.

For organizations, we've developed Package Builder, which creates full software deployments (packages) in 5-10 seconds. It can also create packages right out of existing installed software (Programs and Features) in under 60 seconds! Read more about Package Builder.

Internalized Packages - Best

The best thing you can do here is a process called internalizing, where you download and extract the package, download all of the resources and embed them in the package (or put them somewhere local), edit the scripts to use those embedded/local resources and recompile the package.

This allows you to take advantage of existing package logic without the issue of the internet.

For more details see Manually Internalizing Packages and Package Internalizer - Automatically Internalize Packages.

Organization Use of Chocolatey

Most organizations using Chocolatey are doing some combination of creating packages and internalizing packages, because they need reliability and absolute trust and control over those packages when being used in production scenarios.

Tripoli answered 3/9, 2013 at 15:35 Comment(1)
The good thread : groups.google.com/forum/#!msg/chocolatey/stHHzK-mzMY/…Iconoclasm
C
5

I've created a project named ChocolateStore that automates the process of copying a Chocolatey package from an online source and making the package available for offline use.

You can view the source here: https://github.com/BahKoo/ChocolateStore

Convalescence answered 9/12, 2014 at 16:52 Comment(0)
M
1

Chocolatey’s documentation may answer the first part of the question with this: "How To Host Your Own [Private/Internal/Public] Package Repository Server (aka Package Feed)"

It explains three types of package repositories which enable you to provide packages in your LAN/intranet or through shared volumes:

  1. Folder/UNC share
  2. Simple server
  3. Package gallery

The second part of the question could be answered with Chocolatey’s documentation about recompiling packages. The title sounds more complicated than it really is and could just have been "How to make an existing package local", and I think what is described there can be applied to what the question’s author calls "internal applications" (I guess he means programs aka .exe files which are not available on any public feed), too.

Mooneyham answered 12/8, 2016 at 17:25 Comment(0)
L
1

So, I have created a Nullsoft installer that needed to install Chocolatey packages from an offline computer. These are the overall steps:

  1. Download the Chocolatey packages to a temporary directory with:

    NuGet.exe Install some_package_name -OutputDirectory C:\Temp\ChocoPackages -ExcludeVersion
    
  2. In the Nullsoft script, add these lines to pick up the download packages:

    nsExec::Exec 'choco feature disable -n=allowGlobalConfirmation'
    

    SetOutPath "${TmpPath}ChocoPackages" File /r "C:\Temp\ChocoPackages*.*"

  3. While still in the Nullsoft script, use this command to install a Chocolatey package from the temporary directory that the files were placed at during the install process:

    choco install --Source "${TmpPath}ChocoPackages" ${Name_Of_ChocoPackage} --acceptlicense --yes
    
Lixiviate answered 6/1, 2017 at 19:9 Comment(0)
B
0

Nifty. That's exactly what I'm doing currently!

For what it's worth, to install from a network shared folder, I'm using:

choco upgrade eclipse -y -s \\network\users\KyleStoflet\Eclipse

For example, here I'm upgrading Eclipse, and I'll explain the line a bit more:

-y skips the confirmation

-s provides the source path

network and users are placeholders for our network, and user directories

... and for test purposes, I've got our versions in my directory. Inside that directory there are multiple directories for Eclipse, Visual Studio, and other various software that we use for development.

An important note: I've only gotten this working for the .nupkg files that were retrieved directly from the Chocolatey packages page. I didn't end up finding a fix for executables.

Bartolome answered 27/6, 2016 at 23:6 Comment(0)
G
0

Put the installer in the cache directory:

%TEMP%\chocolatey\<pkg>\<version>

And do a force install:

choco install -f <package_name>

It worked fine on my version (v0.9.10.3).

Golden answered 25/7, 2016 at 4:5 Comment(1)
Of course you can override the cache location - see choco config and choco config set cacheLocation c:\somewhereTripoli
T
0

Chocolatey uses $env:TEMP as a cache directory and the download file put at

$env:Temp\chocolatey\Firefox\60.0.2\FirefoxInstall.exe

60.0.2 is the package version, and Firefox is the package name.

Tetralogy answered 25/6, 2018 at 4:51 Comment(0)
C
0

A.How to install chocolatey package offline with chocolatey

  1. Download the chocolatey NuPackage from chocolatey website. https://chocolatey.org/api/v2/package/chocolatey

  2. Put it in a local file repository, example: D:\chocoOfflineRepository

  3. choco source add -n=chocoOfflineControl -s="file:///d:/chocoOfflineRepository/"

  4. choco install -f package

Optional: In my case, I also set the cache folder to my external D drive, instead of a Temp folder on my admin user account.

  1. choco config set cacheLocation D:\chocoOfflineRepository

B. How to install chocolatey offline

Also, assuming your already have chocolatey installed, But, just in case

  1. Read this: https://docs.chocolatey.org/en-us/choco/setup#completely-offline-install
  2. Download chocolatey Nupackage file and put in local file repository
  3. Copy suggested .ps1 scripts.
  4. Modify package url source for local source
$packageRepo = 'file:///d:/chocoOfflineRepository/chocolatey.0.10.15.nupkg'
  1. Modify search url for simpler
$searchUrl = $packageRepo.Trim('/')#($packageRepo.Trim('/'), 'Packages()?$filter=(Id%20eq%20%27chocolatey%27)%20and%20IsLatestVersion') -join '/'
  1. Run the chocoofflline ps1 script.

Debug: If you have an error here: Download-Package $searchUrl $localChocolateyPackageFilePath

  1. Manually download the file instead and comment out Download-Package line, so do

cp d:/chocoOfflineRepository/chocolatey.0.10.15.nupkg C:\ProgramData\choco-cache\chocolatey.nupkg

  1. Then run this line or entire ps1 script again
  Install-ChocolateyFromPackage $localChocolateyPackageFilePath

Note like @ferventcoder pointed out, it's not deterministic, some package may not work because of internal dependencies or proxy limitation. In my case I couldn't use remote community library because of corporate proxy, so I'm using this until I figure out a better solution. =)

Confutation answered 20/4, 2021 at 15:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.