NextFire / apple-music-discord-rpc

🎵 Discord Rich Presence Client for the macOS Apple Music app and iTunes
MIT License
559 stars 37 forks source link

Homebrew service not starting #64

Closed EyadElshaer closed 3 months ago

EyadElshaer commented 1 year ago

when I play any music on the Apple Music app on the MacBook it doesn't show up on discord I tried restarting the Mac but nothing helped

NathanielH-snek commented 1 year ago

Yeah for me it only works if i manually run it in the terminal

EyadElshaer commented 1 year ago

Yeah for me it only works if i manually run it in the terminal

For me it doesn't work even if I run it in the terminal

NathanielH-snek commented 1 year ago

Are you launching it from brew or path?

EyadElshaer commented 1 year ago

Are you launching it from brew or path?

How can I know ?

NathanielH-snek commented 1 year ago

What do you type into the terminal to run it in terminal? Did you install with homebrew?

EyadElshaer commented 1 year ago

What do you type into the terminal to run it in terminal? Did you install with homebrew?

I downloaded homebrew and used the terminal to run it

NathanielH-snek commented 1 year ago

That didn't really answer but I'm assuming you didnt do anything besides copying the install command. Type: music-rpc.ts into the terminal and it should run for you

EyadElshaer commented 1 year ago

What do you type into the terminal to run it in terminal? Did you install with homebrew?

I typed what was shown in the installation commands

allycatty commented 1 year ago

I've tried installing manually and with brew in every way I could on multiple macs, tried upgrading deno, no luck whatsoever. Are we supposed to create an application in the discord dev portal? Or is it possibly and issue with the change in Discord username discriminators?

NathanielH-snek commented 1 year ago

I've tried installing manually and with brew in every way I could on multiple macs, tried upgrading deno, no luck whatsoever.

Are we supposed to create an application in the discord dev portal? Or is it possibly and issue with the change in Discord username discriminators?

Have you tried launching the application manually the way I mentioned above. It works, I think the problem is the automatic script to have it launch on startup. Probably broken by macOS at some point.

NextFire commented 1 year ago

@EyadElshaer If you installed it with Homebrew, check that the script is running fine on a manual run with music-rpc.ts in the terminal as @NathanielH-snek suggested.

@allycatty The script should run as it is and works fine with the new username system.

If you encounter some issues with the launch agent, try the troubleshooting steps in https://github.com/NextFire/apple-music-discord-rpc/issues/51. If it is not working at all, please ensure that activity sharing is well enabled in your Discord client settings.

mjcarvin commented 1 year ago

I'm running into the same problem. I went through the troubleshooting steps here and in #51 ...

  1. manually running music-rpc.ts from the terminal works and activity sharing is turned on in Discord.

  2. brew services output

Name                    Status       User    File
apple-music-discord-rpc error  19968 michael ~/Library/LaunchAgents/homebrew.mxcl.apple-music-discord-rpc.plist
  1. brew services info apple-music-discord-rpc output
brew services info apple-music-discord-rpc
apple-music-discord-rpc (homebrew.mxcl.apple-music-discord-rpc)
Running: ✘
Loaded: ✔
Schedulable: ✘
  1. brew services start apple-music-discord-rpc output
