pkgx icon indicating copy to clipboard operation
pkgx copied to clipboard

`pkgx --offline`

Open felipecrs opened this issue 8 months ago • 5 comments

--offline would prevent pkgx from making any requests, and instead just fail if the operation cannot be accomplished without internet.

  • Refs https://github.com/lowlighter/metrics/pull/1724#discussion_r2105575553
  • Refs https://github.com/pkgxdev/pkgx/issues/1148#issuecomment-2772598695

felipecrs avatar May 24 '25 00:05 felipecrs

pkgx^1 had --keep-going which would work this way, but I think probably this route is better. --offline makes sense. The flag is fine IMO, especially if there is precedent. Is there any you know of?

mxcl avatar May 30 '25 15:05 mxcl

Yes, maven: https://stackoverflow.com/a/7233762/12156188.

felipecrs avatar May 30 '25 15:05 felipecrs

% pkgx cargo --help
Rust's package manager

Usage: cargo [OPTIONS] [COMMAND]
       cargo [OPTIONS] -Zscript <MANIFEST_RS> [ARGS]...

Options:
  -V, --version                  Print version info and exit
      --list                     List installed commands
      --explain <CODE>           Provide a detailed explanation of a rustc error message
  -v, --verbose...               Use verbose output (-vv very verbose/build.rs output)
  -q, --quiet                    Do not print cargo log messages
      --color <WHEN>             Coloring: auto, always, never
  -C <DIRECTORY>                 Change to DIRECTORY before doing anything (nightly-only)
      --locked                   Assert that `Cargo.lock` will remain unchanged
      --offline                  Run without accessing the network
      --frozen                   Equivalent to specifying both --locked and --offline
      --config <KEY=VALUE|PATH>  Override a configuration value
  -Z <FLAG>                      Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
  -h, --help                     Print help

Commands:
    build, b    Compile the current package
    check, c    Analyze the current package and report errors, but don't build object files
    clean       Remove the target directory
    doc, d      Build this package's and its dependencies' documentation
    new         Create a new cargo package
    init        Create a new cargo package in an existing directory
    add         Add dependencies to a manifest file
    remove      Remove dependencies from a manifest file
    run, r      Run a binary or example of the local package
    test, t     Run the tests
    bench       Run the benchmarks
    update      Update dependencies listed in Cargo.lock
    search      Search registry for crates
    publish     Package and upload this package to the registry
    install     Install a Rust binary
    uninstall   Uninstall a Rust binary
    ...         See all commands with --list

See 'cargo help <command>' for more information on a specific command.

jhheider avatar May 30 '25 15:05 jhheider

Npm has --prefer-offline: https://docs.npmjs.com/cli/v11/using-npm/config#offline.

felipecrs avatar May 30 '25 15:05 felipecrs

potentially a stronger (or alternate) option would be --locked, to prevent updating any of its internal files. but since we don't use lock files like a cargo/npm, it might be meaningless.

jhheider avatar May 30 '25 15:05 jhheider