Skip to content

win_scoop doesn't handle spaces in scoop install path #614

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

Open
greenseeker opened this issue Mar 14, 2025 · 1 comment
Open

win_scoop doesn't handle spaces in scoop install path #614

greenseeker opened this issue Mar 14, 2025 · 1 comment

Comments

@greenseeker
Copy link

SUMMARY

If scoop is installed in a path with spaces, eg. C:\Program Files\Scoop, then the module will fail with "The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program."

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_scoop

ANSIBLE VERSION
ansible [core 2.15.13]
  config file = /home/xxxx/ansible.cfg
  configured module search path = ['/home/xxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/xxxx/.local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/xxxx
  executable location = /home/xxxx/.local/bin/ansible
  python version = 3.9.2 (default, Dec  1 2024, 12:12:57) [GCC 10.2.1 20210110] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

COLLECTION VERSION
# /home/xxxx/.local/lib/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
community.windows 1.13.0

# /home/xxxx/ansible_collections
Collection        Version
----------------- -------
community.windows 2.3.0

# /usr/local/lib/python3.9/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.windows 1.11.1

CONFIGURATION
ANSIBLE_NOCOWS(/home/xxxx/ansible.cfg) = True
CALLBACKS_ENABLED(/home/xxxx/ansible.cfg) = ['ansible.posix.profile_tasks']
COLLECTIONS_PATHS(/home/xxxx/ansible.cfg) = ['/home/xxxx']
CONFIG_FILE() = /home/xxxx/ansible.cfg
DEFAULT_STDOUT_CALLBACK(/home/xxxx/ansible.cfg) = yaml
DEFAULT_VERBOSITY(/home/xxxx/ansible.cfg) = 0

OS / ENVIRONMENT

Windows Server 2022

STEPS TO REPRODUCE
  • Preinstall scoop to C:\Program Files\Scoop or similar path with a space.
  • Run an install task using win_scoop.
---
- hosts: b-windows.xxxx.lab
  tasks:
    - name: Install bruno
      community.windows.win_scoop:
        name: extras/bruno
...
EXPECTED RESULTS

win_scoop should handle spaces in paths gracefully and run the command successfully.

ACTUAL RESULTS

The parts of the path before and after the space are treated as separate arguments.

fatal: [b-windows.xxxx.lab]: FAILED! => changed=false
  command: powershell.exe "C:\Program Files\scoop\shims\scoop.ps1" export
  msg: Error checking installed packages
  rc: 1
  stderr: |-
    C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet, function, script
    file, or operable program. Check the spelling of the name, or if a path was included, verify that
    the path is correct and try again.
    At line:1 char:1
    + C:\Program Files\scoop\shims\scoop.ps1 export
    + ~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (C:\Program:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

@greenseeker
Copy link
Author

I was able to work around this by modifying the Install-Scoop function, changing this:

return $scoop_app.Path

...to this:

$escaped_path = $scoop_app.Path -replace ' ','` '
return $escaped_path

This is pretty hacky and I'm sure there's a better way that I just haven't found yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant