JamJar00 / dotbot-scoop

Plugin for Dotbot, that adds the `scoop` directive, which allows you to install scoop packages
MIT License
2 stars 0 forks source link

Problem installing applications #3

Closed camfrey closed 1 month ago

camfrey commented 5 months ago

Seems to be some sort of type issue when iterating over the apps to install for me.

Adding buckets []
Adding apps [Hack-NF-mono]
An error was encountered while executing action scoop
sequence item 1: expected str instance, App found
Action scoop not handled
JamJar00 commented 5 months ago

Hey! Thanks for reporting the issue!

Could you provide some more info for me please:

It looks almost like your Python isn't automatically converting the object to a string so maybe you're running an older Python than me. I've been running this for a couple of years without issue so presumably some difference in our environments!

Jamie

arilence commented 1 month ago

Running into the same issue

install.conf.yaml:

- defaults:
    link:
      relink: true

- clean: ['~']

- scoop:
    buckets:
      - extras
    apps:
      - obsidian

install.ps1: This is just the default install script with the added argument --plugin-dir dotbot-scoop

$ErrorActionPreference = "Stop"

$CONFIG = "install.conf.yaml"
$DOTBOT_DIR = "dotbot"

$DOTBOT_BIN = "bin/dotbot"
$BASEDIR = $PSScriptRoot

Set-Location $BASEDIR
git -C $DOTBOT_DIR submodule sync --quiet --recursive
git submodule update --init --recursive $DOTBOT_DIR

foreach ($PYTHON in ('python', 'python3')) {
    # Python redirects to Microsoft Store in Windows 10 when not installed
    if (& { $ErrorActionPreference = "SilentlyContinue"
            ![string]::IsNullOrEmpty((&$PYTHON -V))
            $ErrorActionPreference = "Stop" }) {
        &$PYTHON $(Join-Path $BASEDIR -ChildPath $DOTBOT_DIR | Join-Path -ChildPath $DOTBOT_BIN) -d $BASEDIR -c $CONFIG --plugin-dir dotbot-scoop $Args
        return
    }
}
Write-Error "Error: Cannot find Python."

output:

PS > python --version
Python 3.12.3

PS > scoop --version
Current Scoop version:
d337bb1f (HEAD -> master, tag: v0.4.2, origin/master, origin/HEAD) chore(release): Bump to version 0.4.2 (#5964)
'main' bucket:
e96a89a7f (HEAD -> master, origin/master, origin/HEAD) wasmer: Update to version v4.3.1
'extras' bucket:
bcd76e6f1 (HEAD -> master, origin/master, origin/HEAD) webstorm: Update to version 2024.1.3-241.17011.90
'nerd-fonts' bucket:
4b1954d9 (HEAD -> master, origin/master, origin/HEAD) LXGWNeoXiHei: Update to version 1.122

PS > .\install.ps1 -vv
All targets have been cleaned
Found buckets [main (https://github.com/ScoopInstaller/Main.git), extras (https://github.com/ScoopInstaller/Extras), nerd-fonts (https://github.com/matthewjberger/scoop-nerd-fonts)] already configured and apps [7zip, dark, eza, fzf, gcc, GeistMono-NF-Mono, lazygit, make, neovim, nodejs, python, ripgrep, zeal] already installed
Aiming for buckets [extras] to be configured and apps [obsidian] to be installed
Adding buckets []
Adding apps [obsidian]
An error was encountered while executing action scoop
sequence item 1: expected str instance, App found
Action scoop not handled

==> Some tasks were not executed successfully

investigation: I managed to get the installation to work by modifying _add_missing_apps() to use a string for the command instead of joining an array. My python knowledge is limited so I'm not sure why the App class is not being converted automatically. Hopefully this provides some insight.

def _add_missing_apps(self, to_add):
    self._log.debug(f'Adding apps [{", ".join(str(a) for a in to_add)}]')

    success = True
    for app in to_add:
-       command = ['scoop install', app]
+       command = 'scoop install {0}'.format(str(app))

        try:
            subprocess.run(
-               [' '.join(command)],
+               command,
                shell=True,
                check=True)
        except subprocess.CalledProcessError:
            self._log.error(f"Failed to add app {app} by running the command {command}")
            success = False

    return success

output:

PS > .\install.ps1 -vv
All targets have been cleaned
Found buckets [main (https://github.com/ScoopInstaller/Main.git), extras (https://github.com/ScoopInstaller/Extras), nerd-fonts (https://github.com/matthewjberger/scoop-nerd-fonts)] already configured and apps [7zip, dark, eza, fzf, gcc, GeistMono-NF-Mono, lazygit, make, neovim, nodejs, python, ripgrep, zeal] already installed
Aiming for buckets [extras] to be configured and apps [obsidian] to be installed
Adding buckets []
Adding apps [obsidian]
Installing 'obsidian' (1.5.12) [64bit] from 'extras' bucket
Loading Obsidian.1.5.12.exe from cache
Checking hash of Obsidian.1.5.12.exe ... ok.
Extracting dl.7z ... done.
Running pre_install script...
Linking ~\scoop\apps\obsidian\current => ~\scoop\apps\obsidian\1.5.12
Creating shortcut for Obsidian (Obsidian.exe)
'obsidian' (1.5.12) was installed successfully!
New installed set of buckets [main (https://github.com/ScoopInstaller/Main.git), extras (https://github.com/ScoopInstaller/Extras), nerd-fonts (https://github.com/matthewjberger/scoop-nerd-fonts)] and apps [7zip, dark, eza, fzf, gcc, GeistMono-NF-Mono, lazygit, make, neovim, nodejs, obsidian, python, ripgrep, zeal]
All buckets have been added
All apps have been added

==> All tasks executed successfully
JamJar00 commented 1 month ago

Thanks for the extra info!

Just to confirm are you getting the same error sequence item 1: expected str instance, App found?

I wonder if this is because you use Powershell. I run WSL (which is able to call windows executables like scoop) so potentially there's a mismatch in how Python calls WSL vs Powershell. Perhaps taking shell=True off could help here so Python invokes the executable directly

I'll try and have a play this weekend, maybe I can reproduce it and fix!

arilence commented 1 month ago

Just to confirm are you getting the same error sequence item 1: expected str instance, App found?

Yup, I get:

Adding buckets []
Adding apps [obsidian]
An error was encountered while executing action scoop
sequence item 1: expected str instance, App found
Action scoop not handled

I run WSL (which is able to call windows executables like scoop)

Ah good to know! I didn't know WSL is able to call windows executables.

JamJar00 commented 1 month ago

Hey folks,

Managed to reproduce the problem and also found a couple of other issues with Powershell compatibility and how the plugin calls scoop.

Please give the latest main a test and let me know if it's solved your issue! I'll leave this open for you to confirm 🙂

arilence commented 1 month ago

The latest changes fix the issue for me. Thanks for taking the time to look into this!