From 94371b786720bb22646411c272605e0047f11607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Fri, 13 Mar 2026 15:12:05 +0100 Subject: [PATCH] Override dbg_callback once kino is installed --- lib/livebook/runtime/evaluator.ex | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/livebook/runtime/evaluator.ex b/lib/livebook/runtime/evaluator.ex index 255c4574dfb..e176c647db4 100644 --- a/lib/livebook/runtime/evaluator.ex +++ b/lib/livebook/runtime/evaluator.ex @@ -649,9 +649,8 @@ defmodule Livebook.Runtime.Evaluator do quoted = Code.string_to_quoted!(code, file: env.file) try do - {value, binding, env} = - Code.eval_quoted_with_env(quoted, binding, env, prune_binding: true) - + opts = maybe_dbg_callback() ++ [prune_binding: true] + {value, binding, env} = Code.eval_quoted_with_env(quoted, binding, env, opts) {:ok, value, binding, env} catch kind, error -> @@ -706,6 +705,15 @@ defmodule Livebook.Runtime.Evaluator do {result, code_markers} end + defp maybe_dbg_callback() do + if Code.ensure_loaded?(Kino.Debug) do + original = Application.fetch_env!(:elixir, :dbg_callback) + [{:dbg_callback, {Kino.Debug, :dbg, [original]}}] + else + [] + end + end + defp extra_diagnostic?(%SyntaxError{}), do: true defp extra_diagnostic?(%TokenMissingError{}), do: true defp extra_diagnostic?(%MismatchedDelimiterError{}), do: true