brew services start apple-music-discord-rpc
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/michael/Library/LaunchAgents/homebrew.mxcl.apple-music-discord-rpc.plist` exited with 5.
  1. File permissions
-rw-r--r--   1 michael  staff   953 Jun 13 11:59 homebrew.mxcl.apple-music-discord-rpc.plist
NextFire commented 1 year ago

@mjcarvin Do you happen to use an Apple Silicon Mac?

mjcarvin commented 1 year ago

No, Intel MBP - skylake from 2016.

NextFire commented 1 year ago

I've updated the formula which previously had a linting issue https://github.com/NextFire/homebrew-tap/commit/093eb083a746c0e1ffae232f6ddb079341df7db2. I am not sure that it will resolve this issue but can you brew update && brew reinstall nextfire/tap/apple-music-discord-rpc && brew services restart nextfire/tap/apple-music-discord-rpc and check brew services info apple-music-discord-rpc again?

NathanielH-snek commented 1 year ago

I do run an AS mac and I'm having the same issue although I haven't spent a lot of time troubleshooting. I'll see if I can figure it out later.

mjcarvin commented 1 year ago

I've updated the formula which previously had a linting issue https://github.com/NextFire/homebrew-tap/commit/093eb083a746c0e1ffae232f6ddb079341df7db2. I am not sure that it will resolve this issue but can you brew update && brew reinstall nextfire/tap/apple-music-discord-rpc && brew services restart nextfire/tap/apple-music-discord-rpc and check brew services info apple-music-discord-rpc again?

brew services info apple-music-discord-rpc

apple-music-discord-rpc (homebrew.mxcl.apple-music-discord-rpc)
Running: ✘
Loaded: ✔
Schedulable: ✘
brew services

Name                    Status       User    File
apple-music-discord-rpc error  19968 michael ~/Library/LaunchAgents/homebrew.mxcl.apple-music-discord-rpc.plist
sleepwatcher            started      michael ~/Library/LaunchAgents/homebrew.mxcl.sleepwatcher.plist
NextFire commented 1 year ago

@mjcarvin Can you paste the content of the generated launch agent?

mjcarvin commented 1 year ago
{
    EnvironmentVariables = {
        PATH = "/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin";
    };
    KeepAlive = YES;
    Label = "homebrew.mxcl.apple-music-discord-rpc";
    "LimitLoadToSessionType" = (
        Aqua,
        Background,
        LoginWindow,
        StandardIO,
        System,
    );
    ProgramArguments = (
        "/usr/local/opt/apple-music-discord-rpc/bin/music-rpc.ts",
    );
    RunAtLoad = YES;
    StandardErrorPath = "/Users/michael/music-rpc.log";
    WorkingDirectory = "/usr/local/var/apple-music-discord-rpc";
}

That PATH looks really short compared to echo $PATH

/Users/michael/.gem/bin:/usr/local/opt/ruby/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/michael/Development/flutter/bin:/usr/local/opt/:/Users/michael/Library/Android/sdk/platform-tools:/Users/michael/Library/Android/sdk/tools:/Users/michael/Library/Android/sdk/tools/bin:/Users/michael/Library/Android/sdk/emulator
NextFire commented 1 year ago

Is it the raw content of your .plist? Should have been some XML. The PATH is fine if it contains at least osascript and deno (check with which). Then if both /usr/local/opt/apple-music-discord-rpc/bin/music-rpc.ts and /usr/local/var/apple-music-discord-rpc exist, I don't see any reason for it not working... :/ (The music-rpc.log should have been located in /usr/local/var/apple-music-discord-rpc, not in the home root, I'll fix that at least...)

mjcarvin commented 1 year ago

That was the raw content. Here's the xml:

<?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>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin</string>
    </dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>homebrew.mxcl.apple-music-discord-rpc</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>/usr/local/opt/apple-music-discord-rpc/bin/music-rpc.ts</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/Users/michael/music-rpc.log</string>
    <key>WorkingDirectory</key>
    <string>/usr/local/var/apple-music-discord-rpc</string>
</dict>
</plist>

which osascript and which deno return good paths, so that's fine.

music-rpc.ts is in /usr/local/opt/apple-music-discord-rpc/bin/ and running it manually from my home root works fine.

This is not right on my end

from the xml

<key>WorkingDirectory</key>
    <string>/usr/local/var/apple-music-discord-rpc</string>
ls -la /usr/local/var

total 0
drwxrwxr-x   4 michael  admin  128 May 20 14:22 .
drwxr-xr-x  14 root     wheel  448 May 20 14:02 ..
drwxrwxr-x   4 michael  admin  128 May 20 14:10 homebrew
drwxr-xr-x   3 michael  admin   96 May 20 14:22 run
NextFire commented 1 year ago

/usr/local/var/apple-music-discord-rpc is automatically created when the service starts (re-checked on my side) so no problem here

NextFire commented 1 year ago

I guess I'm out of answer, there may be a bug in homebrew/services. As a last resort can you try the shell scripts install method in the README? You may have better luck here...

mjcarvin commented 1 year ago

/usr/local/var/apple-music-discord-rpc is automatically created when the service starts (re-checked on my side) so no problem here

Huh. I don't see it in my /usr/local/var folder.

As a last resort can you try the shell scripts install method in the README? You may have better luck here...

I just did and it started right up when I ran the install script.

Thanks for making the time to help diagnose this. I really appreciate it.

NextFire commented 1 year ago

Huh. I don't see it in my /usr/local/var folder.

Yeah somehow Homebrew couldn't even start its generated launch agent...

I just did and it started right up when I ran the install script.

Perfect!

Thanks for making the time to help diagnose this. I really appreciate it.

You're welcome! Thank you for your quick replies.