reddit / emacs

How to use-package on Windows without network access

ixlxixl · 2022-03-21 18:22
My company has restrict network policy where my work Windows 10 PC cannot access Internet. With the init.el file that uses **use-package**, it cannot reach out to any of the archive sites for packages. I went ahead and manually downloaded all the packages from melpa and placed them under \~/.emacs.d/elpa. Now, when emacs starts it complains: Warning (initialization): An error occurred while loading `C:/User/myusername/.emacs.d/init.el': error: Package `use-package-' is unavailable The init.el contains: (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) ;; install use-package if not (unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package)) (eval-when-compile (require 'use-package)) **M-x list-packages** shows the **use-package** package is installed. Any idea how to make it work in my environment? FWIW, I'm running 29.0.50. Thanks.
[deleted] · 2022-03-21 18:51
[deleted]
[deleted] · 2022-03-21 19:06
[deleted]
SegFaultHell · 2022-03-22 02:15
Take it with a grain of salt, I’m not an emacs expert, but I don’t think you should need to touch the package manager at all if you’re manually installing lisp files. In that case you wouldn’t need to add melpa to the package archive list, or install use package if it isn’t available. Instead you’ll want to add the folder with your packages to [the load path](https://www.emacswiki.org/emacs/LoadPath).
ixlxixl · 2022-03-22 02:52
Yes I should be able to but my init.el is heavily built around use-package with customized key bindings and others. So I want to avoid touching these settings as much as possible. But I’ll give it a try tomorrow at work. :-)
BuilderHarm · 2022-03-22 12:28
Hey, my work forbids me from connecting to the internet as well. What I did was download a mirror of all packages from https://github.com/d12frosted/elpa-mirror. Adding the following to my init file allowed me to use `use-package`. (require 'use-package) (setq package-archives `(("melpa" . ,(concat "c:/Program Files/Emacs/" "elpa-mirror/melpa/")) ("org" . ,(concat "c:/Program Files/Emacs/" "elpa-mirror/org/")) ("gnu" . ,(concat "c:/Program Files/Emacs/" "elpa-mirror/gnu/")))) Might have had to call `package-install use-package` before I could require it, but afterwards it all worked fine.
ixlxixl · 2022-03-22 15:06
Splendid! This works! Thanks a ton!