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

Error with daemon running through brew services #637

Open
fast-90 opened this issue Dec 12, 2023 · 2 comments
Open

Error with daemon running through brew services #637

fast-90 opened this issue Dec 12, 2023 · 2 comments

Comments

@fast-90
Copy link

fast-90 commented Dec 12, 2023

Issue

When I start a daemon with brew start services emacs-plus, I get an "End of file during parsing: Error reading from stdin" error. The strange thing is that I don't get this error when I start a daemon with emacs --daemon in the terminal (after stopping the brew services).

Googling the error seems to suggest that there may be unbalanced parentheses in my config files, but as far as I can tell (visually and using check-parens) this does not seem to be the case.

Does anyone know what the problem might be? How would I go about debugging this further to pinpoint the root cause of the issue?

My setup

MacOS

  • Apple M3 Pro
  • macOS 14.1.2 (Sonoma)

Emacs

==> d12frosted/emacs-plus/emacs-plus@29: stable 29.1, HEAD
/opt/homebrew/Cellar/emacs-plus@29/29.1 (4,539 files, 253.2MB) *
Built from source on 2023-12-01 at 17:04:55 with: --with-xwidgets --with-native-comp --with-imagemagick --with-mailutils
From: https://github.com/d12frosted/homebrew-emacs-plus/blob/HEAD/Formula/[email protected]
==> Dependencies
Build: make ✔, autoconf ✔, gnu-sed ✔, gnu-tar ✔, grep ✔, awk ✔, coreutils ✔, pkg-config ✔, texinfo ✔, xz ✔
Required: gnutls ✔, librsvg ✔, little-cms2 ✔, jansson ✔, tree-sitter ✔
Optional: imagemagick ✘, dbus ✘, mailutils ✔

Error message

Full backtrace from "/tmp/homebrew.mxcl.emacs-plus.stderr.log":

Wrote /Users/duynguyen/.config/emacs/recentf
Wrote /Users/duynguyen/repos/config-files/emacs/config.el
Tangled 145 code blocks from config.org
Loading /Users/duynguyen/repos/config-files/emacs/config.el (source)...
Repeat mode is enabled for 28 commands and 12 keymaps; see ‘describe-repeat-maps’
Loading gcmh (native compiled elisp)...
Loading gcmh (native compiled elisp)...done
Loading /Users/duynguyen/.config/emacs/recentf...
Loading /Users/duynguyen/.config/emacs/recentf...done
Cleaning up the recentf list...
Cleaning up the recentf list...done (0 removed)
Tramp: Opening connection *system-packages* for root@Duys-MBPusing sudo...
Opening connection *system-packages* for root@Duys-MBPusing sudo... \ 
Tramp: Opening connection *system-packages* for root@Duys-MBPusing sudo...done
Tramp: Opening connection nil for root@Duys-MBPusing sudo...
Opening connection nil for root@Duys-MBPusing sudo... \ 
Tramp: Opening connection nil for root@Duys-MBPusing sudo...done
 stop  Warning (initialization): An error occurred while loading ‘/Users/duynguyen/.config/emacs/init.el’:

End of file during parsing: Error reading from stdin

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.
Starting Emacs daemon.
nil: exited abnormally with code 127.
@fast-90
Copy link
Author

fast-90 commented Dec 12, 2023

OK so I figured out that it is because of this line in my config:

(use-package consult
   :ensure-system-package (rg . ripgrep)

This line checks whether the rg binary exists, and I think the brew services does this in sudo mode and therefore requires me to enter my password (hence the "Error reading from stdin"). However, I have no clue how to solve this (i.e. to make brew services work with the above elisp code).

@d12frosted
Copy link
Owner

I don't think it's because of sudo (why and how would it run it as sudo?), but rather because launchctl runs Emacs in a different environment (ie login vs interactive). A bit of explanation can be found in a blog post where I explain why the PATH is injected.

Also I am curious, what exactly :ensure-system-package does. Also, do you use exec-path-from-shell?

In general, I'd say Emacs+ needs some love to make service more usable.

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

No branches or pull requests

2 participants