Cache Brew builds with travis ci
I have a Travis CI osx
build with a brew
dependency that has to be built from source.
I know that Travis has the cache
feature, but it doesn't have any documentation on how to cache brew
builds or outputs.
Any idea on how to cache a brew
package in travis?
macos homebrew travis-ci
add a comment |
I have a Travis CI osx
build with a brew
dependency that has to be built from source.
I know that Travis has the cache
feature, but it doesn't have any documentation on how to cache brew
builds or outputs.
Any idea on how to cache a brew
package in travis?
macos homebrew travis-ci
Do you need to cache an existing bottle, a package/bottle that you yourself built, or brew package metadata? These are all completely different things.
– ivan_pozdeev
Nov 5 '18 at 7:23
add a comment |
I have a Travis CI osx
build with a brew
dependency that has to be built from source.
I know that Travis has the cache
feature, but it doesn't have any documentation on how to cache brew
builds or outputs.
Any idea on how to cache a brew
package in travis?
macos homebrew travis-ci
I have a Travis CI osx
build with a brew
dependency that has to be built from source.
I know that Travis has the cache
feature, but it doesn't have any documentation on how to cache brew
builds or outputs.
Any idea on how to cache a brew
package in travis?
macos homebrew travis-ci
macos homebrew travis-ci
asked Oct 8 '16 at 8:06
StephenGStephenG
1,763930
1,763930
Do you need to cache an existing bottle, a package/bottle that you yourself built, or brew package metadata? These are all completely different things.
– ivan_pozdeev
Nov 5 '18 at 7:23
add a comment |
Do you need to cache an existing bottle, a package/bottle that you yourself built, or brew package metadata? These are all completely different things.
– ivan_pozdeev
Nov 5 '18 at 7:23
Do you need to cache an existing bottle, a package/bottle that you yourself built, or brew package metadata? These are all completely different things.
– ivan_pozdeev
Nov 5 '18 at 7:23
Do you need to cache an existing bottle, a package/bottle that you yourself built, or brew package metadata? These are all completely different things.
– ivan_pozdeev
Nov 5 '18 at 7:23
add a comment |
5 Answers
5
active
oldest
votes
There are 3 separate, loosely related problems here:
- Cache downloaded bottles
- Cache locally-built bottles
- Cache Homebrew metadata
You don't necessarily need all three, so follow whichever sections fit your needs.
Cache downloaded bottles
Add
$HOME/Library/Caches/Homebrew
to Travis' cache (actually, this path is supposed to be retrieved withbrew --cache
but you can't call it here, can you)
cache:
directories:
- $HOME/Library/Caches/Homebrew
Run
brew cleanup
atbefore_cache
stage -- otherwise, the cache will grow indefinitely as new package versions are released
before_cache:
- brew cleanup
Cache locally-built bottles
The full code is too long to list it here, so giving the algorithm.
This is in addition to the previous section. If using without it, save local bottles somewhere outside of Homebrew cache at on installing step and add them to the cache under appropriate names at the at startup step below.
On installing:
- Check package's dependencies with
brew deps
recursively
- If a bottle for the package is not available for your environment (no
(bottled)
inbrew info <pkg>
output), include build dependencies with--include-build
- If a bottle for the package is not available for your environment (no
For each of the packages and dependencies,
- If it's already installed (
brew list --versions <pkg>
succeeds) and latest version (absent frombrew outdated
), skip it - If an older version is present, in the following steps, you'll need to install the new version alongside the old one:
brew unlink
the old version if it's not keg-only (no[keg-only]
inbrew info
output)- Invoke all
brew install
's with--force
- If a bottle is available, just
brew install
it
If a bottle is not available,
Build and install it with the following sequence:
brew install --build-bottle <pkg>
brew bottle --json <pkg>
brew uninstall --ignore-dependencies <pkg>
brew install <bottle>
(There doesn't seem to be any official way to get the names of the resulting bottle and JSON file. I took the bottle name from
brew bottle
output and inferred JSON file name from it.)
Add the bottle info into the package's formula
brew bottle --merge --write <json file>
Save the bottle file into Travis cache under an appropriate name given by
brew --cache <pkg>
- Only do this after adding bottle info -- otherwise, you'll get a path to the source package instead.
- (Homebrew also makes symlinks to downloaded files in
$HOME/Library/Caches/Homebrew
. You don't need to do this.)
- Save the JSON file for later use. Make sure to add its location to Travis cache.
- If it's already installed (
- Check package's dependencies with
At startup:
- Do
brew update
if you're going to - Go through saved .json files. For each one, check if the local bottle is still appropriate (by comparing versions and rebuild numbers; you can parse the output of
brew info --json=v1 <pkg>
andbrew info --json=v1 <bottle>
for this data).
- Delete the cached bottle and the .json if not
- Since you won't be able to get the path to your bottle with
brew --cache
at this point, you need to have saved it independently. Symlinks aren't being saved in Travis' cache as of this writing, so I ended up using regular files that held the paths.
- Since you won't be able to get the path to your bottle with
- Re-add the bottle info into the formula like above if yes
- There's also an unlikely possibility that they change the download URL in the formula without bumping the version -- then the bottle's expected cached name will change because the hash in it is the hash of the download URL. To allow for this, check if
brew --cache <pkg>
still points to your bottle after adding the info.
- There's also an unlikely possibility that they change the download URL in the formula without bumping the version -- then the bottle's expected cached name will change because the hash in it is the hash of the download URL. To allow for this, check if
- Delete the cached bottle and the .json if not
- Do
At
before_cache
:
- If you're using
brew cleanup
from the previous section, save your locally-built bottle files from cache somewhere before running it becausecleanup
may delete those that weren't needed this time around. Aftercleanup
, restore those that were deleted.
- If you're using
Cache Homebrew metadata
If you run brew update --verbose
(and make sure there are no secret variables in .travis.yml
or your Travis project settings -- brew
prints many status messages only if stdout
is a tty) -- you'll see what exactly consititutes a Homebrew selfupdate operation -- thus what you should cache:
- Pulling (actually,
rebase
'ing by default) into a few paths that are actuallygit
repositories:
/usr/local/Homebrew
-- Homebrew itself
/usr/local/Homebrew/Library/Taps/*/*
-- installed taps
- Going through the taps and cache and migrating obsolete bits. Since Travis cache content is added to existing directory structure rather than replaces it, the 2nd time around, there may be strange actions and errors caused by files that were deleted as part of update, but are there again in the new VM. The ones I witnessed:
- will always try migrating
Taps/caskroom/homebrew-cask
toTaps/homebrew/homebrew-cask
, creating a copy atTaps/homebrew/homebrew-cask/homebrew-cask
. If cached, this copy will cause an "error: file exists" on the next run. - will always try to import lots of non-committed files into
Taps/homebrew/homebrew-versions
- will always try migrating
So, the actions will be:
Add
/usr/local/Homebrew
to Travis cache
- adding /usr/local/Cellar and /usr/local/opt proved to be a bad idea: first, they are too large, causing a timeout while making and uploading cache; second, this is unsafe 'cuz
postinstall
scripts may affect other arbitrary parts of the system, so one should install new package versions from (cached) bottles each time rather than cache the result. Installing a bottle only takes several seconds anyway.
- adding /usr/local/Cellar and /usr/local/opt proved to be a bad idea: first, they are too large, causing a timeout while making and uploading cache; second, this is unsafe 'cuz
Before
brew update
: clean up Homebrew codebase
- Delete the
Taps/caskroom/homebrew-cask
dir ifTaps/homebrew/homebrew-cask
exists - Find all
git
repos under/usr/local/Homebrew
(find -type d -name .git
, getdirname
of the result) and rungit clean -fxd
in each to get rid of Travis' leftovers - Clean up Homebrew cache from leftovers, too, with
brew cleanup
(if using in conjunction with the previous section, see there for additional operations) -- otherwise, you'll get lots of errors inbrew update
on the "Migrating cache entries..." stage.
- Delete the
At
brew update
:
- Use
brew update --merge
instead -- it will auto-resolve any possible conflicts with your local commits with bottle info
- Use
When re-adding local bottles (if using in conjunction with the previous section):
- Don't re-add bottle info into the formula if it's already present there
- If package version has changed and your bottle info is present in the formula, remove it from the formula and
git commit
the result. There's no stock way to do that, so you'll have to parse and edit the formula file with a script and delete the corresponsing line frombottle do
table. The path to the formula file is retrieved withbrew formula <pkg>
.
When installing:
If using 3rd-party taps, always check if you already have that tap installed:
brew tap | grep -qxF <tap> || brew tap <tap>
Since symlinks aren't saved in Travis cache, pins will likely not be remembered. But it won't hurt to check for them, too:
brew tap --list-pinned | grep -qxF <tap> || brew tap-pin <tap>
At
before_cache
:
- Delete
Taps/homebrew/homebrew-cask/homebrew-cask
if it exists
- Delete
add a comment |
You can add brew cache directory to travis caches:
cache:
directories:
- $HOME/Library/Caches/Homebrew
As far as I know travis doesn't support homebrew caching out of the box.
1
This caches Homebrew resources (the downloads), not the completed builds (binaries, etc). Still super helpful!
– StephenG
May 8 '17 at 18:04
add a comment |
To cache the actual compiled dependencies as opposed to caching the source tarballs or ccaching object files, adding the respective packages' Cellar
and opt
directories to the cache and using an appropriate before_install check seems to work fine.
You could also add all of /usr/local/Cellar/
and /usr/local/opt/
, but that would add all installed homebrew packages instead of only the ones you need.
Example from a project that depends on openssl, libevent and check:
cache:
directories:
- /usr/local/Cellar/openssl
- /usr/local/opt/openssl
- /usr/local/Cellar/libevent
- /usr/local/opt/libevent
- /usr/local/Cellar/check
- /usr/local/opt/check
before_install:
- test -d /usr/local/opt/openssl/lib || { rmdir /usr/local/opt/openssl; brew install openssl; }
- test -d /usr/local/opt/libevent/lib || { rmdir /usr/local/opt/libevent; brew install libevent; }
- test -d /usr/local/opt/check/lib || { rmdir /usr/local/opt/check; brew install check; }
The rmdir
is needed because TravisCI creates the cached directories if they don't exist, and brew install
fails if /usr/local/opt/$package
is a directory (as opposed to a symlink to a specific installed version in Cellar). For the same reason, test
tests for a subdirectory, not the main package directory.
Note that this approach requires your own project to be able to pick up the dependencies installed in /usr/local/opt
.
add a comment |
Homebrew allows you to build from source:
brew install --build-from-source [package-name]
If you want to cache your homebrew for Travis, the only way I have seen how to do this is to create a zipped version of the homebrew dependencies you want similar to this example, travis.yml
1
I don't understand how this helps with travis caching. Where did brew save to in travis? How to I save and restore the cache?
– StephenG
Oct 8 '16 at 14:56
Misunderstood your question, edited
– Wade Williams
Oct 8 '16 at 15:18
add a comment |
The following should cache the compiler results:
cache:
ccache: true
directories:
- $HOME/Library/Caches/Homebrew
On OSX Travis currently seems not to ship ccache by default => Before using ccache the following has to be done, as well:
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache; fi
Admittedly the completed build still is not cached. But the build results of every individual timer run that leads there are so at least big parts of the build process can count as "cached" afterwards.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39930171%2fcache-brew-builds-with-travis-ci%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are 3 separate, loosely related problems here:
- Cache downloaded bottles
- Cache locally-built bottles
- Cache Homebrew metadata
You don't necessarily need all three, so follow whichever sections fit your needs.
Cache downloaded bottles
Add
$HOME/Library/Caches/Homebrew
to Travis' cache (actually, this path is supposed to be retrieved withbrew --cache
but you can't call it here, can you)
cache:
directories:
- $HOME/Library/Caches/Homebrew
Run
brew cleanup
atbefore_cache
stage -- otherwise, the cache will grow indefinitely as new package versions are released
before_cache:
- brew cleanup
Cache locally-built bottles
The full code is too long to list it here, so giving the algorithm.
This is in addition to the previous section. If using without it, save local bottles somewhere outside of Homebrew cache at on installing step and add them to the cache under appropriate names at the at startup step below.
On installing:
- Check package's dependencies with
brew deps
recursively
- If a bottle for the package is not available for your environment (no
(bottled)
inbrew info <pkg>
output), include build dependencies with--include-build
- If a bottle for the package is not available for your environment (no
For each of the packages and dependencies,
- If it's already installed (
brew list --versions <pkg>
succeeds) and latest version (absent frombrew outdated
), skip it - If an older version is present, in the following steps, you'll need to install the new version alongside the old one:
brew unlink
the old version if it's not keg-only (no[keg-only]
inbrew info
output)- Invoke all
brew install
's with--force
- If a bottle is available, just
brew install
it
If a bottle is not available,
Build and install it with the following sequence:
brew install --build-bottle <pkg>
brew bottle --json <pkg>
brew uninstall --ignore-dependencies <pkg>
brew install <bottle>
(There doesn't seem to be any official way to get the names of the resulting bottle and JSON file. I took the bottle name from
brew bottle
output and inferred JSON file name from it.)
Add the bottle info into the package's formula
brew bottle --merge --write <json file>
Save the bottle file into Travis cache under an appropriate name given by
brew --cache <pkg>
- Only do this after adding bottle info -- otherwise, you'll get a path to the source package instead.
- (Homebrew also makes symlinks to downloaded files in
$HOME/Library/Caches/Homebrew
. You don't need to do this.)
- Save the JSON file for later use. Make sure to add its location to Travis cache.
- If it's already installed (
- Check package's dependencies with
At startup:
- Do
brew update
if you're going to - Go through saved .json files. For each one, check if the local bottle is still appropriate (by comparing versions and rebuild numbers; you can parse the output of
brew info --json=v1 <pkg>
andbrew info --json=v1 <bottle>
for this data).
- Delete the cached bottle and the .json if not
- Since you won't be able to get the path to your bottle with
brew --cache
at this point, you need to have saved it independently. Symlinks aren't being saved in Travis' cache as of this writing, so I ended up using regular files that held the paths.
- Since you won't be able to get the path to your bottle with
- Re-add the bottle info into the formula like above if yes
- There's also an unlikely possibility that they change the download URL in the formula without bumping the version -- then the bottle's expected cached name will change because the hash in it is the hash of the download URL. To allow for this, check if
brew --cache <pkg>
still points to your bottle after adding the info.
- There's also an unlikely possibility that they change the download URL in the formula without bumping the version -- then the bottle's expected cached name will change because the hash in it is the hash of the download URL. To allow for this, check if
- Delete the cached bottle and the .json if not
- Do
At
before_cache
:
- If you're using
brew cleanup
from the previous section, save your locally-built bottle files from cache somewhere before running it becausecleanup
may delete those that weren't needed this time around. Aftercleanup
, restore those that were deleted.
- If you're using
Cache Homebrew metadata
If you run brew update --verbose
(and make sure there are no secret variables in .travis.yml
or your Travis project settings -- brew
prints many status messages only if stdout
is a tty) -- you'll see what exactly consititutes a Homebrew selfupdate operation -- thus what you should cache:
- Pulling (actually,
rebase
'ing by default) into a few paths that are actuallygit
repositories:
/usr/local/Homebrew
-- Homebrew itself
/usr/local/Homebrew/Library/Taps/*/*
-- installed taps
- Going through the taps and cache and migrating obsolete bits. Since Travis cache content is added to existing directory structure rather than replaces it, the 2nd time around, there may be strange actions and errors caused by files that were deleted as part of update, but are there again in the new VM. The ones I witnessed:
- will always try migrating
Taps/caskroom/homebrew-cask
toTaps/homebrew/homebrew-cask
, creating a copy atTaps/homebrew/homebrew-cask/homebrew-cask
. If cached, this copy will cause an "error: file exists" on the next run. - will always try to import lots of non-committed files into
Taps/homebrew/homebrew-versions
- will always try migrating
So, the actions will be:
Add
/usr/local/Homebrew
to Travis cache
- adding /usr/local/Cellar and /usr/local/opt proved to be a bad idea: first, they are too large, causing a timeout while making and uploading cache; second, this is unsafe 'cuz
postinstall
scripts may affect other arbitrary parts of the system, so one should install new package versions from (cached) bottles each time rather than cache the result. Installing a bottle only takes several seconds anyway.
- adding /usr/local/Cellar and /usr/local/opt proved to be a bad idea: first, they are too large, causing a timeout while making and uploading cache; second, this is unsafe 'cuz
Before
brew update
: clean up Homebrew codebase
- Delete the
Taps/caskroom/homebrew-cask
dir ifTaps/homebrew/homebrew-cask
exists - Find all
git
repos under/usr/local/Homebrew
(find -type d -name .git
, getdirname
of the result) and rungit clean -fxd
in each to get rid of Travis' leftovers - Clean up Homebrew cache from leftovers, too, with
brew cleanup
(if using in conjunction with the previous section, see there for additional operations) -- otherwise, you'll get lots of errors inbrew update
on the "Migrating cache entries..." stage.
- Delete the
At
brew update
:
- Use
brew update --merge
instead -- it will auto-resolve any possible conflicts with your local commits with bottle info
- Use
When re-adding local bottles (if using in conjunction with the previous section):
- Don't re-add bottle info into the formula if it's already present there
- If package version has changed and your bottle info is present in the formula, remove it from the formula and
git commit
the result. There's no stock way to do that, so you'll have to parse and edit the formula file with a script and delete the corresponsing line frombottle do
table. The path to the formula file is retrieved withbrew formula <pkg>
.
When installing:
If using 3rd-party taps, always check if you already have that tap installed:
brew tap | grep -qxF <tap> || brew tap <tap>
Since symlinks aren't saved in Travis cache, pins will likely not be remembered. But it won't hurt to check for them, too:
brew tap --list-pinned | grep -qxF <tap> || brew tap-pin <tap>
At
before_cache
:
- Delete
Taps/homebrew/homebrew-cask/homebrew-cask
if it exists
- Delete
add a comment |
There are 3 separate, loosely related problems here:
- Cache downloaded bottles
- Cache locally-built bottles
- Cache Homebrew metadata
You don't necessarily need all three, so follow whichever sections fit your needs.
Cache downloaded bottles
Add
$HOME/Library/Caches/Homebrew
to Travis' cache (actually, this path is supposed to be retrieved withbrew --cache
but you can't call it here, can you)
cache:
directories:
- $HOME/Library/Caches/Homebrew
Run
brew cleanup
atbefore_cache
stage -- otherwise, the cache will grow indefinitely as new package versions are released
before_cache:
- brew cleanup
Cache locally-built bottles
The full code is too long to list it here, so giving the algorithm.
This is in addition to the previous section. If using without it, save local bottles somewhere outside of Homebrew cache at on installing step and add them to the cache under appropriate names at the at startup step below.
On installing:
- Check package's dependencies with
brew deps
recursively
- If a bottle for the package is not available for your environment (no
(bottled)
inbrew info <pkg>
output), include build dependencies with--include-build
- If a bottle for the package is not available for your environment (no
For each of the packages and dependencies,
- If it's already installed (
brew list --versions <pkg>
succeeds) and latest version (absent frombrew outdated
), skip it - If an older version is present, in the following steps, you'll need to install the new version alongside the old one:
brew unlink
the old version if it's not keg-only (no[keg-only]
inbrew info
output)- Invoke all
brew install
's with--force
- If a bottle is available, just
brew install
it
If a bottle is not available,
Build and install it with the following sequence:
brew install --build-bottle <pkg>
brew bottle --json <pkg>
brew uninstall --ignore-dependencies <pkg>
brew install <bottle>
(There doesn't seem to be any official way to get the names of the resulting bottle and JSON file. I took the bottle name from
brew bottle
output and inferred JSON file name from it.)
Add the bottle info into the package's formula
brew bottle --merge --write <json file>
Save the bottle file into Travis cache under an appropriate name given by
brew --cache <pkg>
- Only do this after adding bottle info -- otherwise, you'll get a path to the source package instead.
- (Homebrew also makes symlinks to downloaded files in
$HOME/Library/Caches/Homebrew
. You don't need to do this.)
- Save the JSON file for later use. Make sure to add its location to Travis cache.
- If it's already installed (
- Check package's dependencies with
At startup:
- Do
brew update
if you're going to - Go through saved .json files. For each one, check if the local bottle is still appropriate (by comparing versions and rebuild numbers; you can parse the output of
brew info --json=v1 <pkg>
andbrew info --json=v1 <bottle>
for this data).
- Delete the cached bottle and the .json if not
- Since you won't be able to get the path to your bottle with
brew --cache
at this point, you need to have saved it independently. Symlinks aren't being saved in Travis' cache as of this writing, so I ended up using regular files that held the paths.
- Since you won't be able to get the path to your bottle with
- Re-add the bottle info into the formula like above if yes
- There's also an unlikely possibility that they change the download URL in the formula without bumping the version -- then the bottle's expected cached name will change because the hash in it is the hash of the download URL. To allow for this, check if
brew --cache <pkg>
still points to your bottle after adding the info.
- There's also an unlikely possibility that they change the download URL in the formula without bumping the version -- then the bottle's expected cached name will change because the hash in it is the hash of the download URL. To allow for this, check if
- Delete the cached bottle and the .json if not
- Do
At
before_cache
:
- If you're using
brew cleanup
from the previous section, save your locally-built bottle files from cache somewhere before running it becausecleanup
may delete those that weren't needed this time around. Aftercleanup
, restore those that were deleted.
- If you're using
Cache Homebrew metadata
If you run brew update --verbose
(and make sure there are no secret variables in .travis.yml
or your Travis project settings -- brew
prints many status messages only if stdout
is a tty) -- you'll see what exactly consititutes a Homebrew selfupdate operation -- thus what you should cache:
- Pulling (actually,
rebase
'ing by default) into a few paths that are actuallygit
repositories:
/usr/local/Homebrew
-- Homebrew itself
/usr/local/Homebrew/Library/Taps/*/*
-- installed taps
- Going through the taps and cache and migrating obsolete bits. Since Travis cache content is added to existing directory structure rather than replaces it, the 2nd time around, there may be strange actions and errors caused by files that were deleted as part of update, but are there again in the new VM. The ones I witnessed:
- will always try migrating
Taps/caskroom/homebrew-cask
toTaps/homebrew/homebrew-cask
, creating a copy atTaps/homebrew/homebrew-cask/homebrew-cask
. If cached, this copy will cause an "error: file exists" on the next run. - will always try to import lots of non-committed files into
Taps/homebrew/homebrew-versions
- will always try migrating
So, the actions will be:
Add
/usr/local/Homebrew
to Travis cache
- adding /usr/local/Cellar and /usr/local/opt proved to be a bad idea: first, they are too large, causing a timeout while making and uploading cache; second, this is unsafe 'cuz
postinstall
scripts may affect other arbitrary parts of the system, so one should install new package versions from (cached) bottles each time rather than cache the result. Installing a bottle only takes several seconds anyway.
- adding /usr/local/Cellar and /usr/local/opt proved to be a bad idea: first, they are too large, causing a timeout while making and uploading cache; second, this is unsafe 'cuz
Before
brew update
: clean up Homebrew codebase
- Delete the
Taps/caskroom/homebrew-cask
dir ifTaps/homebrew/homebrew-cask
exists - Find all
git
repos under/usr/local/Homebrew
(find -type d -name .git
, getdirname
of the result) and rungit clean -fxd
in each to get rid of Travis' leftovers - Clean up Homebrew cache from leftovers, too, with
brew cleanup
(if using in conjunction with the previous section, see there for additional operations) -- otherwise, you'll get lots of errors inbrew update
on the "Migrating cache entries..." stage.
- Delete the
At
brew update
:
- Use
brew update --merge
instead -- it will auto-resolve any possible conflicts with your local commits with bottle info
- Use
When re-adding local bottles (if using in conjunction with the previous section):
- Don't re-add bottle info into the formula if it's already present there
- If package version has changed and your bottle info is present in the formula, remove it from the formula and
git commit
the result. There's no stock way to do that, so you'll have to parse and edit the formula file with a script and delete the corresponsing line frombottle do
table. The path to the formula file is retrieved withbrew formula <pkg>
.
When installing:
If using 3rd-party taps, always check if you already have that tap installed:
brew tap | grep -qxF <tap> || brew tap <tap>
Since symlinks aren't saved in Travis cache, pins will likely not be remembered. But it won't hurt to check for them, too:
brew tap --list-pinned | grep -qxF <tap> || brew tap-pin <tap>
At
before_cache
:
- Delete
Taps/homebrew/homebrew-cask/homebrew-cask
if it exists
- Delete
add a comment |
There are 3 separate, loosely related problems here:
- Cache downloaded bottles
- Cache locally-built bottles
- Cache Homebrew metadata
You don't necessarily need all three, so follow whichever sections fit your needs.
Cache downloaded bottles
Add
$HOME/Library/Caches/Homebrew
to Travis' cache (actually, this path is supposed to be retrieved withbrew --cache
but you can't call it here, can you)
cache:
directories:
- $HOME/Library/Caches/Homebrew
Run
brew cleanup
atbefore_cache
stage -- otherwise, the cache will grow indefinitely as new package versions are released
before_cache:
- brew cleanup
Cache locally-built bottles
The full code is too long to list it here, so giving the algorithm.
This is in addition to the previous section. If using without it, save local bottles somewhere outside of Homebrew cache at on installing step and add them to the cache under appropriate names at the at startup step below.
On installing:
- Check package's dependencies with
brew deps
recursively
- If a bottle for the package is not available for your environment (no
(bottled)
inbrew info <pkg>
output), include build dependencies with--include-build
- If a bottle for the package is not available for your environment (no
For each of the packages and dependencies,
- If it's already installed (
brew list --versions <pkg>
succeeds) and latest version (absent frombrew outdated
), skip it - If an older version is present, in the following steps, you'll need to install the new version alongside the old one:
brew unlink
the old version if it's not keg-only (no[keg-only]
inbrew info
output)- Invoke all
brew install
's with--force
- If a bottle is available, just
brew install
it
If a bottle is not available,
Build and install it with the following sequence:
brew install --build-bottle <pkg>
brew bottle --json <pkg>
brew uninstall --ignore-dependencies <pkg>
brew install <bottle>
(There doesn't seem to be any official way to get the names of the resulting bottle and JSON file. I took the bottle name from
brew bottle
output and inferred JSON file name from it.)
Add the bottle info into the package's formula
brew bottle --merge --write <json file>
Save the bottle file into Travis cache under an appropriate name given by
brew --cache <pkg>
- Only do this after adding bottle info -- otherwise, you'll get a path to the source package instead.
- (Homebrew also makes symlinks to downloaded files in
$HOME/Library/Caches/Homebrew
. You don't need to do this.)
- Save the JSON file for later use. Make sure to add its location to Travis cache.
- If it's already installed (
- Check package's dependencies with
At startup:
- Do
brew update
if you're going to - Go through saved .json files. For each one, check if the local bottle is still appropriate (by comparing versions and rebuild numbers; you can parse the output of
brew info --json=v1 <pkg>
andbrew info --json=v1 <bottle>
for this data).
- Delete the cached bottle and the .json if not
- Since you won't be able to get the path to your bottle with
brew --cache
at this point, you need to have saved it independently. Symlinks aren't being saved in Travis' cache as of this writing, so I ended up using regular files that held the paths.
- Since you won't be able to get the path to your bottle with
- Re-add the bottle info into the formula like above if yes
- There's also an unlikely possibility that they change the download URL in the formula without bumping the version -- then the bottle's expected cached name will change because the hash in it is the hash of the download URL. To allow for this, check if
brew --cache <pkg>
still points to your bottle after adding the info.
- There's also an unlikely possibility that they change the download URL in the formula without bumping the version -- then the bottle's expected cached name will change because the hash in it is the hash of the download URL. To allow for this, check if
- Delete the cached bottle and the .json if not
- Do
At
before_cache
:
- If you're using
brew cleanup
from the previous section, save your locally-built bottle files from cache somewhere before running it becausecleanup
may delete those that weren't needed this time around. Aftercleanup
, restore those that were deleted.
- If you're using
Cache Homebrew metadata
If you run brew update --verbose
(and make sure there are no secret variables in .travis.yml
or your Travis project settings -- brew
prints many status messages only if stdout
is a tty) -- you'll see what exactly consititutes a Homebrew selfupdate operation -- thus what you should cache:
- Pulling (actually,
rebase
'ing by default) into a few paths that are actuallygit
repositories:
/usr/local/Homebrew
-- Homebrew itself
/usr/local/Homebrew/Library/Taps/*/*
-- installed taps
- Going through the taps and cache and migrating obsolete bits. Since Travis cache content is added to existing directory structure rather than replaces it, the 2nd time around, there may be strange actions and errors caused by files that were deleted as part of update, but are there again in the new VM. The ones I witnessed:
- will always try migrating
Taps/caskroom/homebrew-cask
toTaps/homebrew/homebrew-cask
, creating a copy atTaps/homebrew/homebrew-cask/homebrew-cask
. If cached, this copy will cause an "error: file exists" on the next run. - will always try to import lots of non-committed files into
Taps/homebrew/homebrew-versions
- will always try migrating
So, the actions will be:
Add
/usr/local/Homebrew
to Travis cache
- adding /usr/local/Cellar and /usr/local/opt proved to be a bad idea: first, they are too large, causing a timeout while making and uploading cache; second, this is unsafe 'cuz
postinstall
scripts may affect other arbitrary parts of the system, so one should install new package versions from (cached) bottles each time rather than cache the result. Installing a bottle only takes several seconds anyway.
- adding /usr/local/Cellar and /usr/local/opt proved to be a bad idea: first, they are too large, causing a timeout while making and uploading cache; second, this is unsafe 'cuz
Before
brew update
: clean up Homebrew codebase
- Delete the
Taps/caskroom/homebrew-cask
dir ifTaps/homebrew/homebrew-cask
exists - Find all
git
repos under/usr/local/Homebrew
(find -type d -name .git
, getdirname
of the result) and rungit clean -fxd
in each to get rid of Travis' leftovers - Clean up Homebrew cache from leftovers, too, with
brew cleanup
(if using in conjunction with the previous section, see there for additional operations) -- otherwise, you'll get lots of errors inbrew update
on the "Migrating cache entries..." stage.
- Delete the
At
brew update
:
- Use
brew update --merge
instead -- it will auto-resolve any possible conflicts with your local commits with bottle info
- Use
When re-adding local bottles (if using in conjunction with the previous section):
- Don't re-add bottle info into the formula if it's already present there
- If package version has changed and your bottle info is present in the formula, remove it from the formula and
git commit
the result. There's no stock way to do that, so you'll have to parse and edit the formula file with a script and delete the corresponsing line frombottle do
table. The path to the formula file is retrieved withbrew formula <pkg>
.
When installing:
If using 3rd-party taps, always check if you already have that tap installed:
brew tap | grep -qxF <tap> || brew tap <tap>
Since symlinks aren't saved in Travis cache, pins will likely not be remembered. But it won't hurt to check for them, too:
brew tap --list-pinned | grep -qxF <tap> || brew tap-pin <tap>
At
before_cache
:
- Delete
Taps/homebrew/homebrew-cask/homebrew-cask
if it exists
- Delete
There are 3 separate, loosely related problems here:
- Cache downloaded bottles
- Cache locally-built bottles
- Cache Homebrew metadata
You don't necessarily need all three, so follow whichever sections fit your needs.
Cache downloaded bottles
Add
$HOME/Library/Caches/Homebrew
to Travis' cache (actually, this path is supposed to be retrieved withbrew --cache
but you can't call it here, can you)
cache:
directories:
- $HOME/Library/Caches/Homebrew
Run
brew cleanup
atbefore_cache
stage -- otherwise, the cache will grow indefinitely as new package versions are released
before_cache:
- brew cleanup
Cache locally-built bottles
The full code is too long to list it here, so giving the algorithm.
This is in addition to the previous section. If using without it, save local bottles somewhere outside of Homebrew cache at on installing step and add them to the cache under appropriate names at the at startup step below.
On installing:
- Check package's dependencies with
brew deps
recursively
- If a bottle for the package is not available for your environment (no
(bottled)
inbrew info <pkg>
output), include build dependencies with--include-build
- If a bottle for the package is not available for your environment (no
For each of the packages and dependencies,
- If it's already installed (
brew list --versions <pkg>
succeeds) and latest version (absent frombrew outdated
), skip it - If an older version is present, in the following steps, you'll need to install the new version alongside the old one:
brew unlink
the old version if it's not keg-only (no[keg-only]
inbrew info
output)- Invoke all
brew install
's with--force
- If a bottle is available, just
brew install
it
If a bottle is not available,
Build and install it with the following sequence:
brew install --build-bottle <pkg>
brew bottle --json <pkg>
brew uninstall --ignore-dependencies <pkg>
brew install <bottle>
(There doesn't seem to be any official way to get the names of the resulting bottle and JSON file. I took the bottle name from
brew bottle
output and inferred JSON file name from it.)
Add the bottle info into the package's formula
brew bottle --merge --write <json file>
Save the bottle file into Travis cache under an appropriate name given by
brew --cache <pkg>
- Only do this after adding bottle info -- otherwise, you'll get a path to the source package instead.
- (Homebrew also makes symlinks to downloaded files in
$HOME/Library/Caches/Homebrew
. You don't need to do this.)
- Save the JSON file for later use. Make sure to add its location to Travis cache.
- If it's already installed (
- Check package's dependencies with
At startup:
- Do
brew update
if you're going to - Go through saved .json files. For each one, check if the local bottle is still appropriate (by comparing versions and rebuild numbers; you can parse the output of
brew info --json=v1 <pkg>
andbrew info --json=v1 <bottle>
for this data).
- Delete the cached bottle and the .json if not
- Since you won't be able to get the path to your bottle with
brew --cache
at this point, you need to have saved it independently. Symlinks aren't being saved in Travis' cache as of this writing, so I ended up using regular files that held the paths.
- Since you won't be able to get the path to your bottle with
- Re-add the bottle info into the formula like above if yes
- There's also an unlikely possibility that they change the download URL in the formula without bumping the version -- then the bottle's expected cached name will change because the hash in it is the hash of the download URL. To allow for this, check if
brew --cache <pkg>
still points to your bottle after adding the info.
- There's also an unlikely possibility that they change the download URL in the formula without bumping the version -- then the bottle's expected cached name will change because the hash in it is the hash of the download URL. To allow for this, check if
- Delete the cached bottle and the .json if not
- Do
At
before_cache
:
- If you're using
brew cleanup
from the previous section, save your locally-built bottle files from cache somewhere before running it becausecleanup
may delete those that weren't needed this time around. Aftercleanup
, restore those that were deleted.
- If you're using
Cache Homebrew metadata
If you run brew update --verbose
(and make sure there are no secret variables in .travis.yml
or your Travis project settings -- brew
prints many status messages only if stdout
is a tty) -- you'll see what exactly consititutes a Homebrew selfupdate operation -- thus what you should cache:
- Pulling (actually,
rebase
'ing by default) into a few paths that are actuallygit
repositories:
/usr/local/Homebrew
-- Homebrew itself
/usr/local/Homebrew/Library/Taps/*/*
-- installed taps
- Going through the taps and cache and migrating obsolete bits. Since Travis cache content is added to existing directory structure rather than replaces it, the 2nd time around, there may be strange actions and errors caused by files that were deleted as part of update, but are there again in the new VM. The ones I witnessed:
- will always try migrating
Taps/caskroom/homebrew-cask
toTaps/homebrew/homebrew-cask
, creating a copy atTaps/homebrew/homebrew-cask/homebrew-cask
. If cached, this copy will cause an "error: file exists" on the next run. - will always try to import lots of non-committed files into
Taps/homebrew/homebrew-versions
- will always try migrating
So, the actions will be:
Add
/usr/local/Homebrew
to Travis cache
- adding /usr/local/Cellar and /usr/local/opt proved to be a bad idea: first, they are too large, causing a timeout while making and uploading cache; second, this is unsafe 'cuz
postinstall
scripts may affect other arbitrary parts of the system, so one should install new package versions from (cached) bottles each time rather than cache the result. Installing a bottle only takes several seconds anyway.
- adding /usr/local/Cellar and /usr/local/opt proved to be a bad idea: first, they are too large, causing a timeout while making and uploading cache; second, this is unsafe 'cuz
Before
brew update
: clean up Homebrew codebase
- Delete the
Taps/caskroom/homebrew-cask
dir ifTaps/homebrew/homebrew-cask
exists - Find all
git
repos under/usr/local/Homebrew
(find -type d -name .git
, getdirname
of the result) and rungit clean -fxd
in each to get rid of Travis' leftovers - Clean up Homebrew cache from leftovers, too, with
brew cleanup
(if using in conjunction with the previous section, see there for additional operations) -- otherwise, you'll get lots of errors inbrew update
on the "Migrating cache entries..." stage.
- Delete the
At
brew update
:
- Use
brew update --merge
instead -- it will auto-resolve any possible conflicts with your local commits with bottle info
- Use
When re-adding local bottles (if using in conjunction with the previous section):
- Don't re-add bottle info into the formula if it's already present there
- If package version has changed and your bottle info is present in the formula, remove it from the formula and
git commit
the result. There's no stock way to do that, so you'll have to parse and edit the formula file with a script and delete the corresponsing line frombottle do
table. The path to the formula file is retrieved withbrew formula <pkg>
.
When installing:
If using 3rd-party taps, always check if you already have that tap installed:
brew tap | grep -qxF <tap> || brew tap <tap>
Since symlinks aren't saved in Travis cache, pins will likely not be remembered. But it won't hurt to check for them, too:
brew tap --list-pinned | grep -qxF <tap> || brew tap-pin <tap>
At
before_cache
:
- Delete
Taps/homebrew/homebrew-cask/homebrew-cask
if it exists
- Delete
edited 7 hours ago
answered Nov 16 '18 at 4:43
ivan_pozdeevivan_pozdeev
19.6k85294
19.6k85294
add a comment |
add a comment |
You can add brew cache directory to travis caches:
cache:
directories:
- $HOME/Library/Caches/Homebrew
As far as I know travis doesn't support homebrew caching out of the box.
1
This caches Homebrew resources (the downloads), not the completed builds (binaries, etc). Still super helpful!
– StephenG
May 8 '17 at 18:04
add a comment |
You can add brew cache directory to travis caches:
cache:
directories:
- $HOME/Library/Caches/Homebrew
As far as I know travis doesn't support homebrew caching out of the box.
1
This caches Homebrew resources (the downloads), not the completed builds (binaries, etc). Still super helpful!
– StephenG
May 8 '17 at 18:04
add a comment |
You can add brew cache directory to travis caches:
cache:
directories:
- $HOME/Library/Caches/Homebrew
As far as I know travis doesn't support homebrew caching out of the box.
You can add brew cache directory to travis caches:
cache:
directories:
- $HOME/Library/Caches/Homebrew
As far as I know travis doesn't support homebrew caching out of the box.
answered Dec 29 '16 at 19:36
Kuba F.Kuba F.
18319
18319
1
This caches Homebrew resources (the downloads), not the completed builds (binaries, etc). Still super helpful!
– StephenG
May 8 '17 at 18:04
add a comment |
1
This caches Homebrew resources (the downloads), not the completed builds (binaries, etc). Still super helpful!
– StephenG
May 8 '17 at 18:04
1
1
This caches Homebrew resources (the downloads), not the completed builds (binaries, etc). Still super helpful!
– StephenG
May 8 '17 at 18:04
This caches Homebrew resources (the downloads), not the completed builds (binaries, etc). Still super helpful!
– StephenG
May 8 '17 at 18:04
add a comment |
To cache the actual compiled dependencies as opposed to caching the source tarballs or ccaching object files, adding the respective packages' Cellar
and opt
directories to the cache and using an appropriate before_install check seems to work fine.
You could also add all of /usr/local/Cellar/
and /usr/local/opt/
, but that would add all installed homebrew packages instead of only the ones you need.
Example from a project that depends on openssl, libevent and check:
cache:
directories:
- /usr/local/Cellar/openssl
- /usr/local/opt/openssl
- /usr/local/Cellar/libevent
- /usr/local/opt/libevent
- /usr/local/Cellar/check
- /usr/local/opt/check
before_install:
- test -d /usr/local/opt/openssl/lib || { rmdir /usr/local/opt/openssl; brew install openssl; }
- test -d /usr/local/opt/libevent/lib || { rmdir /usr/local/opt/libevent; brew install libevent; }
- test -d /usr/local/opt/check/lib || { rmdir /usr/local/opt/check; brew install check; }
The rmdir
is needed because TravisCI creates the cached directories if they don't exist, and brew install
fails if /usr/local/opt/$package
is a directory (as opposed to a symlink to a specific installed version in Cellar). For the same reason, test
tests for a subdirectory, not the main package directory.
Note that this approach requires your own project to be able to pick up the dependencies installed in /usr/local/opt
.
add a comment |
To cache the actual compiled dependencies as opposed to caching the source tarballs or ccaching object files, adding the respective packages' Cellar
and opt
directories to the cache and using an appropriate before_install check seems to work fine.
You could also add all of /usr/local/Cellar/
and /usr/local/opt/
, but that would add all installed homebrew packages instead of only the ones you need.
Example from a project that depends on openssl, libevent and check:
cache:
directories:
- /usr/local/Cellar/openssl
- /usr/local/opt/openssl
- /usr/local/Cellar/libevent
- /usr/local/opt/libevent
- /usr/local/Cellar/check
- /usr/local/opt/check
before_install:
- test -d /usr/local/opt/openssl/lib || { rmdir /usr/local/opt/openssl; brew install openssl; }
- test -d /usr/local/opt/libevent/lib || { rmdir /usr/local/opt/libevent; brew install libevent; }
- test -d /usr/local/opt/check/lib || { rmdir /usr/local/opt/check; brew install check; }
The rmdir
is needed because TravisCI creates the cached directories if they don't exist, and brew install
fails if /usr/local/opt/$package
is a directory (as opposed to a symlink to a specific installed version in Cellar). For the same reason, test
tests for a subdirectory, not the main package directory.
Note that this approach requires your own project to be able to pick up the dependencies installed in /usr/local/opt
.
add a comment |
To cache the actual compiled dependencies as opposed to caching the source tarballs or ccaching object files, adding the respective packages' Cellar
and opt
directories to the cache and using an appropriate before_install check seems to work fine.
You could also add all of /usr/local/Cellar/
and /usr/local/opt/
, but that would add all installed homebrew packages instead of only the ones you need.
Example from a project that depends on openssl, libevent and check:
cache:
directories:
- /usr/local/Cellar/openssl
- /usr/local/opt/openssl
- /usr/local/Cellar/libevent
- /usr/local/opt/libevent
- /usr/local/Cellar/check
- /usr/local/opt/check
before_install:
- test -d /usr/local/opt/openssl/lib || { rmdir /usr/local/opt/openssl; brew install openssl; }
- test -d /usr/local/opt/libevent/lib || { rmdir /usr/local/opt/libevent; brew install libevent; }
- test -d /usr/local/opt/check/lib || { rmdir /usr/local/opt/check; brew install check; }
The rmdir
is needed because TravisCI creates the cached directories if they don't exist, and brew install
fails if /usr/local/opt/$package
is a directory (as opposed to a symlink to a specific installed version in Cellar). For the same reason, test
tests for a subdirectory, not the main package directory.
Note that this approach requires your own project to be able to pick up the dependencies installed in /usr/local/opt
.
To cache the actual compiled dependencies as opposed to caching the source tarballs or ccaching object files, adding the respective packages' Cellar
and opt
directories to the cache and using an appropriate before_install check seems to work fine.
You could also add all of /usr/local/Cellar/
and /usr/local/opt/
, but that would add all installed homebrew packages instead of only the ones you need.
Example from a project that depends on openssl, libevent and check:
cache:
directories:
- /usr/local/Cellar/openssl
- /usr/local/opt/openssl
- /usr/local/Cellar/libevent
- /usr/local/opt/libevent
- /usr/local/Cellar/check
- /usr/local/opt/check
before_install:
- test -d /usr/local/opt/openssl/lib || { rmdir /usr/local/opt/openssl; brew install openssl; }
- test -d /usr/local/opt/libevent/lib || { rmdir /usr/local/opt/libevent; brew install libevent; }
- test -d /usr/local/opt/check/lib || { rmdir /usr/local/opt/check; brew install check; }
The rmdir
is needed because TravisCI creates the cached directories if they don't exist, and brew install
fails if /usr/local/opt/$package
is a directory (as opposed to a symlink to a specific installed version in Cellar). For the same reason, test
tests for a subdirectory, not the main package directory.
Note that this approach requires your own project to be able to pick up the dependencies installed in /usr/local/opt
.
answered Aug 29 '18 at 21:43
Daniel RoethlisbergerDaniel Roethlisberger
6,10812947
6,10812947
add a comment |
add a comment |
Homebrew allows you to build from source:
brew install --build-from-source [package-name]
If you want to cache your homebrew for Travis, the only way I have seen how to do this is to create a zipped version of the homebrew dependencies you want similar to this example, travis.yml
1
I don't understand how this helps with travis caching. Where did brew save to in travis? How to I save and restore the cache?
– StephenG
Oct 8 '16 at 14:56
Misunderstood your question, edited
– Wade Williams
Oct 8 '16 at 15:18
add a comment |
Homebrew allows you to build from source:
brew install --build-from-source [package-name]
If you want to cache your homebrew for Travis, the only way I have seen how to do this is to create a zipped version of the homebrew dependencies you want similar to this example, travis.yml
1
I don't understand how this helps with travis caching. Where did brew save to in travis? How to I save and restore the cache?
– StephenG
Oct 8 '16 at 14:56
Misunderstood your question, edited
– Wade Williams
Oct 8 '16 at 15:18
add a comment |
Homebrew allows you to build from source:
brew install --build-from-source [package-name]
If you want to cache your homebrew for Travis, the only way I have seen how to do this is to create a zipped version of the homebrew dependencies you want similar to this example, travis.yml
Homebrew allows you to build from source:
brew install --build-from-source [package-name]
If you want to cache your homebrew for Travis, the only way I have seen how to do this is to create a zipped version of the homebrew dependencies you want similar to this example, travis.yml
edited Oct 8 '16 at 15:17
answered Oct 8 '16 at 14:46
Wade WilliamsWade Williams
1,7391929
1,7391929
1
I don't understand how this helps with travis caching. Where did brew save to in travis? How to I save and restore the cache?
– StephenG
Oct 8 '16 at 14:56
Misunderstood your question, edited
– Wade Williams
Oct 8 '16 at 15:18
add a comment |
1
I don't understand how this helps with travis caching. Where did brew save to in travis? How to I save and restore the cache?
– StephenG
Oct 8 '16 at 14:56
Misunderstood your question, edited
– Wade Williams
Oct 8 '16 at 15:18
1
1
I don't understand how this helps with travis caching. Where did brew save to in travis? How to I save and restore the cache?
– StephenG
Oct 8 '16 at 14:56
I don't understand how this helps with travis caching. Where did brew save to in travis? How to I save and restore the cache?
– StephenG
Oct 8 '16 at 14:56
Misunderstood your question, edited
– Wade Williams
Oct 8 '16 at 15:18
Misunderstood your question, edited
– Wade Williams
Oct 8 '16 at 15:18
add a comment |
The following should cache the compiler results:
cache:
ccache: true
directories:
- $HOME/Library/Caches/Homebrew
On OSX Travis currently seems not to ship ccache by default => Before using ccache the following has to be done, as well:
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache; fi
Admittedly the completed build still is not cached. But the build results of every individual timer run that leads there are so at least big parts of the build process can count as "cached" afterwards.
add a comment |
The following should cache the compiler results:
cache:
ccache: true
directories:
- $HOME/Library/Caches/Homebrew
On OSX Travis currently seems not to ship ccache by default => Before using ccache the following has to be done, as well:
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache; fi
Admittedly the completed build still is not cached. But the build results of every individual timer run that leads there are so at least big parts of the build process can count as "cached" afterwards.
add a comment |
The following should cache the compiler results:
cache:
ccache: true
directories:
- $HOME/Library/Caches/Homebrew
On OSX Travis currently seems not to ship ccache by default => Before using ccache the following has to be done, as well:
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache; fi
Admittedly the completed build still is not cached. But the build results of every individual timer run that leads there are so at least big parts of the build process can count as "cached" afterwards.
The following should cache the compiler results:
cache:
ccache: true
directories:
- $HOME/Library/Caches/Homebrew
On OSX Travis currently seems not to ship ccache by default => Before using ccache the following has to be done, as well:
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache; fi
Admittedly the completed build still is not cached. But the build results of every individual timer run that leads there are so at least big parts of the build process can count as "cached" afterwards.
answered Dec 1 '17 at 8:22
Gunter KönigsmannGunter Königsmann
6614
6614
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39930171%2fcache-brew-builds-with-travis-ci%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you need to cache an existing bottle, a package/bottle that you yourself built, or brew package metadata? These are all completely different things.
– ivan_pozdeev
Nov 5 '18 at 7:23