Reading a single line from console with shard: readline

I added “readline” to shard.yml and ran shard install. “readline” installed without complaints. However, > when I try to run the program using it, it stumbles on require “readline” line with:
/usr/bin/ld: cannot find -lreadline (this usually means you need to install the development package for libreadline):
Unfortunately, being new to Crystal I don’t even know where and how to start looking for solution to this issue.

Hi

This means the library depends on a separate library. How these can be installed depends on your operating system.

You may also want to file a bug about it at the readline shard repository. Things like external dependencies should absolutely be documented.

Just before I read your reply I found a solution. I thought it must be a system library and with little googling I found a package(for Debian/Ubuntu) libreadline-dev which I installed with apt install and now the readline works. As total newcomer I am a little shy to file a bug, but I agree such thing should be documented. Even more - this means readline probably won’t work on windows which should also be documented!

I suspect this is a thing for more than a few shards.

It might be a good idea to have some kind of automatic check in the shards command on install, especially if windows becomes a first class citizen eventually.

And shards.info could maybe put a badge on shards that have outside requirements and especially ones that ship binary blobs inside.

If this relates to GitHub - crystal-lang/crystal-readline: Crystal bindings to GNU Readline Library then the readme could guide newcomers a little better.

GitHub - crystal-lang/crystal-sqlite3: SQLite3 bindings for Crystal suffers from the same issue, but maybe is more universally available.

Since you are dealing with readline you might be interested in a pure crystal implementation New shard REPLy : A Reader for your REPL

4 Likes