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

ENOENT error on startup #1

Open
CooperCGN opened this issue Feb 19, 2023 · 28 comments
Open

ENOENT error on startup #1

CooperCGN opened this issue Feb 19, 2023 · 28 comments
Labels
bug Something isn't working

Comments

@CooperCGN
Copy link

CooperCGN commented Feb 19, 2023

Describe The Bug:

Plugin throws ENOENT on startup, seems it can't find atvscript which is installed under ~/.local/bin and e.g. can be called from the pi users SSH-login prompt.

To Reproduce:

Expected behavior:

Logs:

[19/02/2023, 06:52:04] [@hujohner/homebridge-appletv] Restarting Process...
[19/02/2023, 06:52:06] [@hujohner/homebridge-appletv] Launched child bridge with PID 16780
[19/02/2023, 06:52:06] Registering platform '@hujohner/homebridge-appletv.AppleTV'
[19/02/2023, 06:52:06] [@hujohner/homebridge-appletv] Loaded @hujohner/homebridge-appletv v1.1.0 child bridge successfully
[19/02/2023, 06:52:06] Loaded 1 cached accessories from cachedAccessories.0EBA39873C8C.
[19/02/2023, 06:52:06] [@hujohner/homebridge-appletv] Loading accessory from cache: ATV4K
[19/02/2023, 06:52:06] [@hujohner/homebridge-appletv] Restoring existing accessory from cache: ATV4K
[19/02/2023, 06:52:06] Homebridge v1.6.0 (HAP v0.11.0) (@hujohner/homebridge-appletv) is running on port 53459.
Error: spawn atvscript ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
[19/02/2023, 06:52:06] [@hujohner/homebridge-appletv] Child bridge process ended
[19/02/2023, 06:52:06] [@hujohner/homebridge-appletv] Process Ended. Code: 1, Signal: null

Plugin Config:

{
    "devices": [
        {
            "name": "ATV4K",
            "host": "10.0.1.XXX",
            "credentials": "redacted",
            "device_state_sensors": [
                "idle",
                "paused",
                "playing"
            ]
        }
    ],
    "platform": "AppleTV",
    "_bridge": {
        "username": "0E:BA:39:87:3C:8C",
        "port": 53459
    }
}

Screenshots:

Environment:

  • Plugin Version: 1.1.0
  • Homebridge Version: 1.6.0
  • Node.js Version: 18.14.0
  • NPM Version: 9.3.1
  • Operating System: Raspbian Bullseye / hb-service
@CooperCGN CooperCGN added the bug Something isn't working label Feb 19, 2023
@HuJohner
Copy link
Owner

Did you install PyATV using sudo?

@CooperCGN
Copy link
Author

Tried that already, while it runs I get a long error thrown that it can’t compile cryptography despite I installed Rust as recommended.

@HuJohner
Copy link
Owner

HuJohner commented Feb 19, 2023

Yeah I had that too. Can't remember exactly what fixed it but I thought it was installing rust...

What is the exact error installing cryptography?

@CooperCGN
Copy link
Author

So here is what I did:

  1. sudo apt-get install build-essential libssl-dev libffi-dev python-dev
  2. sudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Checking if Rust is installed: rustc --version -> rustc 1.67.1 (d5a82bbd2 2023-02-07)

  1. sudo pip install pyatv

Result attached in the text file

errorlog.txt

@sbuchart
Copy link

I have the exact same error. Plugin throws ENOENT on startup. I run Homebridge on a raspberry pi 4. I used the built in terminal of Homebridge and installed all prerequisites including obtaining the credentials for the Apple TV. All worked perfectly. I added the IP address and credentials to the plugin. When I restarted Homebridge, I get the same ENOENT error.

@joelwetzel
Copy link
Contributor

Same error here. I got pyatv installed and paired, so I got a credentials string. But on startup of Homebridge, the plugin just repeatedly throws the same error. I had to manually clean out my config.json to get it to stop.

Oh, this is on a RaspberryPi running the official RPi Homebridge image.

@sbuchart
Copy link

Here is exactly what Homebridge log shows on startup of this plugin. Seems it can’t find something:
[19/02/2023, 17:41:40] [@hujohner/homebridge-appletv] Restarting Process...
[19/02/2023, 17:41:41] [@hujohner/homebridge-appletv] Launched child bridge with PID 3179
[19/02/2023, 17:41:41] Registering platform '@hujohner/homebridge-appletv.AppleTV'
[19/02/2023, 17:41:41] [@hujohner/homebridge-appletv] Loaded @hujohner/homebridge-appletv v1.1.0 child bridge successfully
[19/02/2023, 17:41:41] Loaded 1 cached accessories from cachedAccessories.0E24986CBBCD.
[19/02/2023, 17:41:41] [@hujohner/homebridge-appletv] Loading accessory from cache: Family Room Apple TV
[19/02/2023, 17:41:41] [@hujohner/homebridge-appletv] Restoring existing accessory from cache: Family Room Apple TV
Error: spawn atvscript ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
[19/02/2023, 17:41:41] [@hujohner/homebridge-appletv] Child bridge process ended
[19/02/2023, 17:41:41] [@hujohner/homebridge-appletv] Process Ended. Code: 1, Signal: null
[19/02/2023, 17:41:48] [@hujohner/homebridge-appletv] Restarting Process...
[19/02/2023, 17:41:50] [@hujohner/homebridge-appletv] Launched child bridge with PID 3198
[19/02/2023, 17:41:50] Registering platform '@hujohner/homebridge-appletv.AppleTV'
[19/02/2023, 17:41:50] [@hujohner/homebridge-appletv] Loaded @hujohner/homebridge-appletv v1.1.0 child bridge successfully
[19/02/2023, 17:41:50] Loaded 1 cached accessories from cachedAccessories.0E24986CBBCD.
[19/02/2023, 17:41:50] [@hujohner/homebridge-appletv] Loading accessory from cache: Family Room Apple TV
[19/02/2023, 17:41:50] [@hujohner/homebridge-appletv] Restoring existing accessory from cache: Family Room Apple TV
Error: spawn atvscript ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:82:21)

@sbuchart
Copy link

Note that it will repeatedly show the above error endlessly.

@HuJohner
Copy link
Owner

It appears something is wrong with atvscript... can you guys try running atvscript manually? I don't think there is a version command but just to see if it is accessible from root

@HuJohner
Copy link
Owner

Is everyone that is having this problem running it as a child bridge?

@sbuchart
Copy link

Exact same error, whether in bridge mode or not. If it is not in bridge mode, Homebridge itself keeps restarting over and over again with the exact same error. If it is in bridge mode, then only that bridge restarts over and over again.

@joelwetzel
Copy link
Contributor

Yes, I am able to run atvscript manually.

@sbuchart
Copy link

If I SSH into the raspberry pi that is running Home Ridge, I can run atvscript. However, if I use the terminal from within home bridge, it cannot find atvscript and errors out.

@HuJohner
Copy link
Owner

If I SSH into the raspberry pi that is running Home Ridge, I can run atvscript. However, if I use the terminal from within home bridge, it cannot find atvscript and errors out.

I think this is the issue. It seems like PyATV is installed locally in your ssh users directory rather than in root for all to access. Installing it using sudo should fix this

@CooperCGN
Copy link
Author

CooperCGN commented Feb 20, 2023

I just tried the following: took a fresh SD Card with a core Bullseye OS on it. Updated everything, installed the required dependencies and python, no homebridge. Installed the Rust toolchain as sudo. Then tried to install pyatv again first with sudo pip install pyatv and it failed again because it couldn't find the Rust compiler. Then I tried pip install pyatv and it worked.

So question is, how do I give root access to the Rust compiler?

@joelwetzel
Copy link
Contributor

joelwetzel commented Feb 20, 2023

Ok, I have a solution.

For homebridge to access it, we need to install pyatv as sudo.

But that means sudo needs access to the rust compiler.

So here’s what I did:

  • Install rust as normal: curl https://sh.rustup.rs -sSf | sh
  • To find out where rust was installed, I ran “whereis rustc”. Rust tools were installed here: /home/pi/.cargo/bin
  • I then edited the file /etc/sudoers. I added my rust path to the secure_path variable and saved.
  • I then tried to run “sudo rustc —version”. It told me to run rustup with a few parameters. I made sure to do so as sudo. After that, I was able to run rustc as sudo.
  • And then I could “sudo pip3 install pyatv”
  • And then the plug-in worked!

@joelwetzel
Copy link
Contributor

To be honest, I don’t know if that’s the BEST way to get rust working for sudo. But it did work.

@CooperCGN
Copy link
Author

CooperCGN commented Feb 20, 2023

To be honest, I don’t know if that’s the BEST way to get rust working for sudo.

who cares, you're a genius. At least the plugin is now starting up. I got it working in HomeKit somewhat too.

Iust have some weird stuff going on in HomeKit. The switch for waking up the ATV is turning itself off shortly after using it. If I then turn it on again it stays on. Maybe some timeout problem, also I am already on the new HomeKit architecture.

And the idle sensor is not triggered after waking up the Apple TV.

@jianyu-li
Copy link

Ok, I have a solution.

For homebridge to access it, we need to install pyatv as sudo.

But that means sudo needs access to the rust compiler.

So here’s what I did:

  • Install rust as normal: curl https://sh.rustup.rs -sSf | sh

  • To find out where rust was installed, I ran “whereis rustc”. Rust tools were installed here: /home/pi/.cargo/bin

  • I then edited the file /etc/sudoers. I added my rust path to the secure_path variable and saved.

  • I then tried to run “sudo rustc —version”. It told me to run rustup with a few parameters. I made sure to do so as sudo. After that, I was able to run rustc as sudo.

  • And then I could “sudo pip3 install pyatv”

  • And then the plug-in worked!

can you show what your secure_path variable looks like?

@CooperCGN
Copy link
Author

Here’s mine

secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/pi/.cargo/bin"

@jianyu-li
Copy link

jianyu-li commented Feb 20, 2023

Just want to add onto this (thanks for the write up @joelwetzel !) for those of us that are new to some of these steps

  1. Install rust as normal: curl https://sh.rustup.rs/ -sSf | sh
  2. To find out where rust was installed, I ran “whereis rustc”. Rust tools were installed here: /home/pi/.cargo/bin
  3. I then edited the file /etc/sudoers. I added my rust path to the secure_path variable and saved.
  4. To do this, use sudo nano /etc/sudoers then use your arrow keys to go to the secure_path variable and add /home/pi/.cargo/bin so it looks like the path referenced by CooperCGN
  5. Use ctrl X to exit and press enter to save at the exit confirmation
  6. I then tried to run “sudo rustc —version”. It told me to run rustup with a few parameters. I made sure to do so as sudo. After that, I was able to run rustc as sudo.
  7. The command referenced here is sudo rustup default stable you should be able to run sudo rustc --version now to make sure it worked
  8. And then I could “sudo pip3 install pyatv”

And then the plug-in worked!

@sbuchart
Copy link

Your solution worked! Thank you.

@dustinbrownman
Copy link

FWIW, after having installing it without sudo and getting this same error, I tried just sudo pip install pyatv and it worked. I'm dealing with a very fresh install of Homebridge on a Raspberry Pi 2. Also, during the initial install, I noticed that I couldn't actually run atvremote (or other commands) until I added /home/pi/.local/bin it to my PATH in ~/.bashrc. Hope this is helpful for other checking this out. Also very excited to try this plugin out further!

@icho911
Copy link

icho911 commented Mar 21, 2023

Got the same error. Running pyatv as container on a Synology NAS. Not sure how to solve this.

@linkx2252
Copy link

Can anyone walk me through how to fix this on a macOS homebridge?

@DSimeone1989
Copy link

DSimeone1989 commented Jul 5, 2023

Dear all,
made all of the steps and ran sudo rustup default stable
Version of rust globally is 1.48.0

How do I update rust globally.

dsimeone@homebridge:~ $ sudo rustc --version
rustc 1.48.0 (471d696c7 2020-12-10)
dsimeone@homebridge:~ $ sudo rustup update
info: syncing channel updates for 'stable-armv7-unknown-linux-gnueabihf'
error: rustup is not installed at '/root/.cargo'

Can anybody help?
Thanks.

@DSimeone1989
Copy link

Dear all,

This is what I get:

dsimeone@homebridge:~ $ sudo rustup update
info: syncing channel updates for 'stable-armv7-unknown-linux-gnueabihf'
info: latest update on 2023-08-03, rust version 1.71.1 (eb26296b5 2023-08-03)
info: downloading component 'cargo'
6.5 MiB / 6.5 MiB (100 %) 4.7 MiB/s in 2s ETA: 0s
info: downloading component 'clippy'
info: downloading component 'rust-docs'
13.6 MiB / 13.6 MiB (100 %) 6.3 MiB/s in 3s ETA: 0s
info: downloading component 'rust-std'
23.1 MiB / 23.1 MiB (100 %) 6.3 MiB/s in 6s ETA: 0s
info: downloading component 'rustc'
74.6 MiB / 74.6 MiB (100 %) 6.4 MiB/s in 16s ETA: 0s
info: downloading component 'rustfmt'
info: removing previous version of component 'cargo'
info: removing previous version of component 'clippy'
info: removing previous version of component 'rust-docs'
info: removing previous version of component 'rust-std'
info: removing previous version of component 'rustc'
info: removing previous version of component 'rustfmt'
info: installing component 'cargo'
6.5 MiB / 6.5 MiB (100 %) 5.5 MiB/s in 1s ETA: 0s
info: installing component 'clippy'
info: installing component 'rust-docs'
13.6 MiB / 13.6 MiB (100 %) 460.8 KiB/s in 50s ETA: 0s
info: installing component 'rust-std'
23.1 MiB / 23.1 MiB (100 %) 4.2 MiB/s in 15s ETA: 0s
info: installing component 'rustc'
74.6 MiB / 74.6 MiB (100 %) 3.2 MiB/s in 40s ETA: 0s
8 IO-ops / 8 IO-ops (100 %) 0 IOPS in 3s ETA: Unknown
info: installing component 'rustfmt'
error: rustup is not installed at '/root/.cargo'
dsimeone@homebridge:~ $

Whereis:
dsimeone@homebridge:~ $ whereis rustc
rustc: /usr/bin/rustc /usr/share/rustc /home/dsimeone/.cargo/bin/rustc /usr/share/man/man1/rustc.1.gz
dsimeone@homebridge:~ $

It‘s enclosed in in sudo nano /etc/sudoers:
secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/dsimeone/.cargo/bin"

I do Not get it.
What am I missing?

Thanks

@tetanus
Copy link

tetanus commented Sep 4, 2023

I followed @jianyu-li’s instruction but I’m still getting the error and the plugin crashes Homebridge repeatedly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants