45mg <45mg.wri...@gmail.com> writes:

> Jokes aside, it would be nice to find out why the location of the
> package definition isn't displayed in the backtrace. But I feel like I'd
> need a very thorough understanding of how `guix build` works to figure
> it out.

One important complication to keep in mind is code staging.

Speaking in very rough terms, the package definition is used to compile
a builder script.  The daemon runs that independent builder script,
which has no reference and no knowledge of the module that provides the
package definition.

For example:

--8<---------------cut here---------------start------------->8---
$ guix repl
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> ,use (guix)
scheme@(guix-user)> ,use (gnu packages base)
scheme@(guix-user)> hello
$1 = #<package hello@2.12.1 gnu/packages/base.scm:100 7f4de6e9f4d0>
scheme@(guix-user)> (parameterize ((%graft? #false)) (with-store s 
(run-with-store s (lower-object hello))))
$2 = #<derivation /gnu/store/bfx202rwp4bp4nrvnpqbq0lgannkcxh0-hello-2.12.1.drv 
=> /gnu/store/8bjy9g0cssjrw9ljz2r8ww1sma95isfj-hello-2.12.1 7f4de562ae60>
scheme@(guix-user)> (derivation-sources $2)
$3 = ("/gnu/store/6qhr7s8431yv7ikcax3l30hw6cim95kc-module-import" 
"/gnu/store/vn0i3sxhnhqyafy6zi3m1migs9d3lbgq-hello-2.12.1-builder")
scheme@(guix-user)>
--8<---------------cut here---------------end--------------->8---

That *-builder thing is a Guile script, and the *-module-import thing is
the subset of Guile modules that are available when it is evaluated.
The amount of information ending up in the Guile script is one limiting
factor when it comes to backtraces.

Similarly, code staging also has an effect on error reporting when
generating (rather than executing) the derivation and its builder code.
I think there are fewer good reasons for incomplete or unhelpful
backtraces in that case.

I'm writing this for two reasons:

- it's not always just down to Guile's poor backtraces (which on their own
  can be puzzling, no question about it)
- on the compilation side of things I think Guix would benefit from
  enforcing type contracts to trigger errors earlier.

-- 
Ricardo

Reply via email to