স্কিপ করে মূল কন্টেন্ট এ যান

⚙️ Configuration Errors এবং সমাধান

FLX CLI configuration সংক্রান্ত সমস্যা এবং তাদের সমাধান।

📁 Config File Issues

1. ".flxrc.json file not found"

Error Message: Configuration file .flxrc.json not found

কারণ: Project directory তে configuration file নেই।

সমাধান:

# Manual config file তৈরি করুন
flx config --state getx

# অথবা basic config তৈরি করুন
echo '{
"stateManagement": "getx",
"packages": {
"http": true,
"shared_preferences": true
}
}' > .flxrc.json

# Config verify করুন
flx config

2. "Invalid JSON syntax"

Error Message: Invalid JSON in .flxrc.json at line 5

কারণ: JSON format ভুল, comma missing, বা syntax error।

সমাধান:

# JSON validator ব্যবহার করুন
# https://jsonlint.com/

# Common JSON errors:
# ❌ Missing comma
{
"stateManagement": "getx"
"packages": {} // Missing comma after getx
}

# ✅ Correct
{
"stateManagement": "getx",
"packages": {}
}

# ❌ Trailing comma
{
"stateManagement": "getx",
"packages": {}, // Trailing comma not allowed
}

# Config reset করুন যদি fix করতে না পারেন
flx config --reset

3. "Permission denied writing config"

Error Message: Permission denied: .flxrc.json

কারণ: File write permission নেই।

সমাধান:

# File permission check করুন
ls -la .flxrc.json

# Permission change করুন
chmod 644 .flxrc.json

# Directory permission check করুন
ls -la . | grep -E "^\."

# Directory permission fix করুন
chmod 755 .

🔧 State Management Errors

1. "Invalid state management option"

Error Message: Invalid state management 'redux'. Valid options: getx, bloc

কারণ: Unsupported state management library।

সমাধান:

# Supported options check করুন
flx config --help

# Valid state management options:
flx config --state getx
flx config --state bloc

# Future support (coming soon):
# flx config --state provider
# flx config --state riverpod

2. "State management dependencies missing"

Error Message: GetX dependency not found in pubspec.yaml

কারণ: Selected state management package project এ add করা নেই।

সমাধান:

# GetX এর জন্য
flutter pub add get

# BLoC এর জন্য
flutter pub add flutter_bloc
flutter pub add bloc

# Manual add pubspec.yaml এ
dependencies:
get: ^4.6.5
# অথবা
flutter_bloc: ^8.1.3
bloc: ^8.1.2

flutter pub get

3. "Conflicting state management"

Error Message: Multiple state management libraries detected

কারণ: Project এ multiple state management libraries আছে।

সমাধান:

# pubspec.yaml check করুন
grep -E "(get|bloc|provider|riverpod)" pubspec.yaml

# Unnecessary packages remove করুন
flutter pub remove get # যদি BLoC ব্যবহার করতে চান
# অথবা
flutter pub remove flutter_bloc bloc # যদি GetX ব্যবহার করতে চান

# Config update করুন
flx config --state getx # অথবা bloc

📦 Package Configuration Errors

1. "Package version conflict"

Error Message: Package 'http' version conflict

কারণ: Dependency version mismatch।

সমাধান:

# Version conflict resolve করুন pubspec.yaml এ
dependency_overrides:
http: ^0.13.5

# অথবা specific version set করুন
dependencies:
http: ^0.13.5

# Clean এবং get করুন
flutter clean
flutter pub get

# Config update করুন specific versions সহ
flx config --package-versions '{
"http": "^0.13.5",
"shared_preferences": "^2.0.15"
}'

2. "Unknown package configuration"

Error Message: Unknown package 'unknown_package' in config

কারণ: Config এ invalid package name।

সমাধান:

# Valid packages list check করুন
flx config --list-packages

# Supported packages:
# - http
# - dio
# - shared_preferences
# - hive
# - sqflite
# - floor

# Invalid package remove করুন
flx config --remove-package unknown_package

# অথবা config reset করুন
flx config --reset packages

3. "Package auto-detection failed"

Error Message: Failed to detect packages in pubspec.yaml

কারণ: pubspec.yaml file corrupt বা missing।

সমাধান:

# pubspec.yaml validate করুন
flutter pub get

# pubspec.yaml format check করুন
# Must be valid YAML format

# Sample valid pubspec.yaml:
name: my_app
description: My Flutter app

dependencies:
flutter:
sdk: flutter
get: ^4.6.5
http: ^0.13.5

# Package auto-detection force করুন
flx config --detect-packages

🏗️ Generation Configuration Errors

1. "Invalid folder structure configuration"

Error Message: Custom folder 'invalid_folder' not allowed

কারণ: Invalid custom folder name।

সমাধান:

# Valid folder names:
flx config --features-folder features
flx config --domain-folder domain
flx config --data-folder data
flx config --presentation-folder presentation

# Custom folders (valid examples):
flx config --features-folder modules
flx config --domain-folder business
flx config --data-folder repositories
flx config --presentation-folder ui

# Invalid characters avoid করুন:
# - No spaces
# - No special characters (except underscore)
# - Must start with letter

2. "Template configuration error"

Error Message: Template 'custom_template' not found

কারণ: Custom template file missing।

সমাধান:

# Template directory check করুন
ls -la templates/

# Required template structure:
templates/
├── feature/
│ ├── entity.dart.mustache
│ ├── model.dart.mustache
│ └── controller.dart.mustache
└── model/
└── model.dart.mustache

# Default templates reset করুন
flx config --reset-templates

# Custom template add করুন
flx config --add-template custom_template ./path/to/template

3. "Code generation options conflict"

Error Message: Freezed and manual toJson cannot be used together

কারণ: Conflicting code generation options।

সমাধান:

# Conflicts avoid করুন:

# ✅ Use Freezed
flx config --freezed true --json-annotation false

# ✅ Use manual JSON
flx config --freezed false --json-annotation true

# Check current config
flx config --show code-generation

# Reset conflicting options
flx config --reset code-generation

🌍 Global vs Local Config Issues

1. "Global config overriding local"

Error Message: Local configuration ignored

কারণ: Global config priority বেশি।

সমাধান:

# Config priority order:
# 1. Local (.flxrc.json) - highest priority
# 2. Global (~/.flx/config.json)
# 3. Default

# Local config তৈরি করুন
flx config --local --state getx

# Global config disable করুন temporarily
mv ~/.flx/config.json ~/.flx/config.json.backup

# Local config verify করুন
flx config --show-source

2. "Global config corrupted"

Error Message: Global configuration file corrupted

কারণ: Global config file damaged।

সমাধান:

# Global config location check করুন
echo ~/.flx/config.json

# Backup তৈরি করুন (যদি recoverable হয়)
cp ~/.flx/config.json ~/.flx/config.json.backup

# Global config reset করুন
flx config --global --reset

# Fresh global config তৈরি করুন
flx config --global --state getx --http true

3. "Config inheritance issues"

Error Message: Local config not inheriting from global

কারণ: Config inheritance chain broken।

সমাধান:

# Config inheritance debug করুন
flx config --debug --show-inheritance

# Manual inheritance fix করুন
# Local config এ inherit flag add করুন:
{
"inherit": true,
"stateManagement": "bloc" // Override specific options only
}

# অথবা full local config তৈরি করুন
flx config --local --from-global

🔍 Environment Variable Issues

1. "Environment variable override not working"

Error Message: Environment variables ignored

কারণ: Environment variable names ভুল।

সমাধান:

# Correct environment variable names:
export FLX_STATE_MANAGEMENT=getx
export FLX_GENERATE_TESTS=true
export FLX_USE_FREEZED=false

# Check environment variables
env | grep FLX_

# Verify override working
flx config --show-env

# Clear environment variables
unset FLX_STATE_MANAGEMENT

2. "Environment variable type mismatch"

Error Message: Invalid boolean value 'yes' for FLX_GENERATE_TESTS

কারণ: Environment variable value format ভুল।

সমাধান:

# Boolean values:
export FLX_GENERATE_TESTS=true # ✅ Correct
export FLX_GENERATE_TESTS=false # ✅ Correct
export FLX_GENERATE_TESTS=yes # ❌ Wrong
export FLX_GENERATE_TESTS=1 # ❌ Wrong

# String values:
export FLX_STATE_MANAGEMENT=getx # ✅ Correct
export FLX_STATE_MANAGEMENT=GetX # ❌ Case sensitive

# Number values:
export FLX_MAX_FEATURES=10 # ✅ Correct
export FLX_MAX_FEATURES=ten # ❌ Wrong

🧪 Testing Configuration Errors

1. "Test configuration not applied"

Error Message: Test files not generated despite config

কারণ: Test generation config ঠিকভাবে set হয়নি।

সমাধান:

# Test generation enable করুন
flx config --generate-tests true

# Test framework set করুন
flx config --test-framework flutter_test

# Test dependencies check করুন
flutter pub add --dev flutter_test
flutter pub add --dev mockito
flutter pub add --dev build_runner

# Config verify করুন
flx config --show testing

2. "Mock generation configuration error"

Error Message: Mockito configuration missing

কারণ: Mock generation setup incomplete।

সমাধান:

# Mockito properly configure করুন
flx config --mockito true
flx config --build-runner true

# Required dependencies:
dev_dependencies:
mockito: ^5.3.2
build_runner: ^2.3.3

# Test annotation configure করুন
flx config --test-annotations true

# Generate mocks command
flutter packages pub run build_runner build

🔧 Quick Config Fixes

Reset All Configuration

# Complete reset
flx config --reset --force

# Specific section reset
flx config --reset packages
flx config --reset state-management
flx config --reset testing

Config Validation

# Validate current config
flx config --validate

# Show config problems
flx config --check

# Fix common issues automatically
flx config --auto-fix

Config Backup and Restore

# Backup config
cp .flxrc.json .flxrc.json.backup

# Restore config
cp .flxrc.json.backup .flxrc.json

# Export config for sharing
flx config export my-config.json

# Import config
flx config import my-config.json

✅ Prevention Tips

  1. Regular config validation: flx config --validate
  2. Backup configurations: Before major changes
  3. Use version control: Add .flxrc.json to git
  4. Team synchronization: Share config files
  5. Environment testing: Test in clean environment
  6. Documentation: Document custom configurations

Configuration problems solve করার জন্য: step by step debugging করুন এবং backup রাখুন! ⚙️