Open
Description
Environment details
- Operating System+version: Windows 10
- Compiler+version: N/A
- Conan version: 2.0.16
- Python version: 3.10.6
Steps to reproduce
- Accidentally remove remotes.json from ~/remotes.json
- Try to re-add conancenter
- Got an exception
Logs
$ conan remote add conancenter https://center.conan.io
ERROR: Traceback (most recent call last):
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\site-packages\conan\cli\cli.py", line 270, in main cli.run(args)
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\site-packages\conan\cli\cli.py", line 180, in run command.run(self._conan_api, args[0][1:])
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\site-packages\conan\cli\command.py", line 142, in run sub.run(conan_api, parser, *args)
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\site-packages\conan\cli\command.py", line 156, in run info = self._method(conan_api, parent_parser, self._parser, *args)
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\site-packages\conan\cli\commands\remote.py", line 78, in remote_add conan_api.remotes.add(r, force=args.force, index=args.index)
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\site-packages\conan\api\subapi\remotes.py", line 66, in add return RemoteRegistry(self._remotes_file).add(remote, force=force, index=index)
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\site-packages\conans\client\cache\remote_registry.py", line 163, in add remotes = self._load_remotes()
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\site-packages\conans\client\cache\remote_registry.py", line 151, in _load_remotes return _Remotes.load(self._filename)
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\site-packages\conans\client\cache\remote_registry.py", line 33, in load data = json.loads(text)
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads return _default_decoder.decode(s)
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\AlexF\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
ERROR: Expecting value: line 1 column 1 (char 0)
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
memsharded commentedon Jan 22, 2024
Hi @leha-bot
Thanks for your report.
It seems there is something different there, I can't reproduce:
works fine. Can you please try the above commands?
leha-bot commentedon Jan 22, 2024
Oh, it seems that the simple deletion is not sufficient to reproduce, I had had some another remotes (excluding conancenter) in that
remotes.json
, andconancenter
was explicitly excluded (for test purposes on internal infra), seems this is a important detail for this, would try to reproduce it again...memsharded commentedon Jan 22, 2024
I am afraid I can't reproduce with that info either. Trying to add, remove, etc, doesn't make it fail like that.
I think the key is here:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This only happens if the json file is corrupted and not valid json. Maybe your remotes.json was broken? Someone accidentally touched it? If not, can you please try to provide steps to reproduce the error? Thanks!
memsharded commentedon Jan 24, 2024
Hi @leha-bot
Any feedback here? Thanks!
leha-bot commentedon Feb 11, 2024
hello, sorry for late responce. It seems that the weird symbol was from PowerShell 'New-Item' (but I'm not sure). From my friends I heard that Powershell sometimes likes to add the Unicode BOM symbol in generated files (e.g., after pipelining like
someprog > my.txt
)I think that if you have any resources, then it would be good to add the 'fool check' for weird BOM/file size (I saw some similar in YouCompleteMe Vim plugin for LSP: https://github.com/ycm-core/ycmd/pull/1680/files)
memsharded commentedon Feb 11, 2024
No prob, thanks for following up :)
I see. In general this fie is managed with the
conan remote
command, it makes sense now the behavior if powershell is adding extra characters unexpected. I also think that not only the characters, but also the encoding might be different.Seems a bit overkill at the moment, the check adds some complexity and cost too, I'll check with the team for more opinions.
memsharded commentedon Feb 13, 2024
I have discussed with the team, and yes, it seems a bit overkill at the moment
I am moving this to the docs, to clarify all files are
utf-8
without bom headers. Thanks for the feedback!