Glavin001 / atom-beautify

:mega: Help Wanted - Looking for Maintainer: https://github.com/Glavin001/atom-beautify/issues/2572 | :lipstick: Universal beautification package for Atom editor (:warning: Currently migrating to https://github.com/Unibeautify/ and have very limited bandwidth for Atom-Beautify Issues. Thank you for your patience and understanding :heart: )
http://unibeautify.com/
MIT License
1.5k stars 453 forks source link

Could not find 'black'. The program may not be installed. #2597

Open Doekeb opened 3 years ago

Doekeb commented 3 years ago

Description

Atom Beautify cannot find Black. Running Atom Beautify on even an empty Python file fails with the following message:

Could not find 'black'. The program may not be installed.

See black installation instructions at https://github.com/Glavin001/atom-beautify#beautifiers or go to https://github.com/ambv/black#installation
You can configure Atom Beautify with the absolute path to 'black' by setting 'Executable - black - Path' in the Atom Beautify package settings.
Your program is properly installed if running 'which black' in your Terminal returns an absolute path to the executable.
Hide Stack Trace
Error: Could not find 'black'. The program may not be installed.
    at Function.Executable.commandNotFoundError (/home/doeke/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:277:10)
    at HybridExecutable.Executable.commandNotFoundError (/home/doeke/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:269:18)
    at /home/doeke/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:115:25
    at tryCatcher (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:15:14)

Steps to Reproduce

  1. Create an empty Python file, e.g. test.py.
  2. Run command Atom Beautify: Beautify Editor
  3. The above error message is returned

Note: I have double-checked that black is installed (in my system python—not a virtual environment). Running which black returns the absolute path. I get the same results as above even if I set the absolute path of the executable in Atom Beautify settings. Additionally, I can successfully run black on a file manually from the command line.

Debug

Here is a link to the debug.md Gist: https://gist.github.com/Doekeb/28a2722ef36c776a733b61d3e5d9f0ba

Checklist

I have:

ErielCruz commented 2 years ago

I am experiencing the same issue and have followed the same troubleshooting steps described by Doekeb without success :/

ZeePal commented 2 years ago

possible insight that might help debugging:

mine was working fine then i did an pip3 install --upgrade black New version (broken):

❯ black --version
black, 21.12b0 (compiled: no)

I cant remember what version I had before but I rolled back to pip3 install black==21.10b0 and its working again

ThatXliner commented 2 years ago

Same. Only black==21.10b worked

claytonjroberts commented 2 years ago

For anyone looking for a quick solution: pip install --upgrade black==21.10b0

jeanfrancoiscaty commented 2 years ago

Figured out the issue, version number is getting reported differently now. regex is looking for black, version X.Y.Z but version is now black, X.Y.Z

Cracked open packages/atom-beautify/src/beautifiers/black.coffee and updated the catch:

          try
            text.match(/black, version (\d+\.\d+)/)[1] + "." + text.match(/b(\d+)$/)[1]
          catch
            try
              text.match(/black, version (\d+\.\d+)/)[1] + ".0"
            catch
              text.match(/black, (\d+\.\d+\.\d+)/)[1]

Good enough for me, will look into contributing a proper PR for it when I have the bandwidth.