Use-package: [question] Does use-package preserve order of installation

Created on 1 Oct 2019  路  6Comments  路  Source: jwiegley/use-package

Hi, thanks for making use-package I was wondering if it preserves order of installation? For instance, I believe magit uses dash as dependency but if in my init.el I have

(use-package dash
   :ensure t
   :config (dash-enable-font-lock))

(use-package magit
  :ensure t
  :bind ("C-x g" . magit-staus))

in my package list it still shows dash as dependency and not as installed. What does that mean? Is it installed separately by use-package but shows as dependency since its required by magit or that use-package avoided its installation until the point where it saw that magit needs to be installed and then installed all magit dependencies?

Another reason why I'm asking this is because in my init I have the following

(setq package-archives                                                          
     '(("MELPA STABLE" . "https://stable.melpa.org/packages/")                 
       ("GNU ELPA"     . "https://elpa.gnu.org/packages/")                     
       ("ORG"          . "https://orgmode.org/elpa/")
       ("MELPA"        . "https://melpa.org/packages/"))                       
        package-archive-priorities                                                
        '(("MELPA Stable" . 10)                                                   
          ("GNU ELPA"     . 5)                                                    
          ("ORG"          . 3)                                                    
          ("MELPA"        . 1)))

which sets my preference where packages should be installed from. For instance the order of preference is melpa stable, elpa, org, melpa. But the image below shows another thing going on.

image

Clearly it shows that dash gets installed twice once from elpa and once from melpa but not as I requested in my package order which should have been melpa stable.

Any ideas whether using :ensure can be used to declare preference?

Most helpful comment

@thomasf damn man, that's a good catch. That's what was actually causing the erratic behaviour. Now things seem to be properly installed without any duplicates.

All 6 comments

I don't actually know anything about the :ensure keyword, but I'm hoping someone else here might know the answer to your question... @raxod502?

If you already had Magit installed, then (use-package magit) and (use-package dash) aren't going to do anything, as they just check package-installed-p and then if it returns nil then they call package-refresh-contents and (possibly) package-install. So actually, the results of the code you gave are nondeterministic and depend on how Emacs started up in the past. I don't know that there's a good way of dealing with this problem in package.el. Personally, I don't use package.el because I think it's bad in general (see straight.el.

@raxod502 thanks for the reference and the clarifications but one thing that doesn't make sense to me is that the image that I provided above is from the first fire up of emacs after byte compiling everything since I had removed the whole elpa directory forcing it to check if packages existed and download accordingly. The other thing is that I believe the following:

(setq package-archives                                                          
     '(("MELPA STABLE" . "https://stable.melpa.org/packages/")                 
       ("GNU ELPA"     . "https://elpa.gnu.org/packages/")                     
       ("ORG"          . "https://orgmode.org/elpa/")
       ("MELPA"        . "https://melpa.org/packages/"))                       
        package-archive-priorities                                                
        '(("MELPA Stable" . 10)                                                   
          ("GNU ELPA"     . 5)                                                    
          ("ORG"          . 3)                                                    
          ("MELPA"        . 1)))

somehow messes things up with use-package, instead if I replace the above with

(setq package-archives                                                          
     '(("MELPA STABLE" . "https://stable.melpa.org/packages/")                 
       ("GNU ELPA"     . "https://elpa.gnu.org/packages/")                     
       ("ORG"          . "https://orgmode.org/elpa/")

then I don't get redundant packages anymore

Ah, well in that case I'm afraid I can't really say. use-package is not doing anything special here; it really is just package-installed-p and package-install last I checked. You could see if putting that code directly into your init-file causes the same behavior to be reproduced. It may be a bug or misfeature in package.el.

I don't know how those priority lists are compared but you do have "MELPA Stable" and "MELPA STABLE" which isn't really an equal string by comparison.

@thomasf damn man, that's a good catch. That's what was actually causing the erratic behaviour. Now things seem to be properly installed without any duplicates.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

endoffile78 picture endoffile78  路  11Comments

cswarth picture cswarth  路  5Comments

jtecca picture jtecca  路  9Comments

DamienCassou picture DamienCassou  路  9Comments

Vurp picture Vurp  路  6Comments