Suppose I have a librari named foo-bar
, and I've written a conanfile.py
for it. When running conan create
for it, I get the warning:
WARN: Name containing special chars is discouraged 'foo-bar'
right away.
My question: How strongly is this discouraged? How bad is it - if at all - to have a Conan package name with hyphens/minus chars?
PS - In case it matters, I'm using Conan 2.0.13 and am hoping to get my package onto the Conan Center.
TL;DR: There's a risk of conflicts when exporting packages whose names only vary in the special characters +
/-
/_
. For example foo+bar
, foo-bar
, and foo_bar
.
Looking at the source where that warning is emitted, there's a comment that provides a bit of context:
# Warn if they use .+- in the name/user/channel, as it can be problematic for generators
pattern = re.compile(r'[.+-]')
if pattern.search(self.name):
ConanOutput().warning(f"Name containing special chars is discouraged '{self.name}'")
This check was added in PR #12053 (issue #11857), which was a response to PR #11826 (issue #11822). The root issue was that +
s and -
s in package names would both become normalized to _
in some contexts, which could create ambiguity if two package names differed only in their use of +
/-
/_
.
How bad using a -
is depends on whether you think there's a risk of conflicts from exporting two packages that vary only in +
/-
/_
.
I do not see any references about using -
s being officially deprecated. The tutorial in the docs still states that -
s are valid in package names:
name
: a string, with a minimum of 2 and a maximum of 100 lowercase characters that defines the package name. It should start with alphanumeric or underscore and can contain alphanumeric, underscore,+
,.
,-
characters.