Trying to install both Mycroft-Core and MagicMirror on the same PI

First off, I’m a noob. Second, I do have some basic skills and have googled to death every error that pops up. But this one has stymied me. After installing MagicMirror and getting it working exactly like I want, I really want to add Mycroft to the Mirror build as my AI.

So, because I’m on Debian Jessie, not lite, I went to install Mycroft-Core via git clone, then Bash dev_setup.sh --alow-root to setup the virtualenv for mycroft. Had a couple of problems specifically around Padatious because Padatious requires a newer version of libfann-dev that is provided in the repo. Maybe it was a mistake on my part, but I followed these instructions and essentially used sudo apt-get install mycroft-core . That worked!

After running bash dev_setup.sh --allow-root again, and then ./start-mycroft.sh debug Mycroft came alive asked me to register, installed a couple of skills, Spotify for example. Everything was working fine… Until a reboot. Now every time I try to run ./start-mycroft.sh debug I get the same error at the very beginning of the Mycroft startup process.

IOError: [Errno 13] Permission denied: ‘/tmp/mycroft/voice.pid’

I’ve tried deleting the /.virtualenvs and re-installing. Nothing has worked. Any suggestions short of completely starting over, going back to my MagicMirror image and re-installing mycroft-core?

Can you please do an ls -las of /tmp/mycroft/ so we can see the filesystem permission?

Kind regards,
Kathy

4 drwxr-xr-x 4 mycroft mycroft 4096 Mar 31 14:31 mycroft

pi@mycroft:/tmp $ ls -las
total 92
4 drwxrwxrwt 20 root root 4096 Apr 1 12:18 .
4 drwxr-xr-x 22 root root 4096 Mar 30 16:19 …
4 drwx------ 2 pi pi 4096 Mar 31 14:31 dhcpcd-(null)
4 drwxrwxrwt 2 root root 4096 Mar 31 14:31 .font-unix
4 drwxrwxrwt 2 root root 4096 Mar 31 14:31 .ICE-unix
4 drwxr-xr-x 5 pi pi 4096 Apr 1 12:13 install-pygtk-18711
4 drwxr-xr-x 4 pi pi 4096 Apr 1 11:35 install-pygtk-2033
0 srwxr-xr-x 1 pi pi 0 Apr 1 11:31 .lxterminal-socket:0.0-pi
0 srwxr-xr-x 1 pi pi 0 Mar 31 14:31 .menu-cached-:0-pi
4 drwxr-xr-x 4 mycroft mycroft 4096 Mar 31 14:31 mycroft

it looks as if this file is in the root. is that where it is supposed to be?

pi@mycroft:/tmp $ ls -las

Mycroft is my user

Here’s what I see from Mycroft’s cli
Traceback (most recent call last):

main()
File "/home/pi/mycroft-core/mycroft/client/speech/main.py", line 143, in main
lock = PIDLock("voice")
File "/home/pi/mycroft-core/mycroft/lock/__init__.py", line 112, in __init__
self.create()
File "/home/pi/mycroft-core/mycroft/lock/__init__.py", line 166, in create
self.touch()
File "/home/pi/mycroft-core/mycroft/lock/__init__.py", line 153, in touch
with open(self.path, 'w') as L:
IOError: [Errno 13] Permission denied: '/tmp/mycroft/voice.pid'
  ^--- NEWEST ---^

OK, so it’s running as the pi user, which doesn’t have permission to open the /tmp/mycroft/voice.pid file for writing. I’m not sure what file permissions /tmp/mycroft/voice.pid should have, so I’m going to flag this one for my colleague @forslund to have a look at. He is travelling at the moment, and will be around in 48 hours or so.

Awesome!! Thank you for your help!

I think this will be a really cool use for Mycroft if we can get both Mycroft and MagicMirror working at the same time.

It may be easier for me to go back to my Magic Mirror image and try again, I’m concerned that I will run into the same problem after a reboot.

I have another sd card, so I may give that a try. I’m looking forward to your advice and will let you know what happens with the other sd card

1 Like

Hi,

is this on a raspberry Pi?

From the error message it sounds as if Mycroft is already running. When you install mycroft from the apt repository it’s installed as a service and will be started on boot.

You can check this by running ps aux | grep "mycroft" to list any Mycroft related processes.

1 Like

Yes it is a Raspberry Pi 3b. on a 16gb sd card.

I’m at work now and don’t have access to the Pi.

But what you’re saying makes a lot of sense. I will go back to my original MagicMirror image and start over and do a git clone from the master branch.

I would like to eventually create a skill for Mycroft to interact with the MagicMirror. Which installation would make more sense to you? Install as a service, or running Mycroft in Virtualenv? It seems to me it would make more sense to run in a virtualenv, but the most important thing will be getting both applications running at the same time and able to easily restart on their own after a reboot. For example, if we lose power.

Whatever advice you can give would be much appreciated. Thanks!

It might be better to run in a virtualenv to keep the dependencies in check. The aptpackage gets cranky if the dependencies versions are changed (as they may do) if pip is used to install stuff on the system.

Top about the dev-setup, avoid the --allow-root flag. It’s meant to run in user mode with sudo. Running as root will install the virtualenv in the root users home folder instead of the user that should be running it (Pi or a separate user).

I must have misunderstood, I thought running as sudo causes problems. Not the other way around.

     echo "This script should not be run as root or with sudo."
  echo "To force, rerun with --allow-root"

I have had issues not running as --allow-root

I thought running as sudo was a no-no. for dev_setup.sh

I am new at this so please be patient with my comprehension.

I read this post and understood that I should not run as sudo.

Did I misunderstand? If so, thanks for pointing me in the right direction.

Sorry I misspoke, you shouldn’t run it as sudo, the script will invoke sudo when necessary.

You should just start it with the normal user with ./dev-setup.sh this will run some parts with sudo and ask for password.

–allow-root is a way to get around the restriction installing the development environment as a normal user in the few cases when it’s actually desirable to install it as root (ex, docker installation), but shouldn’t be used normally.

Thanks for the advice, I was misunderstanding what I read. I have gone back to my MagicMirror image and installed mycroft-core via

  • git clone --depth=1 https://github.com/MycroftAI/mycroft-core.git.

Then

  • cd ~/Mycroft-core

  • bash dev_setup.sh.

The installation went ok, with no issues. But when I started

  • ./start-mycroft.sh debug

it gave an error about Padatious. and stopped.

It is apparently an issue with the libfann-dev needing to be newer than what’s in the repo.

I am considering trying two simultaneous builds on different sd cards. One which uses virtualenv and the other installing mycroft as a service through

  • sudo apt-get install mycroft-core

To see which method presents fewer issues. My concern with the latter is it installs a Mycroft user, and I’m wondering if that will present permission issues that will be harder to overcome.

I tried starting with the picroft image that’s available, but installing MagicMirror on to Jessie Lite proved just as difficult it seems. To install both on the same system requires a 16gb sd card. Fortunately I have 2 to play with.

Thank you so much for your advice. I am very new to all of this. If there is anything else I should look out for with either method, please let me know what you think.

You should be able to add the mycroft apt repo and install the newer padatious library or pull the dpkg from the official stretch arm repo.

Thanks! I’ll let you know how that works.

Well… Thanks to your advice, the Mycroft-core is up and running in virtualenv with a working MagicMirror application on the same pi.

It worked following your last suggestion, following these steps listed in these instructions: (not sure all steps were necessary but followed them anyhow)

  • sudo apt-get install apt-transport-https

Download and install signing key from keyserver.

  • sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F3B1AA8B

Create apt source entry (stable releases).

  • sudo bash -c 'echo "deb http://repo.mycroft.ai/repos/apt/debian debian main" > /etc/apt/sources.list.d/repo.mycroft.ai.list'

Update the apt cache to include the new repository

  • sudo apt-get update

  • sudo apt-get install libfann2

From there, everything worked like a charm. Now I just need to figure out how to start everything MagicMirror and Mycroft when the desktop boots and I can start working on the MagicMirror skill for mycroft. Do you recommend using .bashrc to start the virtualenv? Or would there be a better suggestion? Considering that it’s necessary to set the desktop to auto login as pi user for the MagicMirror to start?

2 Likes

In linux there are a lot of ways to achieve that, I’m not sure which way is “cleanest” check out this stackoverflow thread for some suggestion from more experienced people: https://unix.stackexchange.com/questions/122424/execute-a-command-on-user-logon

1 Like

Once again thank you for your guidance.

Turns out that because the desktop automatically logs in as pi user to run MagicMirror the best way I found to start mycroft-core was to call a

  • start.sh

Script in the

  • /home/pi/.config/lxsession/LXDE-pi/autostart

Here’s the script I added:

`#!/bin/bash
 #start.sh for starting mycroft-core

  Echo Waiting for MagicMirror to complete startup...

   Sleep 25

    Echo Starting Mycroft-core virtualenv...
   
   Sleep 5

    Cd /home/pi/mycroft-core/

    start-pulseaudio-x11

     ./start-mycroft.sh all

     Sleep 5

     ./start-mycroft.sh cli`

Not sure why I needed to add the start-pulseaudio-x11, but I couldn’t get it to work just by adding autospawn=yes to the pulseaudio config file.

I used nano (not sudo) to edit the autostart

  • nano /home/pi/.config/lxsession/LXDE-pi/autostart

To read:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@lxterminal -e "/home/pi/start.sh"

I also made the start.sh script executable by:

  • chmod +x /home/pi/start.sh

Anyway, thanks again for your help!

Now to start working on the mycroft MagicMirror skill to allow mycroft to control some basic functions of the MagicMirror modules.

Cheers!

3 Likes

Great writeup, @dmwilsonkc