IEx history works only once

I’ve recently had to transition to a new laptop and IEx history is being weird. I open up a session, do some stuff, leave. Start a new session, press up and as one would expect the history shows up.

Trouble is, that’s officially the last time it works. If I hunt down the .erlang-history folder and blow it away, same deal. it works… once.

This is on a Mac if that matters. Shell variables are as follows: export ERL_AFLAGS="-kernel shell_history enabled shell_history_path '\"$HOME/.erlang-history\"'"

I’ve never had this issue before. The files appear to have proper write permissions. I specifically changed the default shell_history_path to what you see above and that didn’t solve the issue either.

Elixir 1.16.0 (compiled with Erlang/OTP 24) using asdf.

All right, so… the issue is actually that there appears to be a delay before the history is committed and if you exit too fast the last command is cut off. It was a sort of perfect storm to make it look like it was something else.

1 Like

Slightly related:

I’m not sure of course, but I would guess you’re doing a “hard exit” when you exit IEx.

TBH I’m honestly still not sure what is the best way of exiting IEx is. I hit Ctrl + C twice, but I feel like that could bite me one day.

1 Like

I forget the details, but I’ve taught myself Ctrl-g q as the “nicest” way of exiting.

2 Likes

FWIW I recently discovered the emulator flag (fish) set -gx ERL_FLAGS "+B" (I think bash: export ERL_FLAGS="+B") in my shell profile, which lets CtrlC alone work as is traditional. Maybe it would evade the race condition?