marcandre

marcandre

`iex` crashes with recent erlang installs

iex errors when trying to output the result of an expression I type in for recent installs of erlang (errors with 26.1 and 26.1 but not 26.0.2).

$ asdf shell erlang 26.0.2
$ iex
Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Interactive Elixir (1.15.7) - press Ctrl+C to exit (type h() ENTER for help)
iex> 2 + 2
4

$ asdf shell erlang 26.1
$ iex
Erlang/OTP 26 [erts-14.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Interactive Elixir (1.15.7) - press Ctrl+C to exit (type h() ENTER for help)
iex> 2 + 2
Failed to write log message to stdout, trying stderr

09:26:39.936 [error] GenServer #PID<0.64.0> terminating
** (FunctionClauseError) no function clause matching in :prim_tty.cols/2
    (kernel 9.1) prim_tty.erl:980: :prim_tty.cols([{:ansi, "\e[G"}, "\e[35m", 105, 101, 120, 62, "\e[0m", 32, 50, 32, 43, 32, 50], true)
    (kernel 9.1) prim_tty.erl:978: :prim_tty."-cols_multiline/4-lc$^0/1-0-"/3
    (kernel 9.1) prim_tty.erl:978: :prim_tty.cols_multiline/4
    (kernel 9.1) prim_tty.erl:915: :prim_tty.in_view/1
    (kernel 9.1) prim_tty.erl:597: :prim_tty.handle_request/2
    (kernel 9.1) prim_tty.erl:590: :prim_tty.handle_request/2
    (kernel 9.1) user_drv.erl:779: :user_drv.io_request/2
    (kernel 9.1) user_drv.erl:828: :user_drv.io_requests/2
Last message: {:EXIT, #PID<0.69.0>, {:function_clause, [{:prim_tty, :cols, [[{:ansi, "\e[G"}, "\e[35m", 105, 101, 120, 62, "\e[0m", 32, 50, 32, 43, 32, 50], true], [file: ~c"prim_tty.erl", line: 980]}, {:prim_tty, :"-cols_multiline/4-lc$^0/1-0-", 3, [file: ~c"prim_tty.erl", line: 978]}, {:prim_tty, :cols_multiline, 4, [file: ~c"prim_tty.erl", line: 978]}, {:prim_tty, :in_view, 1, [file: ~c"prim_tty.erl", line: 915]}, {:prim_tty, :handle_request, 2, [file: ~c"prim_tty.erl", line: 597]}, {:prim_tty, :handle_request, 2, [file: ~c"prim_tty.erl", line: 590]}, {:user_drv, :io_request, 2, [file: ~c"user_drv.erl", line: 779]}, {:user_drv, :io_requests, 2, [file: ~c"user_drv.erl", line: 828]}]}}
State: {:state, :user_sup, :undefined, #PID<0.69.0>, {#PID<0.64.0>, :user_sup}}

I just installed erlang 26.1.2, same effect.

I tried googling the function clause error but didn’t find an exact match.

Everything else seems to function normally.

Any help and hints much appreciated.

Marked As Solved

josevalim

josevalim

Creator of Elixir

I cannot reproduce it locally. Do you have a custom prompt or any IEx configuration?

Also Liked

AlchemistCamp

AlchemistCamp

I have a similar customized terminal prompt and recently hit this same error (on ubuntu 20.04) after upgrading to OTP-26.

After eliminating the first line that moves the cursor to column 1 and converting the other values to atoms resolved the error for me:

  IEx.configure(
    colors: [
      syntax_colors: [
        number: :light_yellow,
        atom: :light_cyan,
        string: :light_black,
        boolean: [:light_blue],
        nil: [:magenta, :bright]
      ],
      ls_directory: :cyan,
      ls_device: :yellow,
      doc_code: :green,
      doc_inline_code: :magenta,
      doc_headings: [:cyan, :underline],
      doc_title: [:cyan, :bright, :underline]
    ],
    default_prompt:
      [
        :light_magenta,
        "🧪 iex",
        ">",
        :white,
        :reset
      ]
      |> IO.ANSI.format()
      |> IO.chardata_to_string()
  )
marcandre

marcandre

Sometimes I feel very dumb. Turns out I do have a custom .iex.exs, I just didn’t recall creating it.

IEx.configure(
  colors: [
    enabled: true
  ],
  default_prompt: [
      "\e[G",     # ANSI CHA, move cursor to column 1
      "\e[35m",   # ANSI magenta
      "%prefix",  # IEx prompt variable
      ">",        # plain string
      "\e[0m"     # ANSI reset
    ] |> IO.chardata_to_string
)

I have no idea where that comes from. Removing it resolves the issue (of course).

Thank you

josevalim

josevalim

Creator of Elixir

This is definitely a bug though, we would need to isolate and report it upstream. My guess is that Erlang doesn’t like ANSI in prompts.

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Kagamiiiii
Student &amp; New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement