opensouls / terminal-copilot

A smart terminal assistant that helps you find the right command.
Apache License 2.0
573 stars 43 forks source link

UnicodeDecodeError in M1 Macbook #34

Closed 1stprinciples closed 1 year ago

1stprinciples commented 1 year ago

I tried the following commands:

conda create --name myenv python=3.7
conda activate myenv

The following command successfully installed the library

pip install terminal-copilot 

With the following output message (showing only the final line)

Successfully installed charset-normalizer-2.1.1 et-xmlfile-1.1.0 idna-3.4 numpy-1.21.6 openai-0.25.0 openpyxl-3.0.10 pandas-1.3.5 pandas-stubs-1.2.0.62 pyperclip-1.8.2 python-dateutil-2.8.2 pytz-2022.7 requests-2.28.1 simple-term-menu-1.5.2 six-1.16.0 terminal-copilot-1.2.1 tqdm-4.64.1 types-pytz-2022.7.0.0 typing-extensions-4.4.0 urllib3-1.26.13

The following command raises an error

copilot list all files in the parent directory

The error

Traceback (most recent call last):
  File "/Users/username/opt/anaconda3/envs/myenv/bin/copilot", line 8, in <module>
    sys.exit(main())
  File "/Users/username/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/copilot/copilot.py", line 87, in main
    """
  File "/Users/username/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/copilot/history.py", line 46, in get_history
    return _zsh_history(history_context_size)
  File "/Users/username/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/copilot/history.py", line 29, in _zsh_history
    lines = history_file.zsh_history_file_lines()
  File "/Users/username/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/copilot/history_file.py", line 41, in zsh_history_file_lines
    lines = history.read().splitlines()
  File "/Users/username/opt/anaconda3/envs/myenv/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 1648: invalid start byte
github-actions[bot] commented 1 year ago

Hey! Thanks for sharing feedback with the community!

Armandotrsg commented 1 year ago

Got the same error, I even tried using rosetta 2, and I got the same error

EdwardTheLegend commented 1 year ago

the line in the traceback looks different to this line https://github.com/Methexis-Inc/terminal-copilot/blob/591f950a7ecfc2fc2bd3857d0b448b245aefc590/copilot/history_file.py#L41 which has got code to handle decoding errors

maybe this is a case of fixed in repo but new version hasn't been published to pypi yet?

EdwardTheLegend commented 1 year ago

If you don't want to wait for a release you could try cloning the repo and doing local install

JoelKronander commented 1 year ago

O I apologize!. I am pushing out the new version that should fix that based on @EdwardTheLegend contribution!