marcandre

marcandre

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.

Showing Posts 1 to 8

josevalim

josevalim

Creator of Elixir

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

marcandre

marcandre OP

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.

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()
  )
tmock12

tmock12

I tried this, but without the “move cursor to column 1” when you hit up or down arrows to scroll through history, it seems to continuously build the prompt. (ie: keeps adding additional :test_tube: to start of prompt)

AlchemistCamp

AlchemistCamp

Yes. I previously had that line in my .iex.exs file but it broke functionality after upgrading to OTP 26. By this I mean that hitting up and trying to rerun previous commands failed.

Removing the line, IEX is usable, but the UI issue with duplicating :test_tube:s in the prompt happens. I’m not sure why the "\e[G" (move cursor to column 1) line broke on OTP 26, and still need to look into it further.

AlchemistCamp

AlchemistCamp

I just tested the quoted code above with Elixir 1.17 and OTP 27 and the ANSI CHA line still causes crashes.

However the issue of duplicating :test_tube:s when the line is removed. I.e., the config you quoted above behaves normally when scrolling through IEX history on current language versions.

AlchemistCamp

AlchemistCamp

As of Elixir 1.17.2-otp-27, this problem resolved for me and I reverted the default_prompt section of my IEx.configure back to the following:

    default_prompt:
      [
        "\e[G",
        :light_magenta,
        "🧪 iex",
        "(%counter)>",
        :white,
        :reset
      ]
      |> IO.ANSI.format()
      |> IO.chardata_to_string()
— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews