dresdner353 / mpd2chromecast

Simple Python script to get MPD-based streaming platforms such as Volumio, moOde to stream audio to a Chromecast device or multi-room group
MIT License
49 stars 9 forks source link

Username error mooode 8.3.9 #11

Open ajaykay opened 2 months ago

ajaykay commented 2 months ago

I'm running into this error when installing on a fresh image of moOde 8.3.9 Raspberry Pi 4b.

Installing mpd2chromecast user:pi pwd:/home/pi Downloading mpd2chromecast... environment: line 4: git: command not found purging old crontab entries Systemd steps for ~/home/pi/mpd2chromecast/mpd2chromecast.service sed: can't read /home/pi/mpd2chromecast/mpd2chromecast.service: No such file or directory Failed to enable unit: Unit file /etc/systemd/system/mpd2chromecast.service is masked. Failed to restart mpd2chromecast.service: Unit mpd2chromecast.service is masked.

ransur0t commented 2 months ago

"line 4: git: command not found"

Install git ...

ajaykay commented 2 months ago

Sorry I shouldn't have included that, it was from an older attempt. The issue is with the username, here's the install log:

Requirement already satisfied: zipp>=0.5 in /usr/lib/python3/dist-packages (from importlib-metadata>=3.6->typeguard>=4.0.1->inflect->jaraco.text->jaraco.collections->cherrypy) (1.0.0 )
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from zc.lockfile->cherrypy) (52.0.0)
Building wheels for collected packages: zeroconf
Building wheel for zeroconf (PEP 517) ... done
Created wheel for zeroconf: filename=zeroconf-0.132.2-cp39-cp39-manylinux_2_31_aarch64.whl size=8874461 sha256=2005f4e927ade18c2631e4967209136cc2e201b1ea26ec718d4633746eeb6ccf
Stored in directory: /root/.cache/pip/wheels/b4/27/17/f5267620b1ccc4c5d29a896b88954db6dcb1bac552146dfda6
Successfully built zeroconf
Installing collected packages: typing-extensions, importlib-metadata, typeguard, backports.tarfile, pytz, jaraco.functools, jaraco.context, inflect, autocommand, tempora, jaraco.text , ifaddr, zeroconf, zc.lockfile, protobuf, portend, jaraco.collections, cheroot, casttube, pychromecast, cherrypy
Attempting uninstall: typing-extensions
Found existing installation: typing-extensions 3.7.4.3
Not uninstalling typing-extensions at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'typing-extensions'. No files were found to uninstall.
Attempting uninstall: importlib-metadata
Found existing installation: importlib-metadata 1.6.0
Not uninstalling importlib-metadata at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'importlib-metadata'. No files were found to uninstall.
Successfully installed autocommand-2.2.2 backports.tarfile-1.1.0 casttube-0.2.1 cheroot-10.0.0 cherrypy-18.9.0 ifaddr-0.2.0 importlib-metadata-7.1.0 inflect-7.2.0 jaraco.collections- 5.0.1 jaraco.context-5.3.0 jaraco.functools-4.0.1 jaraco.text-3.12.0 portend-3.2.0 protobuf-5.26.1 pychromecast-13.1.0 pytz-2024.1 tempora-5.5.1 typeguard-4.2.1 typing-extensions-4.1 1.0 zc.lockfile-3.0.post1 zeroconf-0.132.2
su: user pi does not exist or the user entry does not contain all the required fields
Systemd steps for ~/home/pi/mpd2chromecast/mpd2chromecast.service
sed: can't read /home/pi/mpd2chromecast/mpd2chromecast.service: No such file or directory
Failed to enable unit: Unit file /etc/systemd/system/mpd2chromecast.service is masked.
Failed to restart mpd2chromecast.service: Unit mpd2chromecast.service is masked.

papampi commented 3 weeks ago

Made some changes in https://github.com/dresdner353/mpd2chromecast/pull/12 that should fix the issue. In the meantime until it merges you can use my fork: https://github.com/papampi/mpd2chromecast

ajaykay commented 3 weeks ago

Still no joy with your fork, i'm root user (not pi, as there seems to be no user pi in moode?!)

Downloading or updating mpd2chromecast...
fatal: could not create work tree dir '/mpd2chromecast': Permission denied

papampi commented 3 weeks ago

Still no joy with your fork, i'm root user (not pi, as there seems to be no user pi in moode?!)

Downloading or updating mpd2chromecast... fatal: could not create work tree dir '/mpd2chromecast': Permission denied

My fork doesn't care what's the user, pi, volumio, moode, alex, ... But I have not tested it with root user.

It looks like its trying to install on /mpd2chromecast and not /root/mpd2chromecast Let me make some changes for root user.

papampi commented 3 weeks ago

@ajaykay Try this patch and let me know:

curl -s https://raw.githubusercontent.com/papampi/mpd2chromecast/papampi-patch-1/install.sh | sudo bash

ajaykay commented 3 weeks ago

As far as I can see the latest moode build doesn't have a built in user, just the one you create when you set it up. So my username is the only one on the device when I list it apart from 'root'.

atl@moode:~ $ curl -s https://raw.githubusercontent.com/papampi/mpd2chromecast/papampi-patch-1/install.sh | sudo bash The script is running as root user. Detected User:atl Detected User Home:/home/atl Installing mpd2chromecast user: pwd: Downloading or updating mpd2chromecast... fatal: could not create work tree dir '/mpd2chromecast': Permission denied purging old crontab entries Hit:1 http://security.debian.org/debian-security bullseye-security InRelease Hit:2 http://deb.debian.org/debian bullseye InRelease Hit:3 http://archive.raspberrypi.org/debian bullseye InRelease Get:4 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB] Get:5 https://dl.cloudsmith.io/public/moodeaudio/m8y/deb/raspbian bullseye InRelease [5,199 B] Fetched 49.3 kB in 2s (28.2 kB/s) Reading package lists... Done Reading package lists... Done Building dependency tree... Done Reading state information... Done python3-pip is already the newest version (20.3.4-4+rpt1+deb11u1). 0 upgraded, 0 newly installed, 0 to remove and 59 not upgraded. bash: line 68: cd: /home/atl/mpd2chromecast: No such file or directory

papampi commented 3 weeks ago

I installed with this script on latest yesterday. Some thing is strange it detects user and set home directory:

Detected User:atl
Detected User Home:/home/atl

But later it shows them empty : Installing mpd2chromecast user: pwd:

Let me check and make some changes.

papampi commented 3 weeks ago

@ajaykay Found and fixed it, has forgotten to export variables. Should be ok now, test the patch again.

ajaykay commented 3 weeks ago

Perfect! All looks good to me.

_atl@moode:~ $ curl -s https://raw.githubusercontent.com/papampi/mpd2chromecast/papampi-patch-1/install.sh | sudo bash The script is running as root user. Detected User:atl Detected User Home:/home/atl Installing mpd2chromecast user:atl pwd:/home/atl Downloading or updating mpd2chromecast... Cloning into '/home/atl/mpd2chromecast'... remote: Enumerating objects: 651, done. remote: Counting objects: 100% (103/103), done. remote: Compressing objects: 100% (52/52), done. remote: Total 651 (delta 82), reused 51 (delta 51), pack-reused 548 Receiving objects: 100% (651/651), 2.04 MiB | 1.48 MiB/s, done. Resolving deltas: 100% (403/403), done. purging old crontab entries Hit:1 http://security.debian.org/debian-security bullseye-security InRelease Hit:2 http://deb.debian.org/debian bullseye InRelease Hit:3 http://archive.raspberrypi.org/debian bullseye InRelease Hit:4 http://deb.debian.org/debian bullseye-updates InRelease Get:5 https://dl.cloudsmith.io/public/moodeaudio/m8y/deb/raspbian bullseye InRelease [5,199 B] Fetched 5,199 B in 2s (3,037 B/s) Reading package lists... Done Reading package lists... Done Building dependency tree... Done Reading state information... Done python3-pip is already the newest version (20.3.4-4+rpt1+deb11u1). 0 upgraded, 0 newly installed, 0 to remove and 59 not upgraded.

Usage: pip3 install [options] [package-index-options] ... pip3 install [options] -r [package-index-options] ... pip3 install [options] [-e] ... pip3 install [options] [-e] ... pip3 install [options] <archive url/path> ...

no such option: --break-system-packages Systemd steps for /home/atl/mpd2chromecast/mpd2chromecast.service Created symlink /etc/systemd/system/multi-user.target.wants/mpd2chromecast.service → /etc/systemd/system/mpd2chromecast.service. _

papampi commented 3 weeks ago

no such option: --break-system-packages

It seems like it couldn't install requirements.txt with pip Does it working ok?

ajaykay commented 3 weeks ago

All seems fine to me, MPD and URL streams work 👍

Big thanks!

ajaykay commented 3 weeks ago

Upgraded to moode v.9.02 from v8 and it's broken whatever the fix was.

Installed git, then the original mpd2chromecast, then your fix, and it returns:

The script is running as root user. Detected User: atl Detected User Home: /home/atl environment: line 0: cd: /home/atl: No such file or directory Hit:1 http://deb.debian.org/debian bookworm InRelease Hit:2 http://archive.raspberrypi.com/debian bookworm InRelease Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease Hit:4 http://deb.debian.org/debian bookworm-updates InRelease Get:5 https://dl.cloudsmith.io/public/moodeaudio/m8y/deb/raspbian bookworm InRelease [9,612 B] Fetched 9,612 B in 2s (6,344 B/s) Reading package lists... Done Reading package lists... Done Building dependency tree... Done Reading state information... Done Calculating upgrade... Done The following packages have been kept back: chromium-browser chromium-browser-l10n chromium-codecs-ffmpeg-extra linux-headers-rpi-2712 linux-headers-rpi-v8 linux-image-rpi-2712 linux-image-rpi-v8 shairport-sync upmpdcli 0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded. Reading package lists... Done Building dependency tree... Done Reading state information... Done python3-pip is already the newest version (23.0.1+dfsg-1+rpt1). 0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded. bash: line 74: cd: /home/atl/mpd2chromecast: No such file or directory atl@moode:/$

papampi commented 3 weeks ago

Are you sure you are running this command: curl -s https://raw.githubusercontent.com/papampi/mpd2chromecast/master/install.sh | sudo bash

I just tried it on 9.0.2 and installed with no problem.

ajaykay commented 3 weeks ago

Yes, see the full log. Looking at it I'm not sure if something is screwy with my install as it can't CH to the home dir.

Last login: Fri Jun 14 13:49:57 2024 from 192.168.1.160 Could not chdir to home directory /home/atl: No such file or directory atl@moode:/$ curl -s https://raw.githubusercontent.com/papampi/mpd2chromecast/master/install.sh | sudo bash The script is running as root user. Detected User: atl Home: /home/atl environment: line 0: cd: /home/atl: No such file or directory Hit:1 http://deb.debian.org/debian bookworm InRelease Hit:2 http://deb.debian.org/debian-security bookworm-security InRelease Hit:3 http://archive.raspberrypi.com/debian bookworm InRelease Hit:4 http://deb.debian.org/debian bookworm-updates InRelease Get:5 https://dl.cloudsmith.io/public/moodeaudio/m8y/deb/raspbian bookworm InRelease [9,612 B] Fetched 9,612 B in 1s (6,656 B/s) Reading package lists... Done Reading package lists... Done Building dependency tree... Done Reading state information... Done Calculating upgrade... Done The following packages have been kept back: chromium-browser chromium-browser-l10n chromium-codecs-ffmpeg-extra linux-headers-rpi-2712 linux-headers-rpi-v8 linux-image-rpi-2712 linux-image-rpi-v8 shairport-sync upmpdcli 0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded. Reading package lists... Done Building dependency tree... Done Reading state information... Done python3-pip is already the newest version (23.0.1+dfsg-1+rpt1). 0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded. bash: line 78: cd: /home/atl/mpd2chromecast: No such file or directory atl@moode:/$

papampi commented 3 weeks ago

So you are logged in with user atl but there is no /home/atl folder?

ajaykay commented 3 weeks ago

Correct. I don't even know at this stage. Tried via putty and web ssh. Same thing.

Will try and reflash from scratch.

papampi commented 3 weeks ago

Add home directory for your user mkdir /home/atl

ajaykay commented 3 weeks ago

Nada, tried adding both dirs via sudo, /home/atl and /home/atl/mpd2chromecast

0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded. ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' Setting up systemd service for mpd2chromecast sed: can't read /home/atl/mpd2chromecast/mpd2chromecast.service: No such file or directory Failed to enable unit: Unit file /etc/systemd/system/mpd2chromecast.service is masked. Failed to restart mpd2chromecast.service: Unit mpd2chromecast.service is masked. mpd2chromecast installation and setup complete. atl@moode:/$

papampi commented 3 weeks ago

Try to reflash 9.0.2 ... seems like that's easier than debugging this problem

ajaykay commented 3 weeks ago

Not to self - never do an in place upgrade.

All sorted, once again.

dresdner353 commented 1 day ago

Hi folks, sorry I'm late to party here. I never get notifications from github on these issues etc.

I'm flashing a fresh image now from the latest bookworm image for moode and will go through the install and sort out any issues it has.

The original install.sh probed detection of moode and volumio files and then toggled between there being a pi user (moode) or volumio user. Then it goes from there in running a sed on the service file to customise the install location (home dir) as it runs the mpd2chromecast agent as this non-root user.

I'll try and rework it as required so that it just works again.

papampi commented 1 day ago

@dresdner353 I already made some changes and improvements in this PR: https://github.com/dresdner353/mpd2chromecast/pull/12

dresdner353 commented 1 day ago

Thanks for the submissions. I took a different approach as your changes were likely to do some damage with the pip3 breakage.

so the cron stuff was removed.. that was ancient stuff I had done with running this script from cron and was trying to undo that config for someone upgrading... at this stage, it can be taken out.

So the user git commands are pure rm -rf and git clone as before. No pull attempts.

the package installs are pure direct python pre-built packages as they do not want the pip approach any longer with the rpi.. thankfully all I need is there in apt and just added git as you had done. No need to test git.. install the package, if its there already no harm done.

apt-get update apt-get -y install git python3-cherrypy3 python3-mpd2 python3-pychromecast

Lastly the sed updates on the service record had to be bit smarter as they needed to sub a user and home directory.. the old approach in that template was assuming the home was in /home and really that can't be done any longer. The user could be anywhere now given this new model

sed -e "s%USER%${HOME_USER}%g" \ -e "s%HOME%${HOME_DIR}%g" \ ${HOME_DIR}/mpd2chromecast/mpd2chromecast.service >/tmp/mpd2chromecast.service

Thanks for all the troubleshooting you went through and apologies for not being able to chime in earlier. I'll do more testing on moode tonight and tackle volumio tomorrow.. thats always got some more nonsense to address

dresdner353 commented 16 hours ago

Changes now made for Volumio, tested (painfully) and pushed.

Volumio as usual lags behind on rpi images. So the new changes now source the /etc/os-release file to get the ${VERSION_ID} env var... if that is >= 12 (Bookworm or later), it pulls in packages from apt only. Not sure if the intention of the /etc/os-release is to act as an env file, but it most definitely works that way when sourced.

For everything else (Volumio or older Moode installs), it will detect the VERSION_ID < 12, pull in python, pip3 and git only from apt and use pip then for the python modules installation.

In fairness, the new approach of pushing the official apt packages is just much faster with the install now happening quite quickly on Bookworm (the apt-get update is the slowest part of that).

The pip approach takes a ridiculuously long time on my pi4 between whatever it's doing to pull the module code and probably compiling some of the Python C-source code along the way. Even to move to a pyenv approach here would get worse again as we'd end up compiling Python from scratch on the rpi.

The new changes to make things play nice between Moode and Volumio or more correctly Bookworm versus older Raspi-OS versions:

# source the /etc/os-release file to 
# collect various platform variables
. /etc/os-release

# refresh package sources
apt-get update

if [ "${VERSION_ID}" -ge "12" ]
then
    # install all packages from apt
    # bookworm and presumably beyond
    echo "Performing Bookworm or later package install (all from apt)"
    apt-get -y install git python3-pip python3-cherrypy3 python3-mpd2 python3-pychromecast
else
    # everything prior to bookworm
    # git, python/pip from apt and pip for the modules
    echo "Performing pre-Bookworm install (pip3 for python modules)"
    apt-get -y install git python3-pip 
    pip3 install pychromecast cherrypy python-mpd2
fi