Stabilize offline mode.

This commit is contained in:
Eric Huss 2019-05-12 10:49:45 -07:00
parent ceb1389037
commit 309eb874fd
55 changed files with 803 additions and 97 deletions

View file

@ -32,7 +32,6 @@ Available unstable (nightly-only) flags:
-Z avoid-dev-deps -- Avoid installing dev-dependencies if possible -Z avoid-dev-deps -- Avoid installing dev-dependencies if possible
-Z minimal-versions -- Install minimal dependency versions instead of maximum -Z minimal-versions -- Install minimal dependency versions instead of maximum
-Z no-index-update -- Do not update the registry, avoids a network request for benchmarking -Z no-index-update -- Do not update the registry, avoids a network request for benchmarking
-Z offline -- Offline mode that does not perform network requests
-Z unstable-options -- Allow the usage of unstable options such as --registry -Z unstable-options -- Allow the usage of unstable options such as --registry
-Z config-profile -- Read profiles from .cargo/config files -Z config-profile -- Read profiles from .cargo/config files
-Z install-upgrade -- `cargo install` will upgrade instead of failing -Z install-upgrade -- `cargo install` will upgrade instead of failing
@ -168,6 +167,7 @@ fn execute_subcommand(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
&args.value_of("color").map(|s| s.to_string()), &args.value_of("color").map(|s| s.to_string()),
args.is_present("frozen"), args.is_present("frozen"),
args.is_present("locked"), args.is_present("locked"),
args.is_present("offline"),
arg_target_dir, arg_target_dir,
&args &args
.values_of_lossy("unstable-features") .values_of_lossy("unstable-features")
@ -239,6 +239,7 @@ See 'cargo help <command>' for more information on a specific command.\n",
) )
.arg(opt("frozen", "Require Cargo.lock and cache are up to date").global(true)) .arg(opt("frozen", "Require Cargo.lock and cache are up to date").global(true))
.arg(opt("locked", "Require Cargo.lock is up to date").global(true)) .arg(opt("locked", "Require Cargo.lock is up to date").global(true))
.arg(opt("offline", "Run without accessing the network").global(true))
.arg( .arg(
Arg::with_name("unstable-features") Arg::with_name("unstable-features")
.help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details") .help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details")

View file

@ -322,7 +322,6 @@ impl Features {
pub struct CliUnstable { pub struct CliUnstable {
pub print_im_a_teapot: bool, pub print_im_a_teapot: bool,
pub unstable_options: bool, pub unstable_options: bool,
pub offline: bool,
pub no_index_update: bool, pub no_index_update: bool,
pub avoid_dev_deps: bool, pub avoid_dev_deps: bool,
pub minimal_versions: bool, pub minimal_versions: bool,
@ -367,7 +366,6 @@ impl CliUnstable {
match k { match k {
"print-im-a-teapot" => self.print_im_a_teapot = parse_bool(v)?, "print-im-a-teapot" => self.print_im_a_teapot = parse_bool(v)?,
"unstable-options" => self.unstable_options = true, "unstable-options" => self.unstable_options = true,
"offline" => self.offline = true,
"no-index-update" => self.no_index_update = true, "no-index-update" => self.no_index_update = true,
"avoid-dev-deps" => self.avoid_dev_deps = true, "avoid-dev-deps" => self.avoid_dev_deps = true,
"minimal-versions" => self.minimal_versions = true, "minimal-versions" => self.minimal_versions = true,

View file

@ -299,9 +299,9 @@ pub(super) fn activation_error(
}; };
if let Some(config) = config { if let Some(config) = config {
if config.cli_unstable().offline { if config.offline() {
msg.push_str( msg.push_str(
"\nAs a reminder, you're using offline mode (-Z offline) \ "\nAs a reminder, you're using offline mode (--offline) \
which can sometimes cause surprising resolution failures, \ which can sometimes cause surprising resolution failures, \
if this error is too confusing you may wish to retry \ if this error is too confusing you may wish to retry \
without the offline flag.", without the offline flag.",

View file

@ -36,7 +36,7 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
failure::bail!("you can't generate a lockfile for an empty workspace.") failure::bail!("you can't generate a lockfile for an empty workspace.")
} }
if opts.config.cli_unstable().offline { if opts.config.offline() {
failure::bail!("you can't update in the offline mode"); failure::bail!("you can't update in the offline mode");
} }

View file

@ -47,7 +47,7 @@ pub fn write_pkg_lockfile(ws: &Workspace<'_>, resolve: &Resolve) -> CargoResult<
} }
if !ws.config().lock_update_allowed() { if !ws.config().lock_update_allowed() {
if ws.config().cli_unstable().offline { if ws.config().offline() {
failure::bail!("can't update in the offline mode"); failure::bail!("can't update in the offline mode");
} }

View file

@ -158,9 +158,9 @@ impl<'cfg> Source for GitSource<'cfg> {
let git_path = self.config.assert_package_cache_locked(&git_path); let git_path = self.config.assert_package_cache_locked(&git_path);
let db_path = git_path.join("db").join(&self.ident); let db_path = git_path.join("db").join(&self.ident);
if self.config.cli_unstable().offline && !db_path.exists() { if self.config.offline() && !db_path.exists() {
failure::bail!( failure::bail!(
"can't checkout from '{}': you are in the offline mode (-Z offline)", "can't checkout from '{}': you are in the offline mode (--offline)",
self.remote.url() self.remote.url()
); );
} }
@ -172,7 +172,7 @@ impl<'cfg> Source for GitSource<'cfg> {
let actual_rev = self.remote.rev_for(&db_path, &self.reference); let actual_rev = self.remote.rev_for(&db_path, &self.reference);
let should_update = actual_rev.is_err() || self.source_id.precise().is_none(); let should_update = actual_rev.is_err() || self.source_id.precise().is_none();
let (db, actual_rev) = if should_update && !self.config.cli_unstable().offline { let (db, actual_rev) = if should_update && !self.config.offline() {
self.config.shell().status( self.config.shell().status(
"Updating", "Updating",
format!("git repository `{}`", self.remote.url()), format!("git repository `{}`", self.remote.url()),

View file

@ -363,7 +363,7 @@ impl<'cfg> RegistryIndex<'cfg> {
yanked_whitelist: &HashSet<PackageId>, yanked_whitelist: &HashSet<PackageId>,
f: &mut dyn FnMut(Summary), f: &mut dyn FnMut(Summary),
) -> CargoResult<()> { ) -> CargoResult<()> {
if self.config.cli_unstable().offline if self.config.offline()
&& self.query_inner_with_online(dep, load, yanked_whitelist, f, false)? != 0 && self.query_inner_with_online(dep, load, yanked_whitelist, f, false)? != 0
{ {
return Ok(()); return Ok(());

View file

@ -182,7 +182,7 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
} }
fn update_index(&mut self) -> CargoResult<()> { fn update_index(&mut self) -> CargoResult<()> {
if self.config.cli_unstable().offline { if self.config.offline() {
if self.repo()?.is_empty()? { if self.repo()?.is_empty()? {
// An empty repository is guaranteed to fail, since hitting // An empty repository is guaranteed to fail, since hitting
// this path means we need at least one crate. This is an // this path means we need at least one crate. This is an

View file

@ -52,10 +52,15 @@ pub struct Config {
rustdoc: LazyCell<PathBuf>, rustdoc: LazyCell<PathBuf>,
/// Whether we are printing extra verbose messages /// Whether we are printing extra verbose messages
extra_verbose: bool, extra_verbose: bool,
/// `frozen` is set if we shouldn't access the network /// `frozen` is the same as `locked`, but additionally will not access the
/// network to determine if the lock file is out-of-date.
frozen: bool, frozen: bool,
/// `locked` is set if we should not update lock files /// `locked` is set if we should not update lock files. If the lock file
/// is missing, or needs to be updated, an error is produced.
locked: bool, locked: bool,
/// `offline` is set if we should never access the network, but otherwise
/// continue operating if possible.
offline: bool,
/// A global static IPC control mechanism (used for managing parallel builds) /// A global static IPC control mechanism (used for managing parallel builds)
jobserver: Option<jobserver::Client>, jobserver: Option<jobserver::Client>,
/// Cli flags of the form "-Z something" /// Cli flags of the form "-Z something"
@ -119,6 +124,7 @@ impl Config {
extra_verbose: false, extra_verbose: false,
frozen: false, frozen: false,
locked: false, locked: false,
offline: false,
jobserver: unsafe { jobserver: unsafe {
if GLOBAL_JOBSERVER.is_null() { if GLOBAL_JOBSERVER.is_null() {
None None
@ -560,6 +566,7 @@ impl Config {
color: &Option<String>, color: &Option<String>,
frozen: bool, frozen: bool,
locked: bool, locked: bool,
offline: bool,
target_dir: &Option<PathBuf>, target_dir: &Option<PathBuf>,
unstable_flags: &[String], unstable_flags: &[String],
) -> CargoResult<()> { ) -> CargoResult<()> {
@ -604,6 +611,11 @@ impl Config {
self.extra_verbose = extra_verbose; self.extra_verbose = extra_verbose;
self.frozen = frozen; self.frozen = frozen;
self.locked = locked; self.locked = locked;
self.offline = offline
|| self
.get::<Option<bool>>("net.offline")
.unwrap_or(None)
.unwrap_or(false);
self.target_dir = cli_target_dir; self.target_dir = cli_target_dir;
self.cli_flags.parse(unstable_flags)?; self.cli_flags.parse(unstable_flags)?;
@ -619,7 +631,11 @@ impl Config {
} }
pub fn network_allowed(&self) -> bool { pub fn network_allowed(&self) -> bool {
!self.frozen() && !self.cli_unstable().offline !self.frozen() && !self.offline()
}
pub fn offline(&self) -> bool {
self.offline
} }
pub fn frozen(&self) -> bool { pub fn frozen(&self) -> bool {

View file

@ -23,6 +23,10 @@ file before fetching the dependencies.
If `--target` is not specified, then all target dependencies are fetched. If `--target` is not specified, then all target dependencies are fetched.
See also the link:https://crates.io/crates/cargo-prefetch[cargo-prefetch]
plugin which adds a command to download popular crates. This may be useful if
you plan to use Cargo without a network with the `--offline` flag.
== OPTIONS == OPTIONS
=== Fetch options === Fetch options

View file

@ -100,6 +100,10 @@ include::options-target-triple.adoc[]
*--debug*:: *--debug*::
Build with the `dev` profile instead the `release` profile. Build with the `dev` profile instead the `release` profile.
=== Manifest Options
include::options-locked.adoc[]
=== Miscellaneous Options === Miscellaneous Options
include::options-jobs.adoc[] include::options-jobs.adoc[]

View file

@ -341,6 +341,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -286,6 +286,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -277,6 +277,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -141,6 +141,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -245,6 +245,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -26,6 +26,11 @@ file before fetching the dependencies.</p>
<div class="paragraph"> <div class="paragraph">
<p>If <code>--target</code> is not specified, then all target dependencies are fetched.</p> <p>If <code>--target</code> is not specified, then all target dependencies are fetched.</p>
</div> </div>
<div class="paragraph">
<p>See also the <a href="https://crates.io/crates/cargo-prefetch">cargo-prefetch</a>
plugin which adds a command to download popular crates. This may be useful if
you plan to use Cargo without a network with the <code>--offline</code> flag.</p>
</div>
</div> </div>
</div> </div>
<div class="sect1"> <div class="sect1">
@ -113,6 +118,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -348,6 +348,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -91,6 +91,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -187,6 +187,43 @@ list of supported targets.</p>
</div> </div>
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="cargo_install_manifest_options">Manifest Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>--frozen</strong></dt>
<dt class="hdlist1"><strong>--locked</strong></dt>
<dd>
<p>Either of these flags requires that the <code>Cargo.lock</code> file is
up-to-date. If the lock file is missing, or it needs to be updated, Cargo will
exit with an error. The <code>--frozen</code> flag also prevents Cargo from
attempting to access the network to determine if it is out-of-date.</p>
<div class="paragraph">
<p>These may be used in environments where you want to assert that the
<code>Cargo.lock</code> file is up-to-date (such as a CI build) or want to avoid network
access.</p>
</div>
</dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="cargo_install_miscellaneous_options">Miscellaneous Options</h3> <h3 id="cargo_install_miscellaneous_options">Miscellaneous Options</h3>
<div class="dlist"> <div class="dlist">
<dl> <dl>

View file

@ -363,6 +363,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -170,6 +170,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -150,6 +150,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -169,6 +169,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -207,6 +207,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -269,6 +269,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -282,6 +282,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -366,6 +366,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -125,6 +125,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -99,6 +99,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -265,6 +265,23 @@ attempting to access the network to determine if it is out-of-date.</p>
access.</p> access.</p>
</div> </div>
</dd> </dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl> </dl>
</div> </div>
</div> </div>

View file

@ -8,3 +8,17 @@
These may be used in environments where you want to assert that the These may be used in environments where you want to assert that the
`Cargo.lock` file is up-to-date (such as a CI build) or want to avoid network `Cargo.lock` file is up-to-date (such as a CI build) or want to avoid network
access. access.
*--offline*::
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
+
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the man:cargo-fetch[1] command to download dependencies before going
offline.
+
May also be specified with the `net.offline` linkcargo:reference/config.html[config value].

View file

@ -141,6 +141,7 @@ color = 'auto' # whether cargo colorizes output
[net] [net]
retry = 2 # number of times a network call will automatically retried retry = 2 # number of times a network call will automatically retried
git-fetch-with-cli = false # if `true` we'll use `git`-the-CLI to fetch git repos git-fetch-with-cli = false # if `true` we'll use `git`-the-CLI to fetch git repos
offline = false # do not access the network, but otherwise try to proceed if possible
# Alias cargo commands. The first 4 aliases are built in. If your # Alias cargo commands. The first 4 aliases are built in. If your
# command requires grouped whitespace use the list format. # command requires grouped whitespace use the list format.

View file

@ -30,19 +30,6 @@ cargo-features = ["publish-lockfile"]
publish-lockfile = true publish-lockfile = true
``` ```
### Offline Mode
* Original Issue: [#4686](https://github.com/rust-lang/cargo/issues/4686)
* Tracking Issue: [#5655](https://github.com/rust-lang/cargo/issues/5655)
The `-Z offline` flag prevents Cargo from attempting to access the network for
any reason. Typically Cargo will stop with an error if it wants to access the
network and it is not available.
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are available locally, even
if there might be a newer version as indicated in the local copy of the index.
### no-index-update ### no-index-update
* Original Issue: [#3479](https://github.com/rust-lang/cargo/issues/3479) * Original Issue: [#3479](https://github.com/rust-lang/cargo/issues/3479)

View file

@ -2,12 +2,12 @@
.\" Title: cargo-bench .\" Title: cargo-bench
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-23 .\" Date: 2019-05-08
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-BENCH" "1" "2018-12-23" "\ \&" "\ \&" .TH "CARGO\-BENCH" "1" "2019-05-08" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -401,6 +401,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-build .\" Title: cargo-build
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2019-03-28 .\" Date: 2019-05-08
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-BUILD" "1" "2019-03-28" "\ \&" "\ \&" .TH "CARGO\-BUILD" "1" "2019-05-08" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -324,6 +324,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-check .\" Title: cargo-check
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-20 .\" Date: 2019-04-16
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-CHECK" "1" "2018-12-20" "\ \&" "\ \&" .TH "CARGO\-CHECK" "1" "2019-04-16" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -310,6 +310,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-clean .\" Title: cargo-clean
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-20 .\" Date: 2019-04-16
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-CLEAN" "1" "2018-12-20" "\ \&" "\ \&" .TH "CARGO\-CLEAN" "1" "2019-04-16" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -158,6 +158,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-doc .\" Title: cargo-doc
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-20 .\" Date: 2019-04-16
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-DOC" "1" "2018-12-20" "\ \&" "\ \&" .TH "CARGO\-DOC" "1" "2019-04-16" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -267,6 +267,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-fetch .\" Title: cargo-fetch
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-20 .\" Date: 2019-05-12
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-FETCH" "1" "2018-12-20" "\ \&" "\ \&" .TH "CARGO\-FETCH" "1" "2019-05-12" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -43,6 +43,11 @@ If the lock file is not available, then this command will generate the lock
file before fetching the dependencies. file before fetching the dependencies.
.sp .sp
If \fB\-\-target\fP is not specified, then all target dependencies are fetched. If \fB\-\-target\fP is not specified, then all target dependencies are fetched.
.sp
See also the \c
.URL "https://crates.io/crates/cargo\-prefetch" "cargo\-prefetch"
plugin which adds a command to download popular crates. This may be useful if
you plan to use Cargo without a network with the \fB\-\-offline\fP flag.
.SH "OPTIONS" .SH "OPTIONS"
.SS "Fetch options" .SS "Fetch options"
.sp .sp
@ -131,6 +136,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-fix .\" Title: cargo-fix
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-20 .\" Date: 2019-04-16
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-FIX" "1" "2018-12-20" "\ \&" "\ \&" .TH "CARGO\-FIX" "1" "2019-04-16" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -380,6 +380,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-generate-lockfile .\" Title: cargo-generate-lockfile
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-20 .\" Date: 2019-04-16
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-GENERATE\-LOCKFILE" "1" "2018-12-20" "\ \&" "\ \&" .TH "CARGO\-GENERATE\-LOCKFILE" "1" "2019-04-16" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -116,6 +116,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-install .\" Title: cargo-install
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2019-03-31 .\" Date: 2019-05-12
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-INSTALL" "1" "2019-03-31" "\ \&" "\ \&" .TH "CARGO\-INSTALL" "1" "2019-05-12" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -235,6 +235,36 @@ This may also be specified with the \fBbuild.target\fP
.RS 4 .RS 4
Build with the \fBdev\fP profile instead the \fBrelease\fP profile. Build with the \fBdev\fP profile instead the \fBrelease\fP profile.
.RE .RE
.SS "Manifest Options"
.sp
\fB\-\-frozen\fP, \fB\-\-locked\fP
.RS 4
Either of these flags requires that the \fBCargo.lock\fP file is
up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will
exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from
attempting to access the network to determine if it is out\-of\-date.
.sp
These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access.
.RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Miscellaneous Options" .SS "Miscellaneous Options"
.sp .sp
\fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP \fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-metadata .\" Title: cargo-metadata
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2019-01-05 .\" Date: 2019-05-08
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-METADATA" "1" "2019-01-05" "\ \&" "\ \&" .TH "CARGO\-METADATA" "1" "2019-05-08" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -376,6 +376,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-pkgid .\" Title: cargo-pkgid
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-20 .\" Date: 2019-04-16
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-PKGID" "1" "2018-12-20" "\ \&" "\ \&" .TH "CARGO\-PKGID" "1" "2019-04-16" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -193,6 +193,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-publish .\" Title: cargo-publish
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2019-02-13 .\" Date: 2019-05-08
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-PUBLISH" "1" "2019-02-13" "\ \&" "\ \&" .TH "CARGO\-PUBLISH" "1" "2019-05-08" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -201,6 +201,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Miscellaneous Options" .SS "Miscellaneous Options"
.sp .sp
\fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP \fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-run .\" Title: cargo-run
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2019-02-05 .\" Date: 2019-05-08
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-RUN" "1" "2019-02-05" "\ \&" "\ \&" .TH "CARGO\-RUN" "1" "2019-05-08" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -229,6 +229,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-rustc .\" Title: cargo-rustc
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-20 .\" Date: 2019-04-16
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-RUSTC" "1" "2018-12-20" "\ \&" "\ \&" .TH "CARGO\-RUSTC" "1" "2019-04-16" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -299,6 +299,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-rustdoc .\" Title: cargo-rustdoc
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-20 .\" Date: 2019-04-16
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-RUSTDOC" "1" "2018-12-20" "\ \&" "\ \&" .TH "CARGO\-RUSTDOC" "1" "2019-04-16" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -307,6 +307,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-test .\" Title: cargo-test
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-23 .\" Date: 2019-05-08
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-TEST" "1" "2018-12-23" "\ \&" "\ \&" .TH "CARGO\-TEST" "1" "2019-05-08" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -443,6 +443,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-update .\" Title: cargo-update
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-23 .\" Date: 2019-04-16
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-UPDATE" "1" "2018-12-23" "\ \&" "\ \&" .TH "CARGO\-UPDATE" "1" "2019-04-16" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -146,6 +146,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -2,12 +2,12 @@
.\" Title: cargo-verify-project .\" Title: cargo-verify-project
.\" Author: [see the "AUTHOR(S)" section] .\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 1.5.8 .\" Generator: Asciidoctor 1.5.8
.\" Date: 2018-12-20 .\" Date: 2019-04-16
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "CARGO\-VERIFY\-PROJECT" "1" "2018-12-20" "\ \&" "\ \&" .TH "CARGO\-VERIFY\-PROJECT" "1" "2019-04-16" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.ss \n[.ss] 0 .ss \n[.ss] 0
@ -126,6 +126,23 @@ These may be used in environments where you want to assert that the
\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
access. access.
.RE .RE
.sp
\fB\-\-offline\fP
.RS 4
Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.
.sp
Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the \fBcargo\-fetch\fP(1) command to download dependencies before going
offline.
.sp
May also be specified with the \fBnet.offline\fP \c
.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
.RE
.SS "Common Options" .SS "Common Options"
.sp .sp
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP

View file

@ -61,6 +61,7 @@ fn new_config(env: &[(&str, &str)]) -> Config {
&None, &None,
false, false,
false, false,
false,
&None, &None,
&["advanced-env".into()], &["advanced-env".into()],
) )

View file

@ -3,7 +3,7 @@ use std::fs;
#[test] #[test]
fn offline_unused_target_dep() { fn offline_unused_target_dep() {
// -Z offline with a target dependency that is not used and not downloaded. // --offline with a target dependency that is not used and not downloaded.
Package::new("unused_dep", "1.0.0").publish(); Package::new("unused_dep", "1.0.0").publish();
Package::new("used_dep", "1.0.0").publish(); Package::new("used_dep", "1.0.0").publish();
let p = project() let p = project()
@ -28,9 +28,7 @@ fn offline_unused_target_dep() {
.run(); .run();
p.cargo("clean").run(); p.cargo("clean").run();
// Build offline, make sure it works. // Build offline, make sure it works.
p.cargo("build -Z offline") p.cargo("build --offline").run();
.masquerade_as_nightly_cargo()
.run();
} }
#[test] #[test]
@ -55,11 +53,8 @@ fn offline_missing_optional() {
.run(); .run();
p.cargo("clean").run(); p.cargo("clean").run();
// Build offline, make sure it works. // Build offline, make sure it works.
p.cargo("build -Z offline") p.cargo("build --offline").run();
.masquerade_as_nightly_cargo() p.cargo("build --offline --features=opt_dep")
.run();
p.cargo("build -Z offline --features=opt_dep")
.masquerade_as_nightly_cargo()
.with_stderr( .with_stderr(
"\ "\
[ERROR] failed to download `opt_dep v1.0.0` [ERROR] failed to download `opt_dep v1.0.0`
@ -92,9 +87,7 @@ fn cargo_compile_path_with_offline() {
.file("bar/src/lib.rs", "") .file("bar/src/lib.rs", "")
.build(); .build();
p.cargo("build -Zoffline") p.cargo("build --offline").run();
.masquerade_as_nightly_cargo()
.run();
} }
#[test] #[test]
@ -137,8 +130,7 @@ fn cargo_compile_with_downloaded_dependency_with_offline() {
.file("src/lib.rs", "") .file("src/lib.rs", "")
.build(); .build();
p2.cargo("build -Zoffline") p2.cargo("build --offline")
.masquerade_as_nightly_cargo()
.with_stderr( .with_stderr(
"\ "\
[COMPILING] present_dep v1.2.3 [COMPILING] present_dep v1.2.3
@ -166,8 +158,7 @@ fn cargo_compile_offline_not_try_update() {
.file("src/lib.rs", "") .file("src/lib.rs", "")
.build(); .build();
p.cargo("build -Zoffline") p.cargo("build --offline")
.masquerade_as_nightly_cargo()
.with_status(101) .with_status(101)
.with_stderr( .with_stderr(
"\ "\
@ -183,6 +174,12 @@ project directory before going offline.
", ",
) )
.run(); .run();
p.change_file(".cargo/config", "net.offline = true");
p.cargo("build")
.with_status(101)
.with_stderr_contains("[..]Unable to update registry[..]")
.run();
} }
#[test] #[test]
@ -242,8 +239,7 @@ fn main(){
) )
.build(); .build();
p2.cargo("run -Zoffline") p2.cargo("run --offline")
.masquerade_as_nightly_cargo()
.with_stderr( .with_stderr(
"\ "\
[COMPILING] present_dep v1.2.3 [COMPILING] present_dep v1.2.3
@ -274,15 +270,14 @@ fn cargo_compile_forbird_git_httpsrepo_offline() {
.file("src/main.rs", "") .file("src/main.rs", "")
.build(); .build();
p.cargo("build -Zoffline").masquerade_as_nightly_cargo().with_status(101). p.cargo("build --offline").with_status(101).with_stderr("\
with_stderr("\
error: failed to load source for a dependency on `dep1` error: failed to load source for a dependency on `dep1`
Caused by: Caused by:
Unable to update https://github.com/some_user/dep1.git Unable to update https://github.com/some_user/dep1.git
Caused by: Caused by:
can't checkout from 'https://github.com/some_user/dep1.git': you are in the offline mode (-Z offline)").run(); can't checkout from 'https://github.com/some_user/dep1.git': you are in the offline mode (--offline)").run();
} }
#[test] #[test]
@ -321,8 +316,7 @@ fn compile_offline_while_transitive_dep_not_cached() {
// Restore the file contents. // Restore the file contents.
fs::write(&baz_path, &baz_content).unwrap(); fs::write(&baz_path, &baz_content).unwrap();
p.cargo("build -Zoffline") p.cargo("build --offline")
.masquerade_as_nightly_cargo()
.with_status(101) .with_status(101)
.with_stderr( .with_stderr(
"\ "\
@ -352,8 +346,7 @@ fn update_offline() {
) )
.file("src/main.rs", "fn main() {}") .file("src/main.rs", "fn main() {}")
.build(); .build();
p.cargo("update -Zoffline") p.cargo("update --offline")
.masquerade_as_nightly_cargo()
.with_status(101) .with_status(101)
.with_stderr("error: you can't update in the offline mode[..]") .with_stderr("error: you can't update in the offline mode[..]")
.run(); .run();
@ -448,8 +441,7 @@ fn cargo_compile_offline_with_cached_git_dep() {
let git_root = git_project.root(); let git_root = git_project.root();
p.cargo("build -Zoffline") p.cargo("build --offline")
.masquerade_as_nightly_cargo()
.with_stderr(format!( .with_stderr(format!(
"\ "\
[COMPILING] dep1 v0.5.0 ({}#[..]) [COMPILING] dep1 v0.5.0 ({}#[..])
@ -482,9 +474,7 @@ fn cargo_compile_offline_with_cached_git_dep() {
), ),
); );
p.cargo("build -Zoffline") p.cargo("build --offline").run();
.masquerade_as_nightly_cargo()
.run();
p.process(&p.bin("foo")) p.process(&p.bin("foo"))
.with_stdout("hello from cached git repo rev1\n") .with_stdout("hello from cached git repo rev1\n")
.run(); .run();
@ -531,8 +521,7 @@ fn offline_resolve_optional_fail() {
"#, "#,
); );
p.cargo("build -Z offline") p.cargo("build --offline")
.masquerade_as_nightly_cargo()
.with_status(101) .with_status(101)
.with_stderr("\ .with_stderr("\
[ERROR] failed to select a version for the requirement `dep = \"^2.0\"` [ERROR] failed to select a version for the requirement `dep = \"^2.0\"`
@ -540,7 +529,7 @@ fn offline_resolve_optional_fail() {
location searched: `[..]` index (which is replacing registry `https://github.com/rust-lang/crates.io-index`) location searched: `[..]` index (which is replacing registry `https://github.com/rust-lang/crates.io-index`)
required by package `foo v0.1.0 ([..]/foo)` required by package `foo v0.1.0 ([..]/foo)`
perhaps a crate was updated and forgotten to be re-vendored? perhaps a crate was updated and forgotten to be re-vendored?
As a reminder, you're using offline mode (-Z offline) which can sometimes cause \ As a reminder, you're using offline mode (--offline) which can sometimes cause \
surprising resolution failures, if this error is too confusing you may wish to \ surprising resolution failures, if this error is too confusing you may wish to \
retry without the offline flag. retry without the offline flag.
") ")

View file

@ -68,6 +68,7 @@ proptest! {
&None, &None,
false, false,
false, false,
false,
&None, &None,
&["minimal-versions".to_string()], &["minimal-versions".to_string()],
) )
@ -533,6 +534,7 @@ fn test_resolving_minimum_version_with_transitive_deps() {
&None, &None,
false, false,
false, false,
false,
&None, &None,
&["minimal-versions".to_string()], &["minimal-versions".to_string()],
) )