DrDynamic / dotbot-sudo

MIT License
9 stars 9 forks source link

Plugin requires system-wide installation of pyyaml #2

Closed niraami closed 3 years ago

niraami commented 3 years ago

Seems that running dotbot-sudo requires a system wide pyyaml installation (such as python-yaml) - meaning that it for some reason doesn't use the bundled one. I've got minimal experience in python.. which is why I'm raising this issue - meaning I've got no idea if this is intended, fixable or dotbots fault. If it's intended, take this as a suggestion to put a disclaimer in the readme, casue I can totally just install python-yaml earlier in the process using dotbot-yay.

Traceback:

  File "/home/niraami/.dotfiles/dotbot-sudo/./execute_plugin.py", line 29, in <module>
    import dotbot
  File "/home/niraami/.dotfiles/dotbot/dotbot/__init__.py", line 1, in <module>
    from .cli import main
  File "/home/niraami/.dotfiles/dotbot/dotbot/cli.py", line 5, in <module>
    from .config import ConfigReader, ReadingError
  File "/home/niraami/.dotfiles/dotbot/dotbot/config.py", line 1, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

Dotbot install script:

#!/usr/bin/env bash

set -e

CONFIG="install.conf.yaml"

DOTBOT_DIR="dotbot"
DOTBOT_BIN="bin/dotbot"

BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

DOTBOT_YAY="${BASEDIR}/dotbot-yay/yay.py"
DOTBOT_SUDO="${BASEDIR}/dotbot-sudo/sudo.py"
DOTBOT_GIT="${BASEDIR}/dotbot-git/git.py"

cd "${BASEDIR}"
git -C "${DOTBOT_DIR}" submodule sync --quiet --recursive
git submodule update --init --recursive "${DOTBOT_DIR}"

# Configs
"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -p "${DOTBOT_SUDO}" -p "${DOTBOT_YAY}" -p "${DOTBOT_GIT}" -c "${CONFIG}" "${@}"

install.conf.yaml:

...
- sudo:
    - link:
        /etc/vconsole.conf:
          path: system/etc/vconsole.conf
          force: true
        /etc/X11/xorg.conf.d/00-keyboard.conf:
          path: system/etc/X11/xorg.conf.d/00-keyboard.conf
        /usr/share/themes/Midnight-GrayNight:
          path: system/usr/share/themes/Midnight-GrayNight
etkeys commented 3 years ago

My two cents (plus tax where applicable).

Is this dotbot's fault?

No. dotbot-sudo performs actions in a sub-process (via execute_plugin.py). Because of this is, all sudo commands are running outside the environment setup by dotbot. execute_plugin.py would be responsible for setting up an environment similar to the one created by dotbot. More on this later.

Is the error intended?

Tough to say. On the surface, no. But there maybe some limitations with the python runtime regarding loading of the same resource by multiple processes. I'm not experienced enough to know how that all works off the top of my head, but I'm experienced enough to bang on it for a bit as a test.

Is this fixible?

Again, tough to say. I'll point out that execute_plugin.py looks very similar to dotbot. This makes me think that it's a simple matter of execute_plugin.py injecting the path information to the bundled pyyaml stuff. But again, I'm not sure if this has been tried already and it's intentional that doing this has been removed from execute_plugin.py.

I'd like to play around with this for a bit to see what can be fixed but I won't have time to do so until early next week. I'll check back on this next week and try some things if this issue is still open.

DrDynamic commented 3 years ago

thank you for the info. This is not intended behaviour.
My idea was to import dotbot itself so there are no dependencies to be installed. Would be great if you find a solution. Thanks

etkeys commented 3 years ago

@niraami, I've submitted PR #3. I did some light testing with this updated on my system using virtual environment and did not have any issues with pyyaml references. If you could spare the time and are able, would you be willing to give these updates a go to see if this works for you?

niraami commented 3 years ago

Can't comment on the changes themselves, but this does resolve my initial issue. Later today I'll also test it on a clean system in a vm, but just uninstalling python-yaml before could bring back the issue for me, which it doesn't anymore, so, according to my testing methology it's fixed :D

All commands have been executed
sudo: begin subprocess
Link exists /etc/vconsole.conf -> /home/niraami/.dotfiles/system/etc/vconsole.conf
Link exists /etc/X11/xorg.conf.d/00-keyboard.conf -> /home/niraami/.dotfiles/system/etc/X11/xorg.conf.d/00-keyboard.conf
Link exists /usr/share/themes/Midnight-GrayNight -> /home/niraami/.dotfiles/system/usr/share/themes/Midnight-GrayNight
All links have been set up
niraami commented 3 years ago

A little later than I wanted, but I tested it on a clean arch install (I was planning to reinstall anyways, so I just waited till the weekend so I had more time) and it works great, no issues here.