rage icon indicating copy to clipboard operation
rage copied to clipboard

UX: rage-keygen error output can be more intuitive

Open Supermarcel10 opened this issue 1 year ago • 1 comments

General Info

The error message was not as intuitive as it could have been.

It would be more intuitive for the keygen to create a directory if one doesn't exist for the file, or at the very least mention that the directory does not exist rather than it failing to open.

As this improvement could be undesirable for the user or cause issues, it would be worthwhile to also have a flag to prevent creation of any directories (if applicable for the user).

What were you trying to do

I was trying to generate a new key pair.

What happened

The console output:

~$ rage-keygen -o ~/.config/age/age.key
Error: Failed to write to output: Failed to open file '/home/marcel/.config/age/age.key'

[ Did rage not do what you expected? Could an error be more useful? ]
[ Tell us: https://str4d.xyz/rage/report  

The output implies that a file exists which is trying to be opened.

What I had to do instead was create the directory manually with mkdir, and then create the key pair file within it.

Supermarcel10 avatar Sep 22 '24 16:09 Supermarcel10

I believe it's generally the case for Unix tools that directories are not created automatically. Some examples:

$ ./age-keygen -o does-not-exist/test-530.key
age-keygen: error: failed to open output file "does-not-exist/test-530.key": open does-not-exist/test-530.key: no such file or directory
age-keygen: report unexpected or unhelpful errors at https://filippo.io/age/report

$ ssh-keygen -f does-not-exist/test-530.key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Saving key "does-not-exist/test-530.key" failed: No such file or directory

So I'm going to have rage-keygen also continue to fail if the directory does not exist, but I'll see if I can improve the error message.

str4d avatar Nov 03 '24 07:11 str4d