pkg/59895: bash-completion-2.17.0 started to error out `bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8)`

"[email protected] via gnats" <[email protected]>
Newsgroups gmane.os.netbsd.devel.pkgsrc.bugs
Message-ID <[email protected]>
>Number:         59895
>Category:       pkg
>Synopsis:       bash-completion-2.17.0 started to erroring out `bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8)`
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 06 22:55:00 +0000 2026
>Originator:     Leonardo Taccari
>Release:        NetBSD 10.1_STABLE
>Organization:
The NetBSD Foundation
>Environment:
System: NetBSD pinebookpro 10.1_STABLE NetBSD 10.1_STABLE (GENERIC64) #0: Fri Dec 26 12:53:23 UTC 2025 [email protected]:/usr/src/sys/arch/evbarm/compile/GENERIC64 evbarm
Architecture: aarch64
Machine: evbarm
>Description:
	When using shells/bash-completion and having set LANG="en_US.UTF-8"
	trying to complete possible globs spams the terminal with:

	 bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8)

	This seems a problem introduced with bash-completion-2.17.0.
	Previous bash-completion-2.11 did not had such problem.

	The completions are usable but this is pretty annoying.
>How-To-Repeat:
	A simple reproducer that directly calls problematic function:

	 $ export LANG=en_US.UTF-8 # or assume that it is present in ~/.profile
	 [...]
         $ _comp_expand_glob files '/tmp/reproducer-*'
         bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8)
	
	Interactively this can be reproduced via e.g.

	 man m<tab>
	
	So, by typing "man m" and the tab character to complete.
>Fix:
	Yes, please!

	_comp_expand_glob() function of share/bash-completion/bash_completion
	now have:

	 # To canonicalize the sorting order of the generated paths, we set
	 # LC_COLLATE=C and unset LC_ALL while preserving LC_CTYPE.
	 local LC_COLLATE=C LC_CTYPE=${LC_ALL:-${LC_CTYPE:-${LANG-}}} LC_ALL=
	
	NetBSD setlocale(3) says under RETURN VALUES:

	     Currently, setlocale() returns NULL and fails to change the locale when
	     LC_COLLATE is modified independently of other values.
	
	...and under CAVEATS:

	     LC_COLLATE is unimplemented (but does not make sense for many languages).

	Probably this can be due that.

	Getting rid of "LC_COLLATE=C" on that local remove that warnings.
	Maybe we should conditionalize that for [[ $OSTYPE != *netbsd* ]] so
	that such local is not set on NetBSD.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.