macOS Emacs (文件缺失"Cannot open load file" "No such file or directory" "rg"



我试图在emacs中安装ripgrep以便与分类帐模式一起使用

我将这些行添加到我的~/.emacs.d/init.el:

(require 'rg)
(rg-enable-default-bindings)

然后运行emacs -nw——debug-init显示如下:

Debugger entered--Lisp error: (file-missing "Cannot open load file" "No such file or directory" "rg")

这是brew info rg

==> ripgrep: stable 13.0.0 (bottled), HEAD
Search tool like grep and The Silver Searcher
https://github.com/BurntSushi/ripgrep
/opt/homebrew/Cellar/ripgrep/13.0.0 (13 files, 5.8MB) *
Poured from bottle on 2023-01-18 at 19:36:26
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/ripgrep.rb
License: Unlicense
==> Dependencies
Build: asciidoctor, pkg-config, rust
Required: pcre2
==> Options
--HEAD
Install HEAD version
==> Caveats
zsh completions have been installed to:
/opt/homebrew/share/zsh/site-functions
==> Analytics
install: 9,411 (30 days), 30,297 (90 days), 122,177 (365 days)
install-on-request: 9,241 (30 days), 29,736 (90 days), 118,865 (365 days)
build-error: 3 (30 days)

emacs --version

GNU Emacs 28.2
Copyright (C) 2022 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

在emacs中运行C-u M-: (getenv "PATH"),显示/opt/homebrew/bin在PATH中,ls -l /opt/homebrew/bin/rg显示以下内容:

lrwxr-xr-x 1 XXXX XXXX 31 Jan 18 19:36 rg -> ../Cellar/ripgrep/13.0.0/bin/rg

我有一台iMac M1 2001,安装了ventura 13.1和Rosetta。

这是我的整个~/.emacs.d/init.el:

;; Install MELPA
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired.  See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
(add-hook 'after-init-hook 'global-company-mode)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages '(hledger-mode)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; load mu4e from the installation path.
;; yours might differ check with the Emacs installation
(add-to-list 'load-path "/opt/homebrew/Cellar/mu/1.8.13/share/emacs/site-lisp/mu/mu4e")
(require 'mu4e)
;; the headers to show in the headers list -- a pair of a field
;; and its width, with `nil' meaning 'unlimited'
;; (better only use that for the last field.
;; These are the defaults:
(setq mu4e-headers-fields
'( (:human-date    .  25)    ;; alternatively, use :human-date
(:flags         .   6)
(:maildir       .  20)
(:from-or-to    .  22)
(:subject       .  nil))) ;; alternatively, use :thread-subject%:
;;(Use-package mu4e
;;  :load-path  "/usr/local/share/emacs/site-lisp/mu/mu4e/")
;;  :load-path "/opt/homebrew/Cellar/mu/1.8.13/bin")
;; for sending mails
(require 'smtpmail)
;; we installed this with homebrew
(setq mu4e-mu-binary (executable-find "mu"))
;; this is the directory we created before:
(setq mu4e-maildir "~/.maildir")
;; this command is called to sync imap servers:
(setq mu4e-get-mail-command (concat (executable-find "mbsync") " -a"))
;; how often to call it in seconds:
(setq mu4e-update-interval 300)
;; save attachment to desktop by default
;; or another choice of yours:
(setq mu4e-attachment-dir "~/Downloads")
;; rename files when moving - needed for mbsync:
(setq mu4e-change-filenames-when-moving t)
;; list of your email adresses:
(setq mu4e-user-mail-address-list '("justme@gmail.com"))
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
;; check your ~/.maildir to see how the subdirectories are called
;; for the generic imap account:
;; e.g `ls ~/.maildir/example'
(setq   mu4e-maildir-shortcuts
'(("/gmail/INBOX" . ?g)
(:maildir "/gmail/Archives" :key ?a)
("/gmail/[Gmail]/Enviados" . ?G)))
;;(add-to-list 'mu4e-bookmarks
;;             (make-mu4e-bookmark
;;              :name "Inbox - Gmail"
;;              :query "maildir:/gmail/INBOX"
;;              :key ?g))
(setq mu4e-contexts
`(,(make-mu4e-context
:name "gmail"
:enter-func
(lambda () (mu4e-message "Enter justme@gmail.com context"))
:leave-func
(lambda () (mu4e-message "Leave justme@gmail.com context"))
:match-func
(lambda (msg)
(when msg
(mu4e-message-contact-field-matches msg
:to "afrancocorrea@gmail.com")))
:vars '((user-mail-address . "justme@gmail.com")
(user-full-name . "Me and myself")
(mu4e-drafts-folder . "/gmail/Borradores")
(mu4e-refile-folder . "/gmail/Archives")
(mu4e-sent-folder . "/gmail/Enviados")
(mu4e-trash-folder . "/gmail/Papelera")))))
;; gpg encryptiom & decryption:
;; this can be left alone
;;(require 'epa-file)
;;(epa-file-enable)
;;(setq epa-pinentry-mode 'loopback)
;;(auth-source-forget-all-cached)
;; don't keep message compose buffers around after sending:
(setq message-kill-buffer-on-exit t)
;; send function:
(setq send-mail-function 'sendmail-send-it
message-send-mail-function 'sendmail-send-it)
;; send program:
;; this is exeranal. remember we installed it before.
(setq sendmail-program (executable-find "msmtp"))
;; select the right sender email from the context.
(setq message-sendmail-envelope-from 'header)
;; chose from account before sending
;; this is a custom function that works for me.
;; well I stole it somewhere long ago.
;; I suggest using it to make matters easy
;; of course adjust the email adresses and account descriptions
(defun timu/set-msmtp-account ()
(if (message-mail-p)
(save-excursion
(let*
((from (save-restriction
(message-narrow-to-headers)
(message-fetch-field "from")))
(account
(cond
((string-match "justme@gmail.com" from) "gmail"))))
(setq message-sendmail-extra-arguments (list '"-a" account))))))
(add-hook 'message-send-mail-hook 'timu/set-msmtp-account)
;; mu4e cc & bcc
;; this is custom as well
(add-hook 'mu4e-compose-mode-hook
(defun timu/add-cc-and-bcc ()
"My Function to automatically add Cc & Bcc: headers.
This is in the mu4e compose mode."
(save-excursion (message-add-header "Cc:n"))
(save-excursion (message-add-header "Bcc:n"))))
;; mu4e address completion
(add-hook 'mu4e-compose-mode-hook 'company-mode)
;; store link to message if in header view, not to header query:
(setq org-mu4e-link-query-in-headers-mode nil)
;; don't have to confirm when quitting:
(setq mu4e-confirm-quit nil)
;; number of visible headers in horizontal split view:
(setq mu4e-headers-visible-lines 20)
;; don't show threading by default:
(setq mu4e-headers-show-threads nil)
;; hide annoying "mu4e Retrieving mail..." msg in mini buffer:
(setq mu4e-hide-index-messages t)
;; customize the reply-quote-string:
(setq message-citation-line-format "%N @ %Y-%m-%d %H:%M :n")
;; M-x find-function RET message-citation-line-format for docs:
(setq message-citation-line-function 'message-insert-formatted-citation-line)
;; by default do not show related emails:
(setq mu4e-headers-include-related nil)
;; by default do not show threads:
(setq mu4e-headers-show-threads nil)
(require 'rg)
(rg-enable-default-bindings)
;;; Basic configuration
(require 'hledger-mode)
;; To open files with .journal extension in hledger-mode
(add-to-list 'auto-mode-alist '("\.journal\'" . hledger-mode))
;; Personal Accounting
(global-set-key (kbd "C-c e") 'hledger-jentry)
(global-set-key (kbd "C-c j") 'hledger-run-command)
;; Provide the path to you journal file.
;; The default location is too opinionated.
(setq hledger-jfile "~/Documents/hledger/hledger.journal")

当使用brew安装ripgrep时,您可以在命令行(即终端)上为您的计算机提供它。这并不意味着你要告诉Emacs如何使用它。为此,您必须按照此处的安装说明进行操作。

最简单的解决方案是模仿init.elmu4e的方式,即:

1)。下载rg。从上面的GitHub安装说明链接

2)。将该文件放在.emacs中的某个位置。d/文件夹

3)。将路径添加到rg。与在init中完成的方法相同。El为mu4e和要求'rg

这样做应该可以解决您的问题,但是为了更好地理解Emacs配置,我建议您查看System crafter的YouTube频道

相关内容

最新更新