unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "牟 桐" <mou.tong@outlook.com>
Cc: 61289-done@debbugs.gnu.org
Subject: bug#61289: 回复: bug#61289: 30.0.50; Cannot reinstall language grammar after running `treesit-ready-p'
Date: Sun, 05 Feb 2023 12:24:46 +0200	[thread overview]
Message-ID: <83cz6os93l.fsf@gnu.org> (raw)
In-Reply-To: <SJ0P220MB067564C9C75BAC75635AA81D97D59@SJ0P220MB0675.NAMP220.PROD.OUTLOOK.COM> (message from 牟 桐 on Sun, 5 Feb 2023 09:58:49 +0000)

> From: 牟 桐 <mou.tong@outlook.com>
> CC: "61289@debbugs.gnu.org" <61289@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.





  reply	other threads:[~2023-02-05 10:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-04 12:59 bug#61289: 30.0.50; Cannot reinstall language grammar after running `treesit-ready-p' 牟 桐
2023-02-05  9:13 ` Eli Zaretskii
2023-02-05  9:58   ` bug#61289: 回复: " 牟 桐
2023-02-05 10:24     ` Eli Zaretskii [this message]
2023-02-05 11:26       ` bug#61289: 回复: " 牟 桐

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83cz6os93l.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=61289-done@debbugs.gnu.org \
    --cc=mou.tong@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).