aider icon indicating copy to clipboard operation
aider copied to clipboard

JSON error

Open coder-r opened this issue 2 years ago • 8 comments

Traceback (most recent call last): File "/usr/local/bin/aider", line 8, in sys.exit(main()) File "/usr/local/lib/python3.8/dist-packages/aider/main.py", line 293, in main coder.run() File "/usr/local/lib/python3.8/dist-packages/aider/coders/base_coder.py", line 328, in run new_user_message = self.run_loop() File "/usr/local/lib/python3.8/dist-packages/aider/coders/base_coder.py", line 396, in run_loop return self.send_new_user_message(inp) File "/usr/local/lib/python3.8/dist-packages/aider/coders/base_coder.py", line 420, in send_new_user_message messages += self.get_files_messages() File "/usr/local/lib/python3.8/dist-packages/aider/coders/base_coder.py", line 304, in get_files_messages repo_content = self.repo_map.get_repo_map(self.abs_fnames, other_files) File "/usr/local/lib/python3.8/dist-packages/aider/repomap.py", line 97, in get_repo_map res = self.choose_files_listing(chat_files, other_files) File "/usr/local/lib/python3.8/dist-packages/aider/repomap.py", line 128, in choose_files_listing files_listing = self.get_ranked_tags_map(chat_files, other_files) File "/usr/local/lib/python3.8/dist-packages/aider/repomap.py", line 345, in get_ranked_tags_map ranked_tags = self.get_ranked_tags(chat_fnames, other_fnames) File "/usr/local/lib/python3.8/dist-packages/aider/repomap.py", line 253, in get_ranked_tags data = self.run_ctags(fname) File "/usr/local/lib/python3.8/dist-packages/aider/repomap.py", line 174, in run_ctags data = [json.loads(line) for line in output] File "/usr/local/lib/python3.8/dist-packages/aider/repomap.py", line 174, in data = [json.loads(line) for line in output] File "/usr/lib/python3.8/json/init.py", line 357, in loads return _default_decoder.decode(s) File "/usr/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 26 (char 25)

Can anyone help with the issue above?

I have reinstalled and remade the CTAG's executable and currently blocked by this.

coder-r avatar Jul 06 '23 19:07 coder-r

Thanks for trying aider! Sorry to hear you are having problems. I'm happy to try and help debug.

What output do you get if you run ctags --version from the command line?

You can also run aider without ctags, it is completely optional.

paul-gauthier avatar Jul 06 '23 20:07 paul-gauthier

I run in the same issue. You need the -output--format=json be supported. ctags --version doesn't output json support. Any installation or build setup i tried on Ubuntu 22 doesnt seem to be getting it. But looking at this https://github.com/universal-ctags/ctags/issues/2013 I found this: sudo apt-get install libjansson-dev && ./autogen.sh && ./configure && make && sudo make install And it seems to be working. (I assume you run into these errors on Linux)

GreazySpoon avatar Jul 07 '23 11:07 GreazySpoon

Thanks for trying aider! Sorry to hear you are having problems. I'm happy to try and help debug.

What output do you get if you run ctags --version from the command line?

You can also run aider without ctags, it is completely optional.

Universal Ctags 6.0.0(71851a4f), Copyright (C) 2015-2022 Universal Ctags Team Universal Ctags is derived from Exuberant Ctags. Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert Compiled: Jul 6 2023, 23:30:30 URL: https://ctags.io/ Output version: 0.0 Optional compiled features: +wildcards, +regex, +gnulib_regex, +iconv, +option-directory, +xpath, +json, +interactive, +sandbox, +yaml, +packcc, +optscript

coder-r avatar Jul 07 '23 11:07 coder-r

@coder-r I added logic to catch and report json errors when aider is parsing ctags output. If you install the latest from github you should get a clear error message showing you what was wrong with the json. If you have a chance to paste that here, I could help debug more.

paul-gauthier avatar Jul 07 '23 16:07 paul-gauthier

aider Model: gpt-4 Git repo: .git Repo-map: universal-ctags using 1024 tokens Use /help to see in-chat commands. ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

what is this repo

/root/git/ctags/Tmain/input-encoding-option.d/input.java: 'utf-8' codec can't decode byte 0x83 in position 18: invalid start byte /root/git/ctags/Tmain/input-encoding-option.d/input.js: 'utf-8' codec can't decode byte 0xca in position 14: invalid continuation byte /root/git/ctags/Tmain/invalid-encoding-option.d/input.java: 'utf-8' codec can't decode byte 0x83 in position 18: invalid start byte /root/git/ctags/Tmain/invalid-encoding-option.d/input.js: 'utf-8' codec can't decode byte 0xca in position 14: invalid continuation byte /root/git/ctags/Tmain/no-input-encoding-option.d/input.java: 'utf-8' codec can't decode byte 0x83 in position 18: invalid start byte /root/git/ctags/Tmain/no-input-encoding-option.d/input.js: 'utf-8' codec can't decode byte 0xca in position 14: invalid continuation byte /root/git/ctags/Tmain/output-encoding-option.d/input.js: 'utf-8' codec can't decode byte 0xca in position 14: invalid continuation byte /root/git/ctags/Tmain/output-encoding-option.d/tags-expected.txt: 'utf-8' codec can't decode byte 0x83 in position 573: invalid start byte /root/git/ctags/Tmain/pattern-length-limit.d/input-iso-8859-1.py: 'utf-8' codec can't decode byte 0x80 in position 144: invalid start byte /root/git/ctags/Tmain/pattern-length-limit.d/stdout-expected.txt: 'utf-8' codec can't decode byte 0x80 in position 759: invalid start byte

thanks again for helping. I tried a command such as what is this repo and its the same for any repo I do this too. On another note how do I disable ctags from being used in aider?

coder-r avatar Jul 07 '23 20:07 coder-r

Ok, looks like ctags is returning non-utf-8 encodings, presumably because your files are using some other encoding?

I just pushed a change, which tells ctags to always output utf-8. If you know the encoding of your files, you should run aider with --encoding xxx to tell it.

Maybe --encoding cp1252 or --encoding latin1 ?

Are you on Windows?

paul-gauthier avatar Jul 07 '23 22:07 paul-gauthier

Using Ubuntu in WSL.

Is there any way of getting a verbose output when you ask something like "what is this repo" and its thinking.

Your recent fix seems to have worked though! Thank you!

coder-r avatar Jul 08 '23 21:07 coder-r

I'm glad to hear that solved your problem.

As far as getting more information, you can just ask more questions to GPT. Ask it to tell you more about the code base you're looking at. You can also ask it if there are particular files it would like to see in order to understand things better.

Finally, you can run aider with --verbose, and that will show you a bunch of debug information. But you're already seeing everything that GPT is writing, so I'm not sure that's what you want to do.

paul-gauthier avatar Jul 08 '23 23:07 paul-gauthier

I'm going to close this issue for now, but feel free to re-open or file a new issue if you have any further problems.

paul-gauthier avatar Jul 11 '23 16:07 paul-gauthier