# file(DOWNLOAD) offline mode

**URL:** <https://discourse.cmake.org/t/file-download-offline-mode/8916>\
**Category:** Development\
**Created:** [September 12, 2023, 2:49pm UTC](https://discourse.cmake.org/t/file-download-offline-mode/8916 "2023-09-12T14:49:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![leha-bot](https://discourse.cmake.org/user_avatar/discourse.cmake.org/leha-bot/32/921_2.png) [@leha-bot](https://discourse.cmake.org/u/leha-bot)\
**Post date:** [September 12, 2023, 2:49pm UTC](https://discourse.cmake.org/t/file-download-offline-mode/8916/1 "2023-09-12T14:49:59Z")

</div>

It would be great if CMake could simulate an absent Internet connection for `file(DOWNLOAD)` via `CMAKE_FILE_DOWNLOAD_OFFLINE_MODE` (or `CMAKE_OFFLINE_MODE`, the latter also may control the `FetchContent_**()` or another network operations) which could also potentially controlled by `--offline` flag.

It could help to debug some projects without actually disconnecting from the network.

---

<div class="post-metadata">

**Author:** ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)\
**Post date:** [September 12, 2023, 7:09pm UTC](https://discourse.cmake.org/t/file-download-offline-mode/8916/2 "2023-09-12T19:09:20Z")

</div>

I agree, I have a lot of internet-using CMakeLists that also need to work offline, and have made mistakes a couple times when a CMake script didn’t work on a truly offline machine.

This flag would be vital for CI, where I didn’t find a way to disconnect the Internet to the CI runner programatically especially useful for cloud CI runners.

I am not aware of any Curl library option to disable the network. I think this would be a really useful capability for CI tests.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [September 13, 2023, 2:50am UTC](https://discourse.cmake.org/t/file-download-offline-mode/8916/3 "2023-09-13T02:50:36Z")

</div>

> [@scivision](#):
>
> I am not aware of any Curl library option to disable the network. I think this would be a really useful capability for CI tests.

Most CI ends up in a Docker container of some flavor. Is it possible to set up a network namespace in there[1] and just hide all network devices from the build commands (while keeping the connection to the CI mothership intact)?

[1] I mean, everything seems to just assume `root` inside the container anyways these days…

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [September 13, 2023, 2:52am UTC](https://discourse.cmake.org/t/file-download-offline-mode/8916/4 "2023-09-13T02:52:18Z")

</div>

I’ll note that turning off CMake’s view of the network isn’t sufficient as commands that do `pip install` or the like also need to be silenced. I think the “hide the network” sandboxing is the best way to do that here.

Given the “`root` in a container” assumptions, you could just blackhole all DNS so that at least anything that does get out is a direct IP address connection…

---

<div class="post-metadata">

**Author:** ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)\
**Post date:** [September 13, 2023, 12:33pm UTC](https://discourse.cmake.org/t/file-download-offline-mode/8916/5 "2023-09-13T12:33:20Z")

</div>

Oh I think this docker container is a great suggestion. Yes, the CI systems I use work well with docker. So I will give that a try when I have time. Thanks…
