9

So, with my .travis.yml, I'm installing some packages via apt-get which doesn't take too long to download, but a very long time to install.

Is there a way to make Travis CI remember the installed packages, so I won't have to install them from scratch for every build?

finefoot
  • 9,914
  • 7
  • 59
  • 102

2 Answers2

7

There seems to be no easy or convenient way to cache all of the packages you need to install via apt-get. According to the Caching Dependencies and Directories documentation, Travis CI currently only provides "convenience" caching for Bundler, CocoaPods, Yarn (and a few others).

However! If you can determine where apt-get installs each of the packages you need (as install locations vary from one package to the next), you can cache each of those install directories individually by following the steps in the Arbitrary directories documentation.

I hope this helps. Please let me know if you have any other questions and I'd be happy to help in any way I can. Cheers!

Derek Hill
  • 5,965
  • 5
  • 55
  • 74
Luna G.
  • 146
  • 3
  • There is. I recommend reading through these forum posts: [After doing a sudo apt-get install , where does the application get stored to?](https://askubuntu.com/questions/408784/after-doing-a-sudo-apt-get-install-app-where-does-the-application-get-stored), [How do I get a list of installed files from a package?](https://askubuntu.com/questions/32507/how-do-i-get-a-list-of-installed-files-from-a-package) and [Where can I find the location of folders for installed programs?](https://askubuntu.com/questions/54395/where-can-i-find-the-location-of-folders-for-installed-programs). – Luna G. Dec 12 '17 at 19:00
  • In summary. (1) I would add `dpkg` commands in my `.travis.yml` file for each of the dependencies that I want to cache and echo the file paths. (2) Note down where each dependency is located by finding them in my Travis build logs. (2-b) I would also maybe repeat this process for a few builds to make sure install locations don't change. (3) Then I would remove the `dpkg` commands from my config file and add the file paths in the cache section following the [Arbitrary directories](https://docs.travis-ci.com/user/caching#Arbitrary-directories) documentation. And voila - that should work. – Luna G. Dec 12 '17 at 19:04
-5

If the packages you need are in Travis' whitelist, you can install them more simply by adding to your .travis.yml:

addons:
  apt:
    packages:
    - cmake
    - package-xy

And cache them with:

cache:
  apt: true
K3---rnc
  • 6,717
  • 3
  • 31
  • 46
  • 5
    That is false, as described in the travis documentation this does not cache the packages and is a misnomer https://github.com/travis-ci/travis-ci/issues/5876#issuecomment-207661127 – Léo Germond Nov 27 '18 at 17:15