Error saving with Preferences crate

I am using the Preferences crate to save some app configuration data. No matter what value I use for “key” it fails. Not much output to help me understand why. Does anyone know how to make this work?


use preferences::{AppInfo, PreferencesMap, Preferences};

fn save_config_file() {
    let APPINFO = AppInfo{name: "preferences", author: ""};
    let config_location = "config/solid";
    // these values also fail
    // let config_location = "config";
    // let config_location = "~/config"

    let mut data: PreferencesMap<String> = PreferencesMap::new();
    data.insert("data_source".to_string(), "memory".to_string());
    data.insert("computation".to_string(), "max".to_string());
    data.insert("pay_this_amount".to_string(), "13".to_string());

    let save_result =, config_location);

panicked at 'assertion failed: save_result.is_ok()'


What’s the output of println!("{:?}", save_result)?

I got this as a result of the println!:

result of save is: Err(Directory(InvalidAppInfo))

so I changed the AppInfo structure data to the following

let APPINFO = AppInfo{name: "preferences", author: "999999"};

I no longer get an error. The println output is:

result of save is: Ok(())

BUT, I cannot find a file with data.....anywhere. I have looked in my project target/debug directory. I looked in my home directory. I looked in root. Nothing.

So it says it saved, but where?


Try their fn to discover the base directory.

1 Like

oh. That's ugly, at least for my needs.