{"record":{"id":"7496b28661c08614","repo":"tauri-apps/tauri","slug":"only-one-of-tag-rev-and-branch-can-be-speci","errorCode":null,"errorMessage":"Only one of --tag, --rev and --branch can be specified","messagePattern":"Only one of --tag, --rev and --branch can be specified","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-cli/src/add.rs","lineNumber":117,"sourceCode":"        .map(ToString::to_string)\n        .or(metadata.version_req.as_ref().map(|v| match manager {\n          PackageManager::Npm => format!(\">={v}\"),\n          _ => format!(\"~{v}\"),\n        }));\n\n      let npm_spec = match (npm_version_req, options.tag, options.rev, options.branch) {\n        (Some(version_req), _, _, _) => format!(\"{npm_name}@{version_req}\"),\n        (None, Some(tag), None, None) => {\n          format!(\"tauri-apps/tauri-plugin-{plugin}#{tag}\")\n        }\n        (None, None, Some(rev), None) => {\n          format!(\"tauri-apps/tauri-plugin-{plugin}#{rev}\")\n        }\n        (None, None, None, Some(branch)) => {\n          format!(\"tauri-apps/tauri-plugin-{plugin}#{branch}\")\n        }\n        (None, None, None, None) => npm_name,\n        _ => crate::error::bail!(\"Only one of --tag, --rev and --branch can be specified\"),\n      };\n      manager.install(&[npm_spec], dirs.tauri)?;\n    }\n\n    let _ = acl::permission::add::command(acl::permission::add::Options {\n      identifier: format!(\"{plugin}:default\"),\n      capability: None,\n    });\n  }\n\n  // add plugin init code to main.rs or lib.rs\n  let plugin_init_fn = if plugin == \"stronghold\" {\n    \"Builder::new(|pass| todo!()).build()\"\n  } else if plugin == \"localhost\" {\n    \"Builder::new(todo!()).build()\"\n  } else if plugin == \"single-instance\" {\n    \"init(|app, args, cwd| {})\"\n  } else if plugin == \"log\" {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-cli/src/add.rs#L99-L135","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Keep exactly one git option: `--tag vX.Y.Z` for a release, `--rev <sha>` for a commit, or `--branch <name>` for a branch","If you want a tagged release on a specific branch, `--tag` alone is sufficient — remove `--branch`/`--rev`","If you did not intend a git install at all, remove all three flags to install from the registry"],"exampleFix":"# before\ntauri add sql --tag v2.0.0 --branch dev\n\n# after\ntauri add sql --tag v2.0.0","handlingStrategy":"validation","validationCode":"# allow at most one git ref flag\nargs=(\"$@\")\ncount=0\nfor a in \"${args[@]}\"; do case \"$a\" in --tag|--rev|--branch) count=$((count+1));; esac; done\n[ \"$count\" -le 1 ] || { echo 'pass at most one of --tag/--rev/--branch'; exit 1; }\ntauri add \"$plugin\" \"${args[@]}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember one npm `repo#ref` spec encodes exactly one ref — never combine the three flags","Prefer `--tag` for releases and `--rev` for exact commits; omit all three for registry installs","Validate flag counts in wrapper scripts before shelling out to `tauri add`"],"tags":["tauri-cli","plugin-management","git","cli-flags","mutually-exclusive"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}