Atom-beautify: beautysh: error: unrecognized arguments: -f

Created on 16 Aug 2019  路  9Comments  路  Source: Glavin001/atom-beautify

Description

The results of beautification are not what I expected because it simply crashed.

Actual Output

usage: beautysh [--indent-size INDENT_SIZE] [--backup] [--check] [--tab] [--force-function-style FORCE_FUNCTION_STYLE] [--version] [--help] [FILE [FILE ...]] beautysh: error: unrecognized arguments: -f

usage: beautysh [--indent-size INDENT_SIZE] [--backup] [--check] [--tab]
                [--force-function-style FORCE_FUNCTION_STYLE] [--version]
                [--help]
                [FILE [FILE ...]]
beautysh: error: unrecognized arguments: -f

Steps to Reproduce

  1. Add code to Atom editor
  2. Run command Atom Beautify: Beautify Editor
  3. Error occurs!

Debug

Here is a link to the debug.md Gist: https://gist.github.com/MatthewWolff/a6e504ca47deffeab27a29367ccf9d6c

Checklist

I have:

  • [x] Tried uninstalling and reinstalling Atom Beautify to ensure it installed properly
  • [x] Reloaded (or restarted) Atom to ensure it is not a caching issue
  • [x] Searched through existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues
    so I know this is not a duplicate issue
  • [x] Filled out the Input, Expected, and Actual sections above or have edited/removed them in a way that fully describes the issue.
  • [x] Generated debugging information by executing Atom Beautify: Help Debug Editor command in Atom and added link for debug.md Gist to this issue
bug

Most helpful comment

Workaround:

Remove -f from %userprofile%\.atom\packages\atom-beautify\src\beautifiers\beautysh.coffee as shown at https://github.com/Glavin001/atom-beautify/pull/2385/files.

All 9 comments

This error occurs regardless of the code. It doesn't seem to be even initiating properly.

Using prettier to format JavaScript I also encountered an error

2375

Until the PR gets merged, you can downgrade to a beautysh version that still has support for the now missing -f flag. Put this in your terminal pip install beautysh==4.1

Downgrading to beautysh 4.1 and using Python 3.8.0 I got the following:

Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\beautysh.exe\__main__.py", line 7, in <module>
  File "c:\python38\lib\site-packages\beautysh\beautysh.py", line 28, in main
    Beautify().main()
  File "c:\python38\lib\site-packages\beautysh\beautysh.py", line 361, in main
    error |= self.beautify_file(path)
  File "c:\python38\lib\site-packages\beautysh\beautysh.py", line 273, in beautify_file
    result, error = self.beautify_string(data, path)
  File "c:\python38\lib\site-packages\beautysh\beautysh.py", line 145, in beautify_string
    if(re.search(here_string, test_record) and not
  File "c:\python38\lib\re.py", line 199, in search
    return _compile(pattern, flags).search(string)
  File "c:\python38\lib\re.py", line 302, in _compile
    p = sre_compile.compile(pattern, flags)
  File "c:\python38\lib\sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "c:\python38\lib\sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "c:\python38\lib\sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "c:\python38\lib\sre_parse.py", line 549, in _parse
    raise source.error("unterminated character set",
re.error: unterminated character set at position 21

Downgrading to beautysh 4.1 and using Python 3.8.0 I got...

well... do you think that's a bug, or just a consequence of using an older version of a syntax formatter with a version of Python that literally came out yesterday 馃憖

For anybody using Docker with beautysh and facing this issue, you'll need to create a custom Docker image to fix this:

  1. Create a Dockerfile in an empty directory with these contents:
FROM python:alpine

LABEL io.whalebrew.name 'beautysh'
LABEL io.whalebrew.config.working_dir '/workdir'
WORKDIR /workdir

RUN pip install --upgrade beautysh==4.1

ENTRYPOINT ["beautysh"]
CMD ["--help"]
  1. Run:
docker image build -t unibeautify/beautysh:latest .

Downgrading to beautysh 4.1 and using Python 3.7.5 fixed this for me.

Workaround:

Remove -f from %userprofile%\.atom\packages\atom-beautify\src\beautifiers\beautysh.coffee as shown at https://github.com/Glavin001/atom-beautify/pull/2385/files.

Yep, in the file atom\packages\atom-beautify\src\beautifiers\beautysh.coffee, you have to edit the beautify in the if/else condition (lines 34 to 39), like this:

if tabs is true
      beautysh.run([ '-t', file ])
        .then(=> @readFile file)
    else
      beautysh.run([ '-i', options.indent_size, file ])
        .then(=> @readFile file)
Was this page helpful?
0 / 5 - 0 ratings