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

brew services cannot find plist file for installed packaged #615

Closed
Who23 opened this issue Feb 1, 2024 · 4 comments
Closed

brew services cannot find plist file for installed packaged #615

Who23 opened this issue Feb 1, 2024 · 4 comments
Labels

Comments

@Who23
Copy link

Who23 commented Feb 1, 2024

I'm attempting to update a formula for package I provide, which has a launchd service. I'm attempting to use the service stanza, but it doesn't seem to find the service file:

Currently, both of these succeed in installing. The only difference is that the plist stanza has been replaced with the service stanza.
Old version - https://github.com/Who23/homebrew-formulae/blob/master/Formula/nchook.rb
New Version:

class Nchook < Formula
include Language::Python::Virtualenv

desc "A hook for macos's notification center"
homepage "https://github.com/who23/nchook"
url "https://github.com/Who23/nchook/releases/download/0.1.1/nchook-v0.1.1.tar.gz"
sha256 "0a1e95d2ec29a8ae8840bd1965711e91fc18d91de677a85052494bdda668e563"
head "https://github.com/who23/nchook.git"

depends_on "[email protected]"
depends_on :macos => :big_sur

resource "watchdog" do
 url "https://files.pythonhosted.org/packages/17/8c/fe6b8554e6a107437375ea6f76c62fbb0deb22288c2eb846c2f92b0d843e/watchdog-2.0.2.tar.gz"
 sha256 "532fedd993e75554671faa36cd04c580ced3fae084254a779afbbd8aaf00566b"
end

resource "apsw" do
 url "https://files.pythonhosted.org/packages/b5/a1/3de5a2d35fc34939672f4e1bd7d68cca359a31b76926f00d95f434c63aaa/apsw-3.9.2-r1.tar.gz"
 sha256 "dab96fd164dde9e59f7f27228291498217fa0e74048e2c08c7059d7e39589270"
end

def caveats; <<~EOF
 Logs in:
   #{var}/log/nchook/
 EOF
end

service do
 run macos: opt_bin/"nchook"
 keep_alive true
 log_path "#{var}/log/nchook/nchook.out.log"
 error_log_path "#{var}/log/nchook/nchook.err.log"
end

def install
 virtualenv_install_with_resources
 (var/"log/nchook").mkpath
end
end

For the new version, Installation caveats seem to indicate brew services recognized the stanza:

> brew install ./new_nchook.rb
Logs in:
  /opt/homebrew/var/log/nchook/

To start nchook now and restart at login:
  brew services start nchook
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/nchook/bin/nchook

Also for the new version, a plist file is created:

> cat /opt/homebrew/opt/nchook/homebrew.mxcl.nchook.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>homebrew.mxcl.nchook</string>
	<key>LimitLoadToSessionType</key>
	<array>
		<string>Aqua</string>
		<string>Background</string>
		<string>LoginWindow</string>
		<string>StandardIO</string>
		<string>System</string>
	</array>
	<key>ProgramArguments</key>
	<array>
		<string>/opt/homebrew/opt/nchook/bin/nchook</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>StandardErrorPath</key>
	<string>/opt/homebrew/var/log/nchook/nchook.err.log</string>
	<key>StandardOutPath</key>
	<string>/opt/homebrew/var/log/nchook/nchook.out.log</string>
</dict>
</plist>

However, with new versions of homebrew, neither actually seem to work:

> brew services list
Name    Status  User   File
nchook  none    USER
....
> brew services start nchook
Error: undefined method `plist_startup' for #<Formula nchook (stable) /opt/homebrew/Library/Taps/who23/homebrew-formulae/Formula/nchook.rb>
Did you mean?  plist_name
/opt/homebrew/Library/Taps/homebrew/homebrew-services/lib/service/formula_wrapper.rb:71:in `service_startup?'
/opt/homebrew/Library/Taps/homebrew/homebrew-services/lib/service/services_cli.rb:280:in `service_load'
/opt/homebrew/Library/Taps/homebrew/homebrew-services/lib/service/services_cli.rb:122:in `block in start'
/opt/homebrew/Library/Taps/homebrew/homebrew-services/lib/service/services_cli.rb:97:in `each'
/opt/homebrew/Library/Taps/homebrew/homebrew-services/lib/service/services_cli.rb:97:in `start'
/opt/homebrew/Library/Taps/homebrew/homebrew-services/lib/service/commands/start.rb:12:in `run'
/opt/homebrew/Library/Taps/homebrew/homebrew-services/cmd/services.rb:130:in `services'
/opt/homebrew/Library/Homebrew/brew.rb:86:in `<main>'

Any advice on how I could fix this?

  • Homebrew Version: Homebrew 4.2.6-60-g0864775
  • brew doctor only reports some unbrewed files which I haven't cleaned up, but nothing to do with this package.
@MikeMcQuaid
Copy link
Member

Can you try to run brew update and try again?

Similarly, can I see the output of brew doctor, brew config and git -C $(brew --repo homebrew/services) show?

@Who23
Copy link
Author

Who23 commented Feb 3, 2024

> brew update
==> Updated Homebrew from 392cc15a7 to df32020fb.
No changes to formulae or casks.
> brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  delta
  [email protected]
  youtube-dl

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libtcl8.6.dylib
  /usr/local/lib/libtk8.6.dylib
  /usr/local/lib/libw2xc.dylib

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/fakemysql.h
  /usr/local/include/fakepq.h
  /usr/local/include/fakesql.h
  /usr/local/include/itcl.h
  /usr/local/include/itcl2TclOO.h
  /usr/local/include/itclDecls.h
  /usr/local/include/itclInt.h
  /usr/local/include/itclIntDecls.h
  /usr/local/include/itclMigrate2TclCore.h
  /usr/local/include/itclTclIntStubsFcn.h
  /usr/local/include/mysqlStubs.h
  /usr/local/include/odbcStubs.h
  /usr/local/include/pqStubs.h
  /usr/local/include/python3.7m/pygame/_camera.h
  /usr/local/include/python3.7m/pygame/_pygame.h
  /usr/local/include/python3.7m/pygame/_surface.h
  /usr/local/include/python3.7m/pygame/bitmask.h
  /usr/local/include/python3.7m/pygame/camera.h
  /usr/local/include/python3.7m/pygame/fastevents.h
  /usr/local/include/python3.7m/pygame/font.h
  /usr/local/include/python3.7m/pygame/freetype.h
  /usr/local/include/python3.7m/pygame/mask.h
  /usr/local/include/python3.7m/pygame/mixer.h
  /usr/local/include/python3.7m/pygame/palette.h
  /usr/local/include/python3.7m/pygame/pgarrinter.h
  /usr/local/include/python3.7m/pygame/pgbufferproxy.h
  /usr/local/include/python3.7m/pygame/pgcompat.h
  /usr/local/include/python3.7m/pygame/pgopengl.h
  /usr/local/include/python3.7m/pygame/pygame.h
  /usr/local/include/python3.7m/pygame/scrap.h
  /usr/local/include/python3.7m/pygame/surface.h
  /usr/local/include/tcl.h
  /usr/local/include/tclDecls.h
  /usr/local/include/tclOO.h
  /usr/local/include/tclOODecls.h
  /usr/local/include/tclPlatDecls.h
  /usr/local/include/tclThread.h
  /usr/local/include/tclTomMath.h
  /usr/local/include/tclTomMathDecls.h
  /usr/local/include/tdbc.h
  /usr/local/include/tdbcDecls.h
  /usr/local/include/tdbcInt.h
  /usr/local/include/tk.h
  /usr/local/include/tkDecls.h
  /usr/local/include/tkPlatDecls.h
  /usr/local/include/w2xconv.h

Warning: Unbrewed '.pc' files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected '.pc' files:
  /usr/local/lib/pkgconfig/tcl.pc
  /usr/local/lib/pkgconfig/tk.pc

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
  /usr/local/lib/libtclstub8.6.a
  /usr/local/lib/libtkstub8.6.a

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  six
> brew config
HOMEBREW_VERSION: 4.2.6-95-gdf32020
ORIGIN: https://github.com/Homebrew/brew
HEAD: df32020fb7dd325d2e23cf09086b757521fe4fe1
Last commit: 34 minutes ago
Core tap JSON: 03 Feb 12:46 UTC
Core cask tap JSON: 03 Feb 12:46 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 10
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 15.0.0 build 1500
Git: 2.39.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.4.0 => /usr/bin/curl
macOS: 14.2.1-arm64
CLT: 15.1.0.0.1.1700200546
Xcode: 15.2
Rosetta 2: false
> git -C $(brew --repo homebrew/services) show
commit cec47abdacbad1d17c5dedc31193c859c23a8c05 (HEAD -> master, origin/master, origin/HEAD)
Merge: d475ef7 4e38ac4
Author: Mike McQuaid <[email protected]>
Date:   Thu Feb 1 14:40:43 2024 +0000

    Merge pull request #614 from Homebrew/dependabot/bundler/diff-lcs-1.5.1

    build(deps-dev): bump diff-lcs from 1.5.0 to 1.5.1

I'm also considering just uninstalling + reinstalling all of homebrew

@Who23
Copy link
Author

Who23 commented Feb 3, 2024

Strange thing happened - I tried running the formula after running brew update again, and it worked - but then after uninstalling and reinstalling the package, I get the same undefined method plist_startup... error again

@Who23
Copy link
Author

Who23 commented Feb 3, 2024

Ah - I think I've figured out the issue, mistake on my part. I was installing the formula with my local formula file (./nchook.rb), but I was starting the service with brew services start nchook instead of brew services start ./nchook.rb. The latter works, I think the former was using the old formula and complained.

@Who23 Who23 closed this as completed Feb 3, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants