all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* error tangling: how to debug please?
@ 2023-09-14 12:29 Fraga, Eric
  2023-09-14 12:40 ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Fraga, Eric @ 2023-09-14 12:29 UTC (permalink / raw)
  To: Emacs Org mode mailing list

Hello all,

I have a rather large & complex file which has many src blocks, all of
which tangle to a single file, defined by a header-args property.

When I try to tangle, I get the following (not very informative
unfortunately) backtrace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  org-src-coderef-regexp(nil)
  org-babel-tangle-single-block(1)
  org-babel-tangle-collect-blocks(nil nil)
  org-babel-tangle(nil)
  funcall-interactively(org-babel-tangle nil)
  command-execute(org-babel-tangle)

This is with both Emacs and org up to date with respect to the
repositories as of a minute or two ago.

I haven't tried emacs -Q or similar as there are too many things to set
up for this complex file.  I am just looking for any hints or
suggestions that could help me debug this.

Thank you,
eric

-- 
: Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: error tangling: how to debug please?
  2023-09-14 12:29 error tangling: how to debug please? Fraga, Eric
@ 2023-09-14 12:40 ` Ihor Radchenko
  2023-09-14 12:51   ` Fraga, Eric
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2023-09-14 12:40 UTC (permalink / raw)
  To: Fraga, Eric; +Cc: Emacs Org mode mailing list

"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:

> I have a rather large & complex file which has many src blocks, all of
> which tangle to a single file, defined by a header-args property.
>
> When I try to tangle, I get the following (not very informative
> unfortunately) backtrace:
>
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>   org-src-coderef-regexp(nil)
>   org-babel-tangle-single-block(1)
> ...
> I haven't tried emacs -Q or similar as there are too many things to set
> up for this complex file.  I am just looking for any hints or
> suggestions that could help me debug this.

Looks like `org-src-coderef-format' returns something weird for one of
the code blocks.

To debug, you can try to patch `org-babel-tangle-single-block', catching
when `org-src-coderef-regexp' is called with nil argument (it must be a
string). Then, examine which source block you are at when that happens.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: error tangling: how to debug please?
  2023-09-14 12:40 ` Ihor Radchenko
@ 2023-09-14 12:51   ` Fraga, Eric
  2023-09-14 12:59     ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Fraga, Eric @ 2023-09-14 12:51 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Emacs Org mode mailing list

Ihor,

On Thursday, 14 Sep 2023 at 12:40, Ihor Radchenko wrote:
> To debug, you can try to patch `org-babel-tangle-single-block', catching
> when `org-src-coderef-regexp' is called with nil argument (it must be a
> string). Then, examine which source block you are at when that happens.

Thank you.  Happy to patch but how do I actually determine the source
block in question?

-- 
: Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: error tangling: how to debug please?
  2023-09-14 12:51   ` Fraga, Eric
@ 2023-09-14 12:59     ` Ihor Radchenko
  2023-09-14 13:00       ` Fraga, Eric
  2023-09-14 14:12       ` Fraga, Eric
  0 siblings, 2 replies; 10+ messages in thread
From: Ihor Radchenko @ 2023-09-14 12:59 UTC (permalink / raw)
  To: Fraga, Eric; +Cc: Emacs Org mode mailing list

"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:

> Ihor,
>
> On Thursday, 14 Sep 2023 at 12:40, Ihor Radchenko wrote:
>> To debug, you can try to patch `org-babel-tangle-single-block', catching
>> when `org-src-coderef-regexp' is called with nil argument (it must be a
>> string). Then, examine which source block you are at when that happens.
>
> Thank you.  Happy to patch but how do I actually determine the source
> block in question?

For the patch, it will be something like adding (when ... (debug)) and
evaluating the defun.

The source block in question is at point, so, in the debugger, you can
just do "e (point) <RET>" and then jump to that point manually.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: error tangling: how to debug please?
  2023-09-14 12:59     ` Ihor Radchenko
@ 2023-09-14 13:00       ` Fraga, Eric
  2023-09-14 14:12       ` Fraga, Eric
  1 sibling, 0 replies; 10+ messages in thread
From: Fraga, Eric @ 2023-09-14 13:00 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Emacs Org mode mailing list

Hi Ihor,

On Thursday, 14 Sep 2023 at 12:59, Ihor Radchenko wrote:
> For the patch, it will be something like adding (when ... (debug)) and
> evaluating the defun.
>
> The source block in question is at point, so, in the debugger, you can
> just do "e (point) <RET>" and then jump to that point manually.

Excellent.  That makes sense.  Thank you.

-- 
: Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: error tangling: how to debug please?
  2023-09-14 12:59     ` Ihor Radchenko
  2023-09-14 13:00       ` Fraga, Eric
@ 2023-09-14 14:12       ` Fraga, Eric
  2023-09-15  9:16         ` Ihor Radchenko
  2023-09-15 14:41         ` Max Nikulin
  1 sibling, 2 replies; 10+ messages in thread
From: Fraga, Eric @ 2023-09-14 14:12 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Emacs Org mode mailing list

Hi Ihor again,

> The source block in question is at point, so, in the debugger, you can
> just do "e (point) <RET>" and then jump to that point manually.

this did the trick.  However, interestingly, the error was a src block
that ended with

+end_src

(somehow the "#" got deleted).  What's interesting is that org continued
to see this as a src block.  I was having some unreproducible problems
with the element cache which may have had something to do with this.

Thanks again,
eric

PS - is there a way to clear the cache completely prior to starting
Emacs?
-- 
: Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: error tangling: how to debug please?
  2023-09-14 14:12       ` Fraga, Eric
@ 2023-09-15  9:16         ` Ihor Radchenko
  2023-09-15 10:45           ` Fraga, Eric
  2023-09-15 14:41         ` Max Nikulin
  1 sibling, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2023-09-15  9:16 UTC (permalink / raw)
  To: Fraga, Eric; +Cc: Emacs Org mode mailing list

"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:

> this did the trick.  However, interestingly, the error was a src block
> that ended with
>
> +end_src
>
> (somehow the "#" got deleted).  What's interesting is that org continued
> to see this as a src block.  I was having some unreproducible problems
> with the element cache which may have had something to do with this.

I recommend setting org-element--cache-self-verify to 'backtrace and
org-element--cache-self-verify-frequency to 1.0. Then, Org will
self-check the cache consistency and generate a backtrace when a problem
is detected.

> PS - is there a way to clear the cache completely prior to starting
> Emacs?

You can disable storing cache between Emacs sessions using
`org-element-cache-persistent'. Or you can simply delete
`org-persist-directory' before starting.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: error tangling: how to debug please?
  2023-09-15  9:16         ` Ihor Radchenko
@ 2023-09-15 10:45           ` Fraga, Eric
  0 siblings, 0 replies; 10+ messages in thread
From: Fraga, Eric @ 2023-09-15 10:45 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Emacs Org mode mailing list

Hi Ihor,

> I recommend setting org-element--cache-self-verify to 'backtrace and
> org-element--cache-self-verify-frequency to 1.0. Then, Org will
> self-check the cache consistency and generate a backtrace when a
> problem is detected.

I have set these and will let you know how I get on.  I have cleared the
whole cache to start from scratch...

Thank you for your help on this.
-- 
: Eric S Fraga, with org release_9.6.7-661-g34ee6f in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: error tangling: how to debug please?
  2023-09-14 14:12       ` Fraga, Eric
  2023-09-15  9:16         ` Ihor Radchenko
@ 2023-09-15 14:41         ` Max Nikulin
  2023-09-15 15:42           ` Fraga, Eric
  1 sibling, 1 reply; 10+ messages in thread
From: Max Nikulin @ 2023-09-15 14:41 UTC (permalink / raw)
  To: emacs-orgmode

On 14/09/2023 21:12, Fraga, Eric wrote:
> this did the trick.  However, interestingly, the error was a src block
> that ended with
> 
> +end_src

Should be caught by `org-lint'

     15 low   Possible incomplete block "#+begin_src"



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: error tangling: how to debug please?
  2023-09-15 14:41         ` Max Nikulin
@ 2023-09-15 15:42           ` Fraga, Eric
  0 siblings, 0 replies; 10+ messages in thread
From: Fraga, Eric @ 2023-09-15 15:42 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode@gnu.org

On Friday, 15 Sep 2023 at 21:41, Max Nikulin wrote:
> Should be caught by `org-lint'

True!  Should have run the document through org-lint.  Ooops.  <blush>

In my defence, I did do so recently but I should get in the habit of
including linting as part of my normal debug process when things go
awry...

Thank you,
eric

-- 
: Eric S Fraga, with org release_9.6.6-412-g2f7b35 in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-09-15 15:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-14 12:29 error tangling: how to debug please? Fraga, Eric
2023-09-14 12:40 ` Ihor Radchenko
2023-09-14 12:51   ` Fraga, Eric
2023-09-14 12:59     ` Ihor Radchenko
2023-09-14 13:00       ` Fraga, Eric
2023-09-14 14:12       ` Fraga, Eric
2023-09-15  9:16         ` Ihor Radchenko
2023-09-15 10:45           ` Fraga, Eric
2023-09-15 14:41         ` Max Nikulin
2023-09-15 15:42           ` Fraga, Eric

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.