-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
hacktoberfestIssues awarding points for Hacktoberfest 2025!Issues awarding points for Hacktoberfest 2025!mediumWeight label for Hacktoberfest 2025 issuesWeight label for Hacktoberfest 2025 issues
Description
Bug Description
When users attempt to save a recipe for the first time, they encounter the error:
Can't save recipes "No such file or directory (os error 2)"
Root Cause
The save_recipe_to_file function in crates/goose/src/recipe/local_recipes.rs does not create the necessary directory structure before attempting to write the recipe file.
The function tries to save recipes to {config_dir}/recipes/ (e.g., ~/Library/Application Support/Block/goose/recipes/ on macOS), but if this directory doesn't exist, fs::write() fails with "No such file or directory".
When This Happens
- First-time users: The global recipe directory doesn't exist yet
- Fresh installations: The config directory structure hasn't been created
- Users who haven't used CLI features: Other goose features create config directories, but recipe saving doesn't
Affected Code
pub fn save_recipe_to_file(recipe: Recipe, file_path: Option<PathBuf>) -> anyhow::Result<PathBuf> {
let recipe_library_dir = get_recipe_library_dir(true);
let file_path_value = match file_path {
Some(path) => path,
None => generate_recipe_filename(&recipe.title, &recipe_library_dir),
};
let yaml_content = serde_yaml::to_string(&recipe)?;
fs::write(&file_path_value, yaml_content)?; // ← Fails if directory doesn't exist
Ok(file_path_value)
}Proposed Solution
Add directory creation before writing the file:
pub fn save_recipe_to_file(recipe: Recipe, file_path: Option<PathBuf>) -> anyhow::Result<PathBuf> {
let recipe_library_dir = get_recipe_library_dir(true);
let file_path_value = match file_path {
Some(path) => path,
None => generate_recipe_filename(&recipe.title, &recipe_library_dir),
};
// Create parent directory if it doesn't exist
if let Some(parent) = file_path_value.parent() {
fs::create_dir_all(parent)?;
}
let yaml_content = serde_yaml::to_string(&recipe)?;
fs::write(&file_path_value, yaml_content)?;
Ok(file_path_value)
}Evidence
Other parts of the codebase already handle this correctly:
crates/goose/src/config/base.rs:119:std::fs::create_dir_all(&config_dir)crates/goose/src/session/session_manager.rs:252:fs::create_dir_all(&session_dir)?
Steps to Reproduce
- Fresh goose installation
- Open goose desktop app
- Create a conversation
- Try to save it as a recipe
- Error occurs: "Can't save recipes 'No such file or directory (os error 2)'"
Environment
- Affects all platforms (macOS, Linux, Windows)
- Occurs in both desktop app and potentially CLI usage
- First-time users are most affected
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
hacktoberfestIssues awarding points for Hacktoberfest 2025!Issues awarding points for Hacktoberfest 2025!mediumWeight label for Hacktoberfest 2025 issuesWeight label for Hacktoberfest 2025 issues