Hi Andrey,

I could reproduce as Sergio did for Noble, using ES_es.UTF-8 (for
convenience in my case):

root@Ncurl:~# env | grep LAN
LANG=es_ES.UTF-8
root@Ncurl:~# /usr/bin/ruby -e 'require "readline"; buf = Readline::readline 
">", true; p buf'
>ñññññññññññ
"ñññññññññññ"

I found some related issues, about building ruby against local readline
to make it works:

https://github.com/rbenv/ruby-build/issues/185
https://blog.rlmflores.me/blog/2012/04/25/adding-utf-8-support-to-rubies-compiled-through-ruby-build/
https://github.com/rbenv/ruby-build/discussions/2357

I checked that in Oracular, with ruby3.3, that's not happening:

root@Oplus1:~# /usr/bin/ruby -e 'require "readline"; buf = Readline::readline 
">", true; p buf'
>ññññññññññ
"ññññññññññ"

So, is it using readline there (Oracular)? I installed 3.3 in Noble, and
it's working without adding anything else:

Se instalarán los siguientes paquetes NUEVOS:
  libruby3.3 ruby3.3
Se actualizarán los siguientes paquetes:
  ruby-xmlrpc


root@Ncurl:~# /usr/bin/ruby3.3 -e 'require "readline"; buf = Readline::readline 
">", true; p buf'
>ñññññññññññ
"ñññññññññññ"

Then, checking what changes in 3.3, I found it's not using readline
anymore: it is using reline now and, in the previous versions, it was
ext/readline, not the readline libs provided by the ubuntu packages [1].
I checked in the buildlog for 3.2 that the autoconfigure pick that
"embedded" readline [2]:

ake -C ext/readline V=1 all
make[4]: Entering directory '/<<PKGBUILDDIR>>/ext/readline'
x86_64-linux-gnu-gcc -I. -I../../.ext/include/x86_64-linux-gnu 
-I../.././include -I../.././ext/readline -DRUBY_EXTCONF_H=\"extconf.h\" 
-Wdate-time -D_FORTIFY_SOURCE=3   -fPIC -g -O2 -fno-omit-frame-pointer 
-mno-omit-leaf-frame-pointer -ffile-prefix-map=/<<PKGBUILDDIR>>=. 
-fstack-protector-strong -fstack-clash-protection -Wformat 
-Werror=format-security -fcf-protection 
-fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/ruby3.2-3.2.3-1ubuntu0.24.04.3 
-fPIC  -o readline.o -c readline.c
rm -f ../../.ext/x86_64-linux-gnu/readline.so
x86_64-linux-gnu-gcc -shared -o ../../.ext/x86_64-linux-gnu/readline.so 
readline.o -L. -L../.. -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now 
-fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed 
-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now    -lruby-3.2 -ledit -lncurses 
 -lm -lpthread  -lc
make[4]: Leaving directory '/<<PKGBUILDDIR>>/ext/readline'

Therefore, and to check that using the system libraries fix the issue, I
build ruby3.2 using libreadline-dev, in the following ppa:

https://launchpad.net/~mirespace/+archive/ubuntu/ruby

That can be used with:

sudo add-apt-repository ppa:mirespace/ruby
sudo apt update

and it fixes the issue:

root@Ncurl:~# apt list --upgradable
Listando... Hecho
dmidecode/noble-updates 3.5-3ubuntu0.1 amd64 [actualizable desde: 3.5-3build1]
libruby3.2/noble 3.2.3-1ubuntu0.24.04.4 amd64 [actualizable desde: 
3.2.3-1ubuntu0.24.04.3]
ruby3.2/noble 3.2.3-1ubuntu0.24.04.4 amd64 [actualizable desde: 
3.2.3-1ubuntu0.24.04.3]


root@Ncurl:~# /usr/bin/ruby3.2 -e 'require "readline"; buf = Readline::readline 
">", true; p buf'
>ññññññ
"ññññññ"

You can check it it fix the issue for you too (I will appreciate your
comments).

I'll add the debdiff to this bug.

However, this change would need to be processed through an SRU [3], and
it's not clear to me that it can land in Noble because we will be
modifying how Ruby behaves with readline: we will need to check other
possible scenarios to see how it impacts.

Therefore, I would like to discuss it with developers more involved in
Ruby (tagging the bug for that).

Thanks.

[1] 
https://github.com/ruby/ruby/blob/a49643340eb6b8d65299912b640887ea18495909/NEWS.md#stdlib-compatibility-issues
[2] 
https://launchpadlibrarian.net/756638295/buildlog_ubuntu-noble-amd64.ruby3.2_3.2.3-1ubuntu0.24.04.3_BUILDING.txt.gz
[3] https://canonical-sru-docs.readthedocs-hosted.com/en/latest/



** Bug watch added: github.com/rbenv/ruby-build/issues #185
   https://github.com/rbenv/ruby-build/issues/185

** Tags added: server-triage-discuss

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2067348

Title:
  ruby build-in readline gem do not handle utf-8 input

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ruby3.2/+bug/2067348/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to