tauri-apps/tauri · error

Only one of --tag, --rev and --branch can be specified

Error message

Only one of --tag, --rev and --branch can be specified

What it means

While `tauri add <official-plugin>` computes the npm spec, it matches on the tuple `(npm_version_req, tag, rev, branch)`. With no version requirement coming from plugin metadata, exactly zero or one of the git options may be set; the catch-all arm fires when two or more are present, because a single npm `repo#ref` spec can only encode one ref.

Source

Thrown at crates/tauri-cli/src/add.rs:117

        .map(ToString::to_string)
        .or(metadata.version_req.as_ref().map(|v| match manager {
          PackageManager::Npm => format!(">={v}"),
          _ => format!("~{v}"),
        }));

      let npm_spec = match (npm_version_req, options.tag, options.rev, options.branch) {
        (Some(version_req), _, _, _) => format!("{npm_name}@{version_req}"),
        (None, Some(tag), None, None) => {
          format!("tauri-apps/tauri-plugin-{plugin}#{tag}")
        }
        (None, None, Some(rev), None) => {
          format!("tauri-apps/tauri-plugin-{plugin}#{rev}")
        }
        (None, None, None, Some(branch)) => {
          format!("tauri-apps/tauri-plugin-{plugin}#{branch}")
        }
        (None, None, None, None) => npm_name,
        _ => crate::error::bail!("Only one of --tag, --rev and --branch can be specified"),
      };
      manager.install(&[npm_spec], dirs.tauri)?;
    }

    let _ = acl::permission::add::command(acl::permission::add::Options {
      identifier: format!("{plugin}:default"),
      capability: None,
    });
  }

  // add plugin init code to main.rs or lib.rs
  let plugin_init_fn = if plugin == "stronghold" {
    "Builder::new(|pass| todo!()).build()"
  } else if plugin == "localhost" {
    "Builder::new(todo!()).build()"
  } else if plugin == "single-instance" {
    "init(|app, args, cwd| {})"
  } else if plugin == "log" {

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Keep exactly one git option: `--tag vX.Y.Z` for a release, `--rev <sha>` for a commit, or `--branch <name>` for a branch
  2. If you want a tagged release on a specific branch, `--tag` alone is sufficient — remove `--branch`/`--rev`
  3. If you did not intend a git install at all, remove all three flags to install from the registry

Example fix

# before
tauri add sql --tag v2.0.0 --branch dev

# after
tauri add sql --tag v2.0.0
Defensive patterns

Strategy: validation

Validate before calling

# allow at most one git ref flag
args=("$@")
count=0
for a in "${args[@]}"; do case "$a" in --tag|--rev|--branch) count=$((count+1));; esac; done
[ "$count" -le 1 ] || { echo 'pass at most one of --tag/--rev/--branch'; exit 1; }
tauri add "$plugin" "${args[@]}"

Prevention

When it happens

Trigger: Running e.g. `tauri add sql --tag v2.0.0 --branch dev`, or any combination of two or three of `--tag`/`--rev`/`--branch` for an official plugin whose npm package has no pinned version requirement.

Common situations: Copy-pasting flags from different instructions; attempting to specify a tag on a branch (git semantics allow tag lookup without the branch); shell scripts that set all three defensively.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/7496b28661c08614. Report an issue: GitHub.