fix(cli): resolve subpackage register paths before deduplication#2428
Open
Anai-Guo wants to merge 1 commit intohuggingface:mainfrom
Open
fix(cli): resolve subpackage register paths before deduplication#2428Anai-Guo wants to merge 1 commit intohuggingface:mainfrom
Anai-Guo wants to merge 1 commit intohuggingface:mainfrom
Conversation
On RHEL/CentOS-derived distros lib64 is a symlink to lib, so both paths appear in submodule_search_locations. The previous set() compared raw strings and treated the symlink siblings as distinct entries, causing each register module to be imported twice and raising 'argparse.ArgumentError: conflicting subparser' at optimum-cli startup. Resolving each path with Path.resolve() before building the set lets symlinked locations collapse to a single canonical entry, so the registration loop runs once per real directory. Fixes huggingface#2417
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #2417.
On RHEL / CentOS-derived distributions
lib64is a symlink tolib, so both site-packages directories end up incommands_register_spec.submodule_search_locations:register_optimum_cli_subcommandsdeduplicates that list with a plainset(...), which compares the raw path strings. Since the strings differ, the same register module is imported twice — once vialib, once vialib64. The duplicateREGISTER_COMMANDSentries then try to register identical subparsers and anyoptimum-cliinvocation that pulls in a subpackage (e.g.optimum-cli export onnx --help) blows up with:Ubuntu / Debian only ship
lib, so the bug never surfaced there. The reporter narrowed it down on CentOS Stream 10; it also reproduces on Fedora, RHEL 8/9 and any virtualenv created on those distros.Fix
Resolve each candidate path with
Path.resolve()before building the deduplication set. Symlinked siblings collapse to one canonical absolute path, so the registration loop runs exactly once per real directory.The rest of the loop is unchanged —
register_pathwas already being wrapped inPath(...)on the first line of the body, so the resolvedPathobject is a drop-in replacement.Why this is safe
submodule_search_locationscontains a single entry,Path.resolve()returns it unchanged.pathlib.Pathis already imported at the top of the module.commands_register_spec.submodule_search_locations is Noneshort-circuit is preserved (lines above the change).Reproduction (matches the issue)
🤖 Generated with Claude Code