~technomancy/fennel

8 2

help getting readline working in repl

Details
Message ID
<f11e1ce6-e7ec-4114-b6d1-18a21f1c06ef@www.fastmail.com>
DKIM signature
fail
Download raw message
DKIM signature: fail
Hi,

I'm on Debian Testing. I just installed Lua 5.4 into /usr/local, and then luarocks there as well.

When I built Lua 5.4, I used linux-readline as the platform (rather than just linux).

After installing luarocks I updated my ~/.bashrc to include:

~~~
export LUA_PATH='/usr/local/share/lua/5.4/?.lua;/usr/local/share/lua/5.4/?/init.lua;/usr/local/lib/lua/5.4/?.lua;/usr/local/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua;/home/john/.luarocks/share/lua/5.4/?.lua;/home/john/.luarocks/share/lua/5.4/?/init.lua'
export LUA_CPATH='/usr/local/lib/lua/5.4/?.so;/usr/local/lib/lua/5.4/loadall.so;./?.so;/home/john/.luarocks/lib/lua/5.4/?.so'
export PATH="/home/john/.luarocks/bin:$PATH"
~~~

I installed fennel via `luarocks --local install fennel`, and fennel works.

I have libreadline-dev apt installed.

When I run lua, I get the expected readline support in the lua repl.

Per the instructions at <https://fennel-lang.org/setup#installing-readline.lua-with-luarocks> I installed:

    luarocks --local install readline

and it seems to have completed fine:

~~~
$ luarocks --local install readline
Installing https://luarocks.org/readline-1.2-1.src.rock
Missing dependencies for readline 1.2-1:
   luaposix >= 30 (not installed)

readline 1.2-1 depends on lua >= 5.1 (5.4-1 provided by VM)
readline 1.2-1 depends on luaposix >= 30 (not installed)
Installing https://luarocks.org/luaposix-35.0-1.src.rock

luaposix 35.0-1 depends on lua >= 5.1, < 5.5 (5.4-1 provided by VM)
/usr/local/bin/lua build-aux/luke package="luaposix" version="35.0" PREFIX="/home/john/.luarocks/lib/luarocks/rocks-5.4/luaposix/35.0-1" LUA="/usr/local/bin/lua" LUA_INCDIR="/usr/local/include" CFLAGS="-O2 -fPIC" LIBFLAG="-shared" LIB_EXTENSION="so" OBJ_EXTENSION="o" INST_LIBDIR="/home/john/.luarocks/lib/luarocks/rocks-5.4/luaposix/35.0-1/lib" INST_LUADIR="/home/john/.luarocks/lib/luarocks/rocks-5.4/luaposix/35.0-1/lua"
creating lib/posix/version.lua
creating build-aux/config.ld
gcc -O2 -fPIC -shared   -DNDEBUG -D_POSIX_C_SOURCE=200809L -DHAVE_MSGSND -DHAVE_SYS_MSG_H -DPACKAGE='"luaposix"' -DVERSION='"35.0"' -D_FORTIFY_SOURCE=2 -DHAVE_MSGRCV -D_XOPEN_SOURCE=700 -Iext/include -I/usr/local/include ext/posix/sys/msg.c -o linux/posix/sys/msg.so 
{snip a bunch more gcc lines}
gcc -O2 -fPIC -shared   -DNDEBUG -DPACKAGE='"luaposix"' -DVERSION='"35.0"' -D_FORTIFY_SOURCE=2 -DHAVE_POSIX_FADVISE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -Iext/include -I/usr/local/include ext/posix/fcntl.c -o linux/posix/fcntl.so 
true -c build-aux/config.ld .
/usr/local/bin/lua build-aux/luke install --quiet INST_LIBDIR="/home/john/.luarocks/lib/luarocks/rocks-5.4/luaposix/35.0-1/lib" INST_LUADIR="/home/john/.luarocks/lib/luarocks/rocks-5.4/luaposix/35.0-1/lua"
luaposix 35.0-1 is now installed in /home/john/.luarocks (license: MIT/X11)

gcc -O2 -fPIC -I/usr/local/include -c C-readline.c -o C-readline.o -I/usr/include
gcc -shared -o C-readline.so C-readline.o -L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lreadline
readline 1.2-1 is now installed in /home/john/.luarocks (license: MIT/X11)
~~~

So, looks like it's installed:

~~~
$ luarocks list

Rocks installed for Lua 5.4
---------------------------

fennel
   0.4.2-2 (installed) - /home/john/.luarocks/lib/luarocks/rocks-5.4

luaposix
   35.0-1 (installed) - /home/john/.luarocks/lib/luarocks/rocks-5.4

readline
   1.2-1 (installed) - /home/john/.luarocks/lib/luarocks/rocks-5.4
~~~

but when I start up the fennel repl I still get:

~~~
$ fennel
Welcome to Fennel 0.4.2 on Lua 5.4!
Use (doc something) to view documentation.
Try installing readline via luarocks for a better repl experience.
>>
~~~

and there's no readline support there.

The fennel setup page says, "Note: If you’ve installed with the --local flag, you may need to ensure your package.path and package.cpath contain its location. See the note on LuaRocks installation for details." ... what are "package.path" and "package.cpath"? (Also the link in the sentence appears broken.)

Thanks!
-- John
Details
Message ID
<1404516b-45ae-4285-a1f5-10eeaf1cb1c4@www.fastmail.com>
In-Reply-To
<f11e1ce6-e7ec-4114-b6d1-18a21f1c06ef@www.fastmail.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Fri, Jul 31, 2020, at 12:59 AM, John Gabriele wrote:
> {snip}
> 
> Per the instructions at 
> <https://fennel-lang.org/setup#installing-readline.lua-with-luarocks> I 
> installed:
> 
>     luarocks --local install readline
> 
> and it seems to have completed fine:
> 
> ~~~
> $ luarocks --local install readline
> Installing https://luarocks.org/readline-1.2-1.src.rock
> {snip}
> ~~~
> 
> So, looks like it's installed:
> 
> ~~~
> $ luarocks list
> 
> Rocks installed for Lua 5.4
> ---------------------------
> 
> fennel
>    0.4.2-2 (installed) - /home/john/.luarocks/lib/luarocks/rocks-5.4
> 
> luaposix
>    35.0-1 (installed) - /home/john/.luarocks/lib/luarocks/rocks-5.4
> 
> readline
>    1.2-1 (installed) - /home/john/.luarocks/lib/luarocks/rocks-5.4
> ~~~

Wait a minute. Is this <https://luarocks.org/modules/peterbillam/readline> the readline I just installed via luarocks? Because according to that web page, it looks like v 1.2-1 is quite old, and that the newest version is 2.6-0. Did luarocks give me an old version of readline? If so, why?
Details
Message ID
<878sezae1n.fsf@hagelb.org>
In-Reply-To
<f11e1ce6-e7ec-4114-b6d1-18a21f1c06ef@www.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
John Gabriele <jgabriele@fastmail.fm> writes:

> I'm on Debian Testing. I just installed Lua 5.4 into /usr/local, and then luarocks there as well.
>
> When I built Lua 5.4, I used linux-readline as the platform (rather than just linux).

I don't actually use readline for my repls, but it may be that our docs
are out of date. I didn't know that Lua 5.4 could be compiled with
built-in readline support. I wonder if this is a new feature in 5.4?

I think the Fennel setup instructions assume that you have not done
this and are pulling in readline externally. Maybe the built-in readline
support conflicts with the luarocks-installed version?

> readline 1.2-1 is now installed in /home/john/.luarocks (license: MIT/X11)

Something is very strange there; I get readline 2.6-0 rather than
1.2-0. I don't use luarocks much, so I can't offer much advice about
what's going wrong there, but it seems fishy.

> but when I start up the fennel repl I still get:
>
> ~~~
> $ fennel
> Welcome to Fennel 0.4.2 on Lua 5.4!
> Use (doc something) to view documentation.
> Try installing readline via luarocks for a better repl experience.
> >>
> ~~~
>
> and there's no readline support there.

The fennel script by default will use /usr/bin/env lua, which may or may
not be your lua5.4 that you've just built. Each version of Lua has its
own store of luarocks-installed libraries. See if this works in order to debug:

    $ lua5.4 -lluarocks.loader /path/to/fennel

And if you have other versions of Lua installed as well, try them to see
if you get different results.

On the other hand, if you are an Emacs user, try using M-x fennel-repl
from fennel-mode.el and you might find that to be a decent substitute
for readline.

-Phil
Details
Message ID
<80d4056b-bdb7-4d1f-82c2-6dba93441556@www.fastmail.com>
In-Reply-To
<878sezae1n.fsf@hagelb.org> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Fri, Jul 31, 2020, at 11:40 AM, Phil Hagelberg wrote:
> John Gabriele <jgabriele@fastmail.fm> writes:
> 
> > I'm on Debian Testing. I just installed Lua 5.4 into /usr/local, and then luarocks there as well.
> >
> > When I built Lua 5.4, I used linux-readline as the platform (rather than just linux).
> 
> I don't actually use readline for my repls,

I don't understand. Do you mean for fennel?

Also, what is the alternative? What would you use in lieu of readline?
(I remember installing rlwrap once to set up and use with a repl that
had no readline support ... is that what you mean?)

>  but it may be that our docs
> are out of date. I didn't know that Lua 5.4 could be compiled with
> built-in readline support. I wonder if this is a new feature in 5.4?

I just learned that in pre 5.4, Lua built with readline by default, and
would not build without it. As of v5.4, the default for building on Linux
(`make linux`) will not give you readline support --- you need to explicitly
ask for it via `make linux-readline`.

> I think the Fennel setup instructions assume that you have not done
> this and are pulling in readline externally. Maybe the built-in readline
> support conflicts with the luarocks-installed version?
> 
> > readline 1.2-1 is now installed in /home/john/.luarocks (license: MIT/X11)
> 
> Something is very strange there; I get readline 2.6-0 rather than
> 1.2-0. I don't use luarocks much, so I can't offer much advice about
> what's going wrong there, but it seems fishy.

Ah, ... y'know, Lua 5.4 was just released quite recently. Looking at [the
readline.lua luarocks page](https://luarocks.org/modules/peterbillam/readline),
if I follow the links on those release nums, the resulting page indicates which
versions the package works for. Most of them say, "For lua >=5.1, <5.4",
*except* for 1.2-1, which says, "For lua >= 5.1" ! Looks like luarocks is only
following orders and thinks anything newer is incompatible.

> > but when I start up the fennel repl I still get:
> >
> > ~~~
> > $ fennel
> > Welcome to Fennel 0.4.2 on Lua 5.4!
> > Use (doc something) to view documentation.
> > Try installing readline via luarocks for a better repl experience.
> > >>
> > ~~~
> >
> > and there's no readline support there.
> 
> The fennel script by default will use /usr/bin/env lua, which may or may
> not be your lua5.4 that you've just built. Each version of Lua has its
> own store of luarocks-installed libraries. See if this works in order to debug:
> 
>     $ lua5.4 -lluarocks.loader /path/to/fennel

Here's what I have:

~~~
$ which lua
/usr/local/bin/lua

$ which fennel
/home/john/.luarocks/bin/fennel

$ lua5.4
bash: lua5.4: command not found

$ lua -lluarocks.loader ~/.luarocks/bin/fennel
lua: /home/john/.luarocks/bin/fennel:3: unexpected symbol near '-'
~~~

What output do you expect for that last command?

Thanks!
-- John
Details
Message ID
<873657a1y7.fsf@hagelb.org>
In-Reply-To
<80d4056b-bdb7-4d1f-82c2-6dba93441556@www.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
John Gabriele <jgabriele@fastmail.fm> writes:

>> I don't actually use readline for my repls,
>
> I don't understand. Do you mean for fennel?

For anything pretty much; I either use language-specific Emacs modes or
run them in an M-x shell buffer so I get all the nice history/bindings
for free.

> I just learned that in pre 5.4, Lua built with readline by default, and
> would not build without it. As of v5.4, the default for building on Linux
> (`make linux`) will not give you readline support --- you need to explicitly
> ask for it via `make linux-readline`.

Looks like I was getting it mixed up with LuaJIT, which does not build
with readline by default.

> $ which lua
> /usr/local/bin/lua
>
> $ which fennel
> /home/john/.luarocks/bin/fennel
>
> $ lua5.4
> bash: lua5.4: command not found
>
> $ lua -lluarocks.loader ~/.luarocks/bin/fennel
> lua: /home/john/.luarocks/bin/fennel:3: unexpected symbol near '-'

Ah; I forgot that luarocks installs a shell script  wrapper as the bit
that goes directly on the $PATH to set up env vars and such.

Try pointing it at ~/.luarocks/lib/luarocks/rocks-5.4/fennel/0.4.2-2/bin/fennel
instead; that is where the actual Lua file lives.

-Phil
Details
Message ID
<b97c954d-b09a-49de-ac62-b09e6efc5e5d@www.fastmail.com>
In-Reply-To
<873657a1y7.fsf@hagelb.org> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Fri, Jul 31, 2020, at 4:01 PM, Phil Hagelberg wrote:
> John Gabriele <jgabriele@fastmail.fm> writes:
> 
> >> I don't actually use readline for my repls,
> >
> > I don't understand. Do you mean for fennel?
> 
> For anything pretty much; I either use language-specific Emacs modes or
> run them in an M-x shell buffer so I get all the nice history/bindings
> for free.

Ah, I see. You're saying that for any program that provides a shell or repl,
you generally don't need that program to be built with readline support,
since you can run it in an M-x shell buffer. Had no idea Emacs could do
that.

> 
> > $ which lua
> > /usr/local/bin/lua
> >
> > $ which fennel
> > /home/john/.luarocks/bin/fennel
> >
> > $ lua5.4
> > bash: lua5.4: command not found
> >
> > $ lua -lluarocks.loader ~/.luarocks/bin/fennel
> > lua: /home/john/.luarocks/bin/fennel:3: unexpected symbol near '-'
> 
> Ah; I forgot that luarocks installs a shell script  wrapper as the bit
> that goes directly on the $PATH to set up env vars and such.
> 
> Try pointing it at ~/.luarocks/lib/luarocks/rocks-5.4/fennel/0.4.2-2/bin/fennel
> instead; that is where the actual Lua file lives.

Thanks. Ok:

~~~
$ lua -lluarocks.loader ~/.luarocks/lib/luarocks/rocks-5.4/fennel/0.4.2-2/bin/fennel
Welcome to Fennel 0.4.2 on Lua 5.4!
Use (doc something) to view documentation.
Try installing readline via luarocks for a better repl experience.
>>
~~~

I emailed the maintainer of readline.lua about the possibility of a dependency
issue with Lua v5.4.
Details
Message ID
<8c426e0b-420b-4fff-9371-fb4823ca3822@www.fastmail.com>
In-Reply-To
<f11e1ce6-e7ec-4114-b6d1-18a21f1c06ef@www.fastmail.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Fri, Jul 31, 2020, at 12:59 AM, John Gabriele wrote:
> 
> The fennel setup page says, "Note: If you’ve installed with the --local 
> flag, you may need to ensure your package.path and package.cpath 
> contain its location. See the note on LuaRocks installation for 
> details." ... what are "package.path" and "package.cpath"? 

Ah, I see. These are in lua's stdlib. They visible in the Lua repl.
Details
Message ID
<60980096-d29b-4bce-957e-30d1d31a3a60@www.fastmail.com>
In-Reply-To
<b97c954d-b09a-49de-ac62-b09e6efc5e5d@www.fastmail.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Fri, Jul 31, 2020, at 4:14 PM, John Gabriele wrote:
> 
> I emailed the maintainer of readline.lua about the possibility of a dependency
> issue with Lua v5.4.

There's a new readline.lua at luarocks (2.7-0). Readline support for
fennel is working for me now.
Details
Message ID
<87v9i28bpw.fsf@hagelb.org>
In-Reply-To
<60980096-d29b-4bce-957e-30d1d31a3a60@www.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
John Gabriele <jgabriele@fastmail.fm> writes:

> There's a new readline.lua at luarocks (2.7-0). Readline support for
> fennel is working for me now.

Cool; thanks for reporting that upstream. Glad it's working now!

-Phil
Export thread (mbox)