Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cannot determine Magit's version" message with straight.el #4511

Closed
fredericgiquel opened this issue Sep 22, 2021 · 13 comments
Closed

"Cannot determine Magit's version" message with straight.el #4511

fredericgiquel opened this issue Sep 22, 2021 · 13 comments
Labels

Comments

@fredericgiquel
Copy link
Contributor

When magit is installed with straight.el, the following message is displayed at magit startup :

Cannot determine Magit’s version (error "/home/fred/.emacs.d/straight/build/magit/magit.elc" repo static elpa dirname hash)

How to reproduce

  • Use the following init.el
;; Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;; Install magit
(straight-use-package 'magit)
  • M-x magit-status on a git repository
  • Check *Messages* buffer

Other informations

  • Magit version : last commit from github
  • Emacs version : 27.1 from Debian
  • The problem seems to have been introduced by commit d173de7
@tarsius
Copy link
Member

tarsius commented Sep 22, 2021

Probably works now ...

@fredericgiquel
Copy link
Contributor Author

The fix works with Emacs 28. But unfortunaly, the problem persists with Emacs 27.

@tarsius
Copy link
Member

tarsius commented Sep 23, 2021

@fredericgiquel Exact same error?

@raxod502 Can I use straight from an alternative location, so that I can avoid having to move my existing .emacs.d out of the way first. Didn't see anything in the docs.

@fredericgiquel
Copy link
Contributor Author

Yes. Exact same error.
Capture d’écran de 2021-09-23 21-40-12

@fredericgiquel
Copy link
Contributor Author

I think I better understand the cause of the error.

Before d173de7 commit, locate-library was called with "magit.el" argument and always returns the path for magit.el in the build directory of straight.
Now, (locate-library "magit") returns :

  • "/home/fred/.emacs.d/straight/build/magit/magit.elc" with Emacs 27
  • "/home/fred/.emacs.d/straight/build/magit/magit.el" with Emacs 28

According to locate-library documentation, the load-suffixes variable is used to determine which file extensions to search. So replacing

(setq toplib (locate-library "magit"))

by

(let ((load-suffixes (delete ".elc" load-suffixes)))
        (setq toplib (locate-library "magit")))

fixes the error with straight installation of magit (at least in my case). And I think it should work with "magit.el.gz" installation.

tarsius added a commit that referenced this issue Sep 25, 2021
@tarsius
Copy link
Member

tarsius commented Sep 25, 2021

Thanks!

@raxod502
Copy link
Contributor

Can I use straight from an alternative location, so that I can avoid having to move my existing .emacs.d out of the way first. Didn't see anything in the docs

Yeah, you can. In particular you should be able to set straight-base-dir (defaults to user-emacs-directory) before running the bootstrap snippet. Unfortunately, it looks like this isn't documented at present, so I filed radian-software/straight.el#852 accordingly.

@tarsius
Copy link
Member

tarsius commented Sep 27, 2021

Thanks!

@sunlin7
Copy link

sunlin7 commented Oct 11, 2021

It's seems the straight will byte-compile the magit.el to be .../build/magit/magit.elc and soft link the magit.el to be ../build/magit/magit.el,
then (locate-library "magit") got the ../build/magit/magit.elc, magit will failed to detect version for this path.
The solution is like the 9a865f1, and also compatible with some minmum distibution which only has *.elc (without *.el and *.el.gz):

     (let ((load-suffixes '(".el" ".el.gz" ".elc")))
        (setq toplib (locate-library "magit"))))

sunlin7 pushed a commit to sunlin7/magit that referenced this issue Oct 11, 2021
@sunlin7
Copy link

sunlin7 commented Oct 11, 2021

I created new PR #4526 for the fixing,
@fredericgiquel plese help verify with straight.el, thanks.

@tarsius
Copy link
Member

tarsius commented Oct 11, 2021

Thanks!

@fredericgiquel
Copy link
Contributor Author

@sunlin7 Your PR works with straight.el.

@sunlin7
Copy link

sunlin7 commented Oct 12, 2021

Thanks all of you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants