Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.hledger.journal file overwritten on -f path typo #1056

Closed
klacansky opened this issue Jun 23, 2019 · 11 comments

Comments

Projects
None yet
3 participants
@klacansky
Copy link

commented Jun 23, 2019

On Windows, the following command will overwrite the file Documents\.hledger.journal with an empty file. I sometimes make the typo with extra period in the path and I have to restore from backup. Version tested 1.14.1.

C:\Users\klacansky>hledger -f Documents.\.hledger.journal add
Creating hledger journal file C:\Users\klacansky\Documents.\.hledger.journal.
The hledger journal file "C:\Users\klacansky\Documents.\.hledger.journal" was not found.
Please create it first, eg with "hledger add" or a text editor.
Or, specify an existing journal file with -f or LEDGER_FILE.
@simonmichael

This comment has been minimized.

Copy link
Owner

commented Jun 23, 2019

Wow, thanks for the report. Would you be interested in debugging further ? Help available in http://irc.hledger.org.

@klacansky

This comment has been minimized.

Copy link
Author

commented Jun 26, 2019

On IRC, we determined the issue is the directory ending with a period '.', windows ignores it, but hledger does not, thus it will report the file does not exists, and proceed to create a new file '.hledger.journal'. However, when creating that file, windows removes the period at the end of the directory name, and thus overwrites the original file.

@alerque

This comment has been minimized.

Copy link
Collaborator

commented Jun 26, 2019

👏👏 Windows! When will you learn?

@simonmichael

This comment has been minimized.

Copy link
Owner

commented Jun 26, 2019

Ideas for resolution:

  • mention this issue for windows users in docs
  • on windows, check each part of the file path for a trailing period and warn or give an error
  • report this issue to the appropriate upstream haskell lib (base ?) and do the warning/error there
@simonmichael

This comment has been minimized.

Copy link
Owner

commented Jun 26, 2019

I recommend prioritizing it; I were not to keep backup, it would really be upsetting

@simonmichael simonmichael reopened this Jun 26, 2019

@simonmichael

This comment has been minimized.

Copy link
Owner

commented Jun 26, 2019

...you're right. I have pushed a fix. It should also be highlighted in docs (somewhere?) for users of older hledger versions. If someone wants to propagate this discussion to the upstream haskell lib, that might be a service to the community.

@simonmichael

This comment has been minimized.

Copy link
Owner

commented Jun 26, 2019

I've mentioned this issue & requirement at the end of add's documentation (27c01e8). But I'm not sure this is enough. Is there somewhere else appropriate that users of older hledger might notice ?

@simonmichael

This comment has been minimized.

Copy link
Owner

commented Jun 26, 2019

I guess we could do this same path check for all commands (not just add and hledger-web add), which would make it more likely to be noticed before it actually causes trouble. But no.. this would require an up to date hledger version, which doesn't have the problem.

@simonmichael

This comment has been minimized.

Copy link
Owner

commented Jun 26, 2019

So mention in next release notes and release announcement I guess. Adding it to the FAQ as well (even though it isn't one) might not hurt.

@klacansky

This comment has been minimized.

Copy link
Author

commented Jun 29, 2019

Thanks!

@klacansky klacansky closed this Jun 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.