How to create and debug Ruby gem with C (native) extension

This article explains how to create a minimum Ruby gem with native extension written in C and debug it with gdb. I uploaded complete code to GitHub. Tested with: Ubuntu 20.04 (with self-built Linux kernel 5.11.22+) Ruby 2.7.4 Warning Using Ruby version 2.7.4 is strongly recommended at the first time of doing this tutorial. I think making Ruby-C-extensions has a high probability of encountering errors – for instance, as of 2021-08-14, with Ruby 3.

Sort Scrapbox JSON (Export Pages) by title for git

1 2 3 4 5 # download PROJECT_NAME.json by "Export Pages" cp ~/Downloads/PROJECT_NAME.json ./scrapbox.json git diff ./scrapbox.json # large diff! jq <~/Downloads/PROJECT_NAME.json '.pages = (.pages | sort_by(.title))' > ./scrapbox.json git diff ./scrapbox.json # good diff