Skip to content

mruby-bin-mirb: drop the readline and linenoise completion adapters - #7249

Merged
matz merged 3 commits into
mruby:masterfrom
takumin:mirb-drop-readline-remnants
Aug 18, 2026
Merged

mruby-bin-mirb: drop the readline and linenoise completion adapters#7249
matz merged 3 commits into
mruby:masterfrom
takumin:mirb-drop-readline-remnants

Conversation

@takumin

@takumin takumin commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

527018c replaced readline, libedit and linenoise in mirb with the built-in multi-line editor and took their detection out of mrbgem.rake. That rake file was also what defined MRB_READLINE_HEADER next to MRB_USE_READLINE, so a config that still defines MRB_USE_READLINE on its own, as the IntelEdison cross target does (build_config/IntelEdison.rb:25), now reaches an #include with nothing to include:

$ MRUBY_CONFIG=IntelEdison rake -j16
...
CPP   mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c -> build/host/mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.pi
mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c:45:10: error: #include expects "FILENAME" or <FILENAME>
   45 | #include MRB_READLINE_HEADER
      |          ^~~~~~~~~~~~~~~~~~~
rake aborted!

What is left in the source

Three guarded blocks survived 527018c, none of them reachable:

Where What
mirb_completion.c:43-51 #ifdef MRB_USE_READLINE#include MRB_READLINE_HEADER, #ifdef MRB_USE_LINENOISE#include <linenoise.h>
mirb_completion.c:593-698 the readline/libedit adapter (mirb_readline_generator, mirb_readline_completion, mirb_setup_readline_completion) and the linenoise adapter (mirb_linenoise_completion, mirb_setup_linenoise_completion)
mirb_completion.h:107-116 the declarations of the two setup functions

mirb.c only calls mirb_setup_editor_completion and mirb_get_completions; neither setup function has a caller. The first commit removes the three blocks together with the current_index field that only the readline generator used, so defining MRB_USE_READLINE or MRB_USE_LINENOISE is a no-op, which is what 527018c's message already says ("readline integration has been completely removed").

The second commit brings mrbgems/mruby-bin-mirb/README.md up to date: it still said completion needs "a readline library", listed the three backends, and documented a MRUBY_MIRB_READLINE environment variable that nothing reads. The Tab Completion section now describes the built-in editor.

The third commit removes the define from IntelEdison.rb:25 itself. It selected mirb's readline backend when the config was written; with the last guarded block gone, cc.defines = %w(MRB_USE_READLINE) only replaces the toolchain's default define list with a stale name. With the config loaded, MRuby.targets['core2-32-poky-linux'].cc.defines is [] where it was ["MRB_USE_READLINE"].

Verified

Three builds of the same config (default.gembox, enable_debug, enable_test) into separate build directories: master, this branch, and this branch with conf.cc.defines << 'MRB_USE_READLINE' added. The third one fails on master at the line above and builds here; mirb_completion.o.flags confirms -DMRB_USE_READLINE reached the compiler.

size on the results, master versus branch and branch with the define:

mirb text mirb_completion.o text
master 2585455 6540
branch 2585439 6529
branch + MRB_USE_READLINE 2585439 6529

The 11 bytes are the ctx->current_index = 0 store in mirb_completion_free (this config is -O0); the guarded blocks were never compiled without the define, so nothing else moves. Master and the branch with the define are not comparable, since master does not build.

Tab completion was driven through a pty on all three binaries with the same key sequence per case (constant Stri, method String.ne, listing String.n, keyword whi, global $std, local my_var), and the three terminal transcripts are byte-identical (md5sum b80fb4d6…). Excerpts:

1> String          # Stri<Tab>
1> String.new      # String.ne<Tab>
1> String.n
new  name  nil?    # String.n<Tab>
1> while           # whi<Tab>
1> $std
$stdin  $stderr  $stdout
1> my_var          # my_<Tab> after my_var = 1

rake -m test on the branch build: KO 0, Crash 0.

Environment

Details
OS Ubuntu 24.04.4 LTS
Kernel Linux 7.0.0-29-generic x86_64
CPU AMD Ryzen 9 5950X, 16 cores / 32 threads
C compiler gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
binutils GNU ld (GNU Binutils) 2.47.20260726
CRuby running rake ruby 4.0.6 (2026-07-14 revision 03b6d3f889) +PRISM

The line each build gives mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c, read off the .flags record beside the object, the -I list and -o dropped:

# master, branch
gcc -std=gnu99 -g -O3 -Wall -Wundef -Werror-implicit-function-declaration -Wwrite-strings -g3 -O0 -DMRBGEM_MRUBY_BIN_MIRB_VERSION=0.0.0 -DMRB_DEBUG -DHAVE_MRUBY_REGEXP_GEM -DMRB_USE_SET -DHAVE_MRUBY_IO_GEM -DMRB_USE_RATIONAL -DMRB_USE_COMPLEX -DMRB_USE_BIGINT -DMRB_USE_DEBUG_HOOK -MMD -c mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c
# branch + MRB_USE_READLINE
gcc -std=gnu99 -g -O3 -Wall -Wundef -Werror-implicit-function-declaration -Wwrite-strings -g3 -O0 -DMRB_USE_READLINE -DMRBGEM_MRUBY_BIN_MIRB_VERSION=0.0.0 -DMRB_DEBUG -DHAVE_MRUBY_REGEXP_GEM -DMRB_USE_SET -DHAVE_MRUBY_IO_GEM -DMRB_USE_RATIONAL -DMRB_USE_COMPLEX -DMRB_USE_BIGINT -DMRB_USE_DEBUG_HOOK -MMD -c mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c

527018c replaced readline, libedit and linenoise with the built-in
multi-line editor and removed their detection from `mrbgem.rake`. That
rake file was also what defined `MRB_READLINE_HEADER` next to
`MRB_USE_READLINE`, so a config that still defines `MRB_USE_READLINE`
on its own now reaches an `#include` with nothing to include:

```console
CPP   mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c -> build/host/mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.pi
mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c:45:10: error: #include expects "FILENAME" or <FILENAME>
   45 | #include MRB_READLINE_HEADER
      |          ^~~~~~~~~~~~~~~~~~~
```

Nothing calls the guarded code any more: `mirb.c` only uses
`mirb_setup_editor_completion` and `mirb_get_completions`, and neither
`mirb_setup_readline_completion` nor `mirb_setup_linenoise_completion`
has a caller. Remove both adapters, their declarations, the conditional
includes, and the `current_index` field that only the readline generator
used. Defining `MRB_USE_READLINE` or `MRB_USE_LINENOISE` is now a no-op,
matching what 527018c already stated.

Without either define the removed blocks were never compiled, so the
editor path is unchanged: `mirb_completion.o` shrinks by the 11 bytes
of the dropped field store and Tab completion behaves identically
before and after.
The README still said completion needs "a readline library", listed
GNU readline, libedit and linenoise as the supported backends, and
documented the `MRUBY_MIRB_READLINE` environment variable. All of that
left with 527018c; the environment variable is not read by anything.

Rewrite the introduction around the built-in multi-line editor and
replace the backend and configuration sections with a short note on
what a Tab press does: a single match is inserted, a shared longer
prefix extends the input, otherwise the candidates are listed.
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 205c7abf-b022-4f84-907f-76ac63aedfc7

📥 Commits

Reviewing files that changed from the base of the PR and between d1bbe7b and 002f4b6.

📒 Files selected for processing (1)
  • build_config/IntelEdison.rb
💤 Files with no reviewable changes (1)
  • build_config/IntelEdison.rb

Included review availability: Your plan includes up to 8 reviews per rolling hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Mirb removes readline, libedit, and linenoise completion adapters, related declarations, cleanup state, headers, and configuration. The README documents the built-in multi-line editor and completion behavior.

Changes

Mirb completion adapter cleanup

Layer / File(s) Summary
Remove external completion adapters
mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.h, mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c, build_config/IntelEdison.rb
The completion context and API no longer expose external adapters. Their includes, callbacks, generators, setup functions, cleanup state, and compiler define are removed.
Update completion documentation
mrbgems/mruby-bin-mirb/README.md
The README identifies the built-in multi-line editor and documents single-match insertion, shared-prefix expansion, and candidate listing.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 002f4

This change removes obsolete completion adapters, keeps built-in tab completion unchanged, and allows the IntelEdison configuration to build successfully. No actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

  • mruby/mruby#7247: Removes related MRB_USE_READLINE configuration from build_config/IntelEdison.rb.

Suggested reviewers: matz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: removing the readline and linenoise completion adapters from mruby-bin-mirb.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the build label Aug 18, 2026
The cross target has carried `cc.defines = %w(MRB_USE_READLINE)` since
the config was written, when it selected mirb's readline backend. mirb
stopped reading the define in 527018c, and the previous commit removed
the last guarded block, so the assignment now selects nothing and only
replaces the toolchain's default define list with a stale name. Delete
it; `cxx.defines` still copies `cc.defines`, which is now the default.

With the config loaded, `MRuby.targets['core2-32-poky-linux'].cc.defines`
is `[]` where it was `["MRB_USE_READLINE"]`.
@takumin
takumin force-pushed the mirb-drop-readline-remnants branch from 002f4b6 to 403b8a1 Compare August 18, 2026 01:40
@matz
matz merged commit 45ebdf2 into mruby:master Aug 18, 2026
20 of 21 checks passed
@takumin
takumin deleted the mirb-drop-readline-remnants branch August 18, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants