GNU bug report logs - #61289
30.0.50; Cannot reinstall language grammar after running `treesit-ready-p'

Previous Next

Package: emacs;

Reported by: 牟 桐 <mou.tong <at> outlook.com>

Date: Sun, 5 Feb 2023 07:47:02 UTC

Severity: normal

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: 牟 桐 <mou.tong <at> outlook.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: "61289-done <at> debbugs.gnu.org" <61289-done <at> debbugs.gnu.org>
Subject: bug#61289: 回复: 回复: bug#61289: 30.0.50; Cannot reinstall language grammar after running `treesit-ready-p'
Date: Sun, 5 Feb 2023 11:26:42 +0000
[Message part 1 (text/plain, inline)]
> Thanks.  I installed the change on the emacs-29 branch, and I'm
> closing this bug.

I compiled a new Emacs based on emacs-29 branch, it works fine, thanks
for your patience. Hope it will be merged to master soon 😊

> It cannot be deleted as long as the Emacs session which uses it is up
> and running.  Windows doesn't let us delete a DLL that is being used,
> that's why the patch renames it instead.

I get it, thanks for the explanation.

> This was considered, but we decided not to do that, for several good
> reasons.  One reason is that Emacs itself changes the value, which is
> not appropriate with defcustoms.

Oh, it seems that I think too little.

---

发件人: Eli Zaretskii<mailto:eliz <at> gnu.org>
发送时间: 2023年2月5日 18:24
收件人: 牟 桐<mailto:mou.tong <at> outlook.com>
抄送: 61289-done <at> debbugs.gnu.org<mailto:61289-done <at> debbugs.gnu.org>
主题: Re: 回复: bug#61289: 30.0.50; Cannot reinstall language grammar after running `treesit-ready-p'

> From: 牟 桐 <mou.tong <at> outlook.com>
> CC: "61289 <at> debbugs.gnu.org" <61289 <at> debbugs.gnu.org>
> Date: Sun, 5 Feb 2023 09:58:49 +0000
>
> Yes, after applying your patch, I believe this problem has been solved.

Thanks.  I installed the change on the emacs-29 branch, and I'm
closing this bug.

> But I noticed the `libtree-sitter-xxx.dll.old` in the tree-sitter dir
> hadn't been delelted.

It cannot be deleted as long as the Emacs session which uses it is up
and running.  Windows doesn't let us delete a DLL that is being used,
that's why the patch renames it instead.

The next time you install a new version of the same DLL, the .old file
will be deleted, if it still exists.  Or you can delete it by hand.

> If I remove the `ignore-errors` function in your patch, which seems like
> this (sorry, I'm not a programmer and don't know how to use diff):
>
> -          (copy-file lib-name (file-name-as-directory out-dir) t t)
> +          (let* ((library-fname (expand-file-name lib-name out-dir))
> +                 (old-fname (concat library-fname ".old")))
> +            ;; Rename the existing shared library, if any, then
> +            ;; install the new one, and try deleting the old one.
> +            ;; This is for Windows systems, where we cannot simply
> +            ;; overwrite a DLL that is being used.
> +            (if (file-exists-p library-fname)
> +                (rename-file library-fname old-fname t))
> +            (copy-file lib-name (file-name-as-directory out-dir) t t)
> +            ;; Ignore errors, in case the old version is still used.
> +            (delete-file old-fname))
>
>              ^
>              I deleted the outside `ignore-errors` to know why the `xxx.old` hadn’t been deleted.
>
> After applying the change, I got the same error as I mentioned before:
>
> ```
> ⛔ Warning (treesit): Error encountered when installing language grammar: (permission-denied Removing old name Permission denied c:/Users/redacted/.emacs.d/tree-sitter/libtree-sitter-c.dll.old)
> ```

Of course: that's why the patch uses ignore-errors in the first
place.  The DLL cannot be deleted as long as it is used.

> Btw, can we make the variable ` treesit-language-source-alist`
> customizable? (Use `defcustom` instead of `defvar`.) I'm using
> `use-package` to manage my config. When I'm configuring treesit, I'd
> like to use `:custom` instead of `:init` or `:config` since it can let
> me set variable's value without writing `setq`.

This was considered, but we decided not to do that, for several good
reasons.  One reason is that Emacs itself changes the value, which is
not appropriate with defcustoms.

[Message part 2 (text/html, inline)]

This bug report was last modified 2 years and 107 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.