snowskeleton / ynam

Mint-to-YNAB translator
Apache License 2.0
38 stars 0 forks source link

Error when running ynam --quickstart #36

Closed asadakbar closed 1 year ago

asadakbar commented 1 year ago

Thanks for creating ynam. I installed it through pip and then ran ynam --quickstart. After I enter my mint username, I hit this error

Traceback (most recent call last):
  File "/Users/Asad/.asdf/installs/python/3.11.3/bin/ynam", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/Asad/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/ynam/main.py", line 19, in main
    handleArgs()
  File "/Users/Asad/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/ynam/main.py", line 58, in handleArgs
    sys.exit(run())
             ^^^^^
  File "/Users/Asad/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/ynam/quickstart.py", line 41, in run
    updateStash('mint_username', username.strip())
  File "/Users/Asad/.asdf/installs/python/3.11.3/lib/python3.11/site-packages/ynam/ynam_secrets.py", line 59, in updateStash
    with open(arg('secrets_file'), 'w+') as file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/Asad/.ynam/secrets.json'

I didn't see anything about creating a .ynam folder or secrets.json file in the readme, so I'm wondering if there is an install step I'm missing.

asadakbar commented 1 year ago

I don't know python but from my reading of the ynam_secrets.py file, in the loadSecrets function, the secrets.json file is trying to get loaded. But I don't see anywhere in the quicksetup code where the file is initially created. I created an empty .ynam/secrets.json file and ran the quickstart command again, but am now hitting this error WARNING:ynam:Error reading /Users/Asad/.ynam/secrets.json; assuming it to be empty.

snowskeleton commented 1 year ago

The second error you get shouldn't be a stopping error. If the secrets file is empty or malformed, the idea is that it's just overwritten with whatever new values you supply. Is that not happening?

snowskeleton commented 1 year ago

The first issue seems to be because I wasn't creating the right directory structure. I added a line that makes sure the .ynam directory exists before trying to create a file in it.

asadakbar commented 1 year ago

Thanks for the change. It works now.