A .env file is a text file that stores environment variables (like passwords, API keys, database URLs). It's loaded automatically by VS Code and many applications.
The project root is: /Users/arun.parmar/go/src/adk-python
This is where you see:
src/directoryconfig.inifilepyproject.tomlfile.venv/directory (if you have a virtual environment)
-
Open terminal
-
Navigate to project root:
cd /Users/arun.parmar/go/src/adk-python -
Create the file:
touch .env
-
Open it in VS Code:
code .env
-
Add your environment variables:
# Database URL (optional - config.ini already has it) # DATABASE_URL=postgresql://username:password@hostname:5432/database # Redbus ADG Configuration ADURL=your_ad_url_here ADU=your_ad_user_here ADP=your_ad_password_here REDBUS_ADG_MODEL=40 # Google/Gemini API Keys (for Gemini models) GOOGLE_API_KEY=your_google_api_key_here GEMINI_API_KEY=your_gemini_api_key_here # PostgreSQL Schema (optional) DB_SCHEMA=your_schema_name
-
Save the file (Cmd+S / Ctrl+S)
- In VS Code, right-click in the file explorer (left sidebar)
- Select "New File"
- Type
.envas the filename - Press Enter
- Add your environment variables
- Save
cd /Users/arun.parmar/go/src/adk-python && cat > .env << 'EOF'
ADURL=your_ad_url_here
ADU=your_ad_user_here
ADP=your_ad_password_here
REDBUS_ADG_MODEL=40
EOFThe .env file format is simple:
VARIABLE_NAME=value
ANOTHER_VAR=another_value
Important rules:
- No spaces around the
=sign - No quotes needed (unless the value contains spaces)
- One variable per line
- Lines starting with
#are comments
# This is a comment
# Database URL (optional - can also be set in config.ini)
DATABASE_URL=postgresql://username:password@hostname:5432/database
# Redbus ADG Configuration
ADURL=https://your-azure-gateway-url.com
ADU=your_username
ADP=your_password
REDBUS_ADG_MODEL=40
# Google/Gemini API Keys (for Gemini models)
GOOGLE_API_KEY=your_google_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here
# PostgreSQL Schema (optional)
DB_SCHEMA=your_schema_nameAfter creating .env:
- Restart VS Code debugger (F5)
- Check the logs - you should see environment variables are loaded
- Or test in Python:
import os print(os.getenv('ADURL'))
.env to git! It should already be in .gitignore. If not, add it:
echo ".env" >> .gitignoreSince your config.ini already has the database URL, you don't need to set DATABASE_URL in .env unless you want to override it.
You only need .env if you need:
- ADURL, ADU, ADP (for RedbusADG model)
- Or want to override database URL from environment