tauri-dotenv-working-directory

Load .env files from the correct path in Tauri apps with dotenvy.

Updated Jan 23, 2026
One-click install
npx skills add https://github.com/strataga/claude-skill-inception --skill tauri-dotenv-working-directory
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tauri-dotenv-working-directory
Source: https://github.com/strataga/claude-skill-inception/tree/main/tauri-dotenv-working-directory
Command: npx skills add https://github.com/strataga/claude-skill-inception --skill tauri-dotenv-working-directory

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Fix for Tauri app not loading .env file with dotenvy. Use when: (1) Environment variables return not set errors in Tauri commands, (2) dotenvy::from_filename() fails with relative paths like ../../.env, (3) API keys or config work locally but not in Tauri app, (4) GhostClient::from_env() or similar fails with missing env vars. The fix is that cargo tauri dev runs with CWD at project root, not at ui/src-tauri, so use .env not ../../.env.

Core Features & Use Cases

  • Corrects the working directory context for dotenvy in Tauri dev.
  • Implements a multi-path loading approach to locate the .env file.
  • Verifies critical environment variables at startup to prevent silent failures.

Quick Start

Add a small multi-path env loader to your Tauri entry point and verify env vars load correctly during development. Then run cargo tauri dev from the project root to ensure GHOST_URL and other keys are available.

Frequently Asked Questions about tauri-dotenv-working-directory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does dotenvy fail to load .env files in my Tauri app?

Tauri environment variables return not set errors because dotenvy uses incorrect relative paths during development. Since cargo tauri dev runs with the working directory at the project root, paths like ../../.env fail to locate the file, requiring a multi-path loading approach.

How do I load environment variables in a Tauri app using dotenvy?

To load environment variables in a Tauri app, add a multi-path env loader to your entry point and verify critical variables at startup. Run cargo tauri dev from the project root so API keys and config like GHOST_URL are available without missing env vars errors.

Does Tauri run cargo dev from the project root or the src-tauri directory?

Cargo tauri dev runs with the current working directory at the project root, not at ui/src-tauri. This working directory context means relative paths like ../../.env fail to resolve, so .env files must be loaded directly from the root context.

What is the best way to verify API keys are loaded in Tauri development?

The best way to verify API keys in Tauri development is to implement explicit environment-variable verification at startup. This prevents silent failures when GhostClient::from_env() or similar functions try to read missing config variables from incorrectly loaded .env files.

Can I use dotenvy multi-path loading to fix missing config in Tauri commands?

Yes, you can use a multi-path loading approach to fix missing config in Tauri commands. By checking multiple potential file locations and verifying critical environment variables at startup, you prevent silent failures when API keys work locally but not in the Tauri app.