Subject: bug#40099: 28.0.50; [feature/native-comp] Different working dir of .eln files is not expected by pdf-tools

From: Ihor Radchenko <[email-masked]>
Date: Wed, 18 Mar 2020 23:54:46 +0800

> Good point, indeed.  This problem already exists in theory in some
> systems (such as Debian in the past) where byte-compiled files were
> placed in a different directory (for the case where several major
> versions of Emacs are used, with packages re-compiled separately for
> each major version).
>
> But yes, this will bite much more often.

Just found another example from treemacs package:

(defconst treemacs-dir
  ;; locally we're in src/elisp, installed from melpa we're at the package root
  (-let [dir (-> (if load-file-name
                     (file-name-directory load-file-name)
                   default-directory)
                 (expand-file-name))]
    (if (s-ends-with? "src/elisp/" dir)
        (-> dir (f-parent) (f-parent))
      dir))
  "The directory treemacs.el is stored in.")

Dired icons (via treemacs-icons-dired) fail to load because of wrong
directory from treemacs.  

Regards,
Ihor

Stefan Monnier <[email-masked]> writes:

>> Great I think the problem is clear, pdf-tools is using `load-file-name'
>> as a way to obtain `pdf-tools-directory' but this is false assumption
>> for the eln folder directory we have arranged.
>
> Good point, indeed.  This problem already exists in theory in some
> systems (such as Debian in the past) where byte-compiled files were
> placed in a different directory (for the case where several major
> versions of Emacs are used, with packages re-compiled separately for
> each major version).
>
> But yes, this will bite much more often.
>
> We could lie (set `load-file-name` to point to the source file, for
> example) or introduce some function to go from the `load-file-name` to
> the "intended" origin (something like the name of the source file) and
> update all packages to use that function?
>
>> Adding Stephane in cc to get an optinion on this.
>
> I assume that was a typo, I didn't see nay Stephane in the Cc.
>
>
>         Stefan
>

-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China
Email: [email-masked], [email-masked]