Skip to content

Windows: cmd.run doesn't honor PATH anymore after update from 2018.3.4 to 2019.2.3 #56199

Closed

Description

@dhs-rec

Description of Issue

After said update, the follwing SLS doesn't work anymore:

{% if grains['os'] == 'Windows' %}
{% set version = salt['pillar.get']('python:crypto:version') %}
{% from "saltstore/map.jinja" import saltstore with context %}
{% set pkg_name = 'pycrypto-' ~ version ~ '.win-amd64-py2.7.exe' %}
{% set current_path = salt['environ.get']('PATH') %}
include:
  - python.install

pycrypto_pkg:
  file.managed:
    - name: {{ saltstore.dir }}/Python/{{ pkg_name }}
    - source: salt://store/Python/{{ pkg_name }}?saltenv=base
    - makedirs: True

pycrypto_install:
  cmd.run:
    - name: easy_install {{ saltstore.dir }}/Python/{{ pkg_name }}
    - creates: C:/Python27/Lib/site-packages/pycrypto-{{ version }}-py2.7-win-amd64.egg
    - env:
      - PATH: {{ ['C:\Python27', 'C:\Python27\Scripts', current_path]|join(';') }}
    - require:
      - file: pycrypto_pkg
      - sls: python.install
    - shell: powershell
{% endif %}

The cmd.run fails with this error message:

easy_install : The term 'easy_install' is not recognized as the name of a cmdlet, function, script file, or operable program.

Setup

See above.

Steps to Reproduce Issue

Apply this to Windows Minions running 2018.3.4 -> Works
Apply this to Windows Minions running 2019.2.3 -> Fails

Activity

  1. waynew commented on Feb 21, 2020

    @waynew
    Contributor

    And you have verified that C:\Python27\Scripts\easy_install.exe or C:\Python27\easy_install.exe does exist, right? (or that it's somewhere else on the path)?

  2. dhs-rec commented on Feb 24, 2020

    @dhs-rec
    ContributorAuthor

    That's what

       - require:
          - file: pycrypto_pkg
          - sls: python.install
    

    is for. And downgrading Salt makes it work again.

  3. self-assigned this
    on Mar 9, 2020
  4. added this to the Approved milestone on Mar 10, 2020
  5. stale commented on Apr 9, 2020

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

    If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

  6. added
    bug
    and removed on Apr 10, 2020
  7. twangboy commented on Apr 17, 2020

    @twangboy
    Contributor

    Bad stale bot

  8. dhs-rec commented on Jun 10, 2020

    @dhs-rec
    ContributorAuthor

    Any news here?

  9. changed the title [-]Windows: cmd.run doesn't honor PATH anmore after update from 2018.3.4 to 2019.2.3[/-] [+]Windows: cmd.run doesn't honor PATH anymore after update from 2018.3.4 to 2019.2.3[/+] on Jun 15, 2020
  10. dhs-rec commented on Jun 15, 2020

    @dhs-rec
    ContributorAuthor

    I believe I found the reason. Something(tm) reg. environment variable handling seems to have changed to being case-sensitive on Windows minions now. If I use

    - env:
      - Path: ...
    

    instead of

    - env:
      - PATH: ...
    

    in cmd.run it works on Windows minions running 3000.3. Please update the documentation accordingly.

  11. 1 remaining item

  12. added
    Magnesium
    on Jun 25, 2020
  13. sagetherage commented on Jun 25, 2020

    @sagetherage
    Contributor

    let's look at this as we enter planning for the next release likely this will need some docs as noted here: #57706 (comment)

  14. added
    severity-high
    on Jul 6, 2020
  15. removed
    severity-high
    on Sep 10, 2020
  16. added
    Aluminium
    and removed
    Magnesium
    on Sep 29, 2020
  17. xeacott commented on Feb 2, 2021

    @xeacott
    Contributor

    Hey @dhs-rec so I commented on the other ticket, but I think this ticket is still applicable.

    For the case of using env, I think salt needs to be able to handle $Path and I may be wrong, but I don't think it does currently (seems like regression as is the case if it worked once in 2018.3.4)
    For the case of using prepend_path, salt definitely can't handle that right now as shown in your other ticket and confirmed.

    Does that sound like it sums up what's going on here?

  18. dhs-rec commented on Feb 2, 2021

    @dhs-rec
    ContributorAuthor

    Nearly. In 2018.3.4 it worked using PATH, which stopped working in 2019.2.x in favour of Path (which is also what any Windows command shows). But anyway, if Salt is supposed to access env vars in a case-sensitive manner even on Windows now, I'm fine with that. It just needs to be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

AluminiumRegressionWindowsbug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions