Skip to content
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

Action fails due to missing dependency on colorama #70

Closed
rarestg opened this issue Dec 12, 2022 · 3 comments
Closed

Action fails due to missing dependency on colorama #70

rarestg opened this issue Dec 12, 2022 · 3 comments

Comments

@rarestg
Copy link

rarestg commented Dec 12, 2022

I'm using this action in my project and it's failing because it doesn't find this colorama package.

Run isort/[email protected]
  with:
    configuration: --check-only --diff --profile black
    isortVersion: latest
    sortPaths: .
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.15/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.15/x64
    Python[2](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:2)_ROOT_DIR: /opt/hostedtoolcache/Python/[3](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:3).9.15/x6[4](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:4)
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.1[5](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:5)/x[6](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:6)4
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib
Run /home/runner/work/_actions/isort/isort-action/v1.1.0/bin/ensure_python
Run /home/runner/work/_actions/isort/isort-action/v1.1.0/bin/install_packages latest 
  /home/runner/work/_actions/isort/isort-action/v1.1.0/bin/install_packages latest 
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.15/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.15/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.15/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.15/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib
Install isort
  Installing latest version of isort
  Collecting isort[pipfile_deprecated_finder,requirements_deprecated_finder]
    Downloading isort-5.11.0-py3-none-any.whl (118 kB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.5/118.5 kB 2.2 MB/s eta 0:00:00
  WARNING: isort 5.11.0 does not provide the extra 'pipfile_deprecated_finder'
  WARNING: isort 5.11.0 does not provide the extra 'requirements_deprecated_finder'
  Installing collected packages: isort
  Successfully installed isort-5.11.0
Run /home/runner/work/_actions/isort/isort-action/v1.1.0/bin/run_isort --check-only --diff --profile black .
  /home/runner/work/_actions/isort/isort-action/v1.1.0/bin/run_isort --check-only --diff --profile black .
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.15/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.15/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.15/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.15/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib
Running isort --check-only --diff --profile black .
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.15/x64/lib/python3.9/site-packages/isort/main.py", line 8[7](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:7), in sort_imports
    incorrectly_sorted = not api.check_file(file_name, config=config, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.15/x64/lib/python3.9/site-packages/isort/api.py", line 33[8](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:8), in check_file
    return check_stream(
  File "/opt/hostedtoolcache/Python/3.[9](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:9).15/x64/lib/python3.9/site-packages/isort/api.py", line 272, in check_stream
    printer = create_terminal_printer(
  File "/opt/hostedtoolcache/Python/3.9.15/x64/lib/python3.9/site-packages/isort/format.py", line 153, in create_terminal_printer
    colorama.init(strip=False)
NameError: name 'colorama' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.15/x64/bin/isort", line 8, in <module>
    sys.exit(main())
  File "/opt/hostedtoolcache/Python/3.9.15/x64/lib/python3.9/site-packages/isort/main.py", line 1225, in main
    for sort_attempt in attempt_iterator:
  File "/opt/hostedtoolcache/Python/3.9.15/x64/lib/python3.9/site-packages/isort/main.py", line 1209, in <genexpr>
    sort_imports(  # type: ignore
  File "/opt/hostedtoolcache/Python/3.9.15/x64/lib/python3.9/site-packages/isort/main.py", line [11](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:11)4, in sort_imports
    _print_hard_fail(config, offending_file=file_name)
  File "/opt/hostedtoolcache/Python/3.9.15/x64/lib/python3.9/site-packages/isort/main.py", line [12](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:12)7, in _print_hard_fail
    printer = create_terminal_printer(
  File "/opt/hostedtoolcache/Python/3.9.15/x64/lib/python3.9/site-packages/isort/format.py", line 1[53](https://github.com/getathelas/errands/actions/runs/3679172842/jobs/6223372652#step:8:58), in create_terminal_printer
    colorama.init(strip=False)
NameError: name 'colorama' is not defined
Error: Process completed with exit code 1.
@jamescurtin
Copy link
Member

This is a bug that was introduced in isort==5.11.0, and isn't related to this action specifically. The underlying issue has already been patched (see the changelog for 5.11.1), so retrying should fix the broken build.

By default, this action will use the latest version of isort. In general, it is a good idea to consider pinning the version of isort that is used by the plugin (reference), which would have been one way to avoid this error case.

@comc
Copy link

comc commented Dec 13, 2022

This issue persists for me, due to what I presume is having color_output: true in my config that I pass into isort/isort-action; however, the action does not appear to be installing the correct configuration in the action (isort[colors]) to succeed. This broke in my CI with the release of 5.11.0, but has not resolved with the patch for 5.11.1.

Workaround of installing colorama as a step before this action (see below) appears to work, but does not explain the break in CI behaviour.

  isort:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - run: pip install colorama
      - uses: isort/[email protected]
        with:
          configuration: '--check-only --diff --settings-file=./app/pyproject.toml'
          sortPaths: './app'

@diegoferigo
Copy link

#96 broke again --color since the colorama installed in the default path in a custom step is no longer visible from within the new virtualenv where isort runs.

I worked around this change using requirements.txt in a downstream project: ami-iit/rod#46.

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

4 participants