mechboxes / mech

Easy command line virtual machines for VMWare
https://mechboxes.github.io/mech/
MIT License
311 stars 49 forks source link

json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes if `~/.mech/data/index` was broken #59

Open dodo5522 opened 5 years ago

dodo5522 commented 5 years ago

If I mech up, the following log has come.

bash-3.2$ mech up
Traceback (most recent call last):
  File "/usr/local/bin/mech", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/mech/__main__.py", line 39, in main
    return Mech(arguments)()
  File "/usr/local/lib/python3.7/site-packages/mech/command.py", line 89, in __call__
    obj = klass(arguments)
  File "/usr/local/lib/python3.7/site-packages/mech/mech.py", line 602, in up
    utils.index_active_instance(instance_name)
  File "/usr/local/lib/python3.7/site-packages/mech/utils.py", line 458, in index_active_instance
    'path': path,
  File "/usr/local/lib/python3.7/site-packages/mech/utils.py", line 201, in settle_instance
    instances = json.loads(uncomment(fp.read()))
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 3 (char 4)

The error comes from broken index file. I can't know why the index was broken...

$ cat ~/.mech/data/index
{

$ 

I want to know how to recover by indication of log message like below.

$ mech up
Index file seems broken. Try to remove
/Users/takashi/.mech/data/index.