Common issues and their solutions when using Codesi Programming Language.
Error:
Error: Cannot open file 'script.cds'
Solution:
# Check file exists
ls script.cds
# Run with full path
codesi /full/path/to/script.cds
# Check file extension
# Must be .cds not .txt or otherIssue: Program runs but shows nothing
Solution:
// Check if you're using likho()
// ❌ Wrong
"Hello World"
// ✅ Correct
likho("Hello World")
// Check if variables are printed
x = 10
likho(x) // Must use likho()
Issue: Program stops in middle
Solution:
// Check for errors before stopping point
try {
// Your code
} catch (e) {
likho("Error:", e.message)
}
// Check for break statements
har i se 1 tak 10 {
agar (i == 5) {
break // This stops loop!
}
}
Error:
Error starting REPL
Solution:
# Check Python version
python3 --version # Must be 3.7+
# Try with explicit python
codesi
Issue: exit or quit doesn't work
Solution:
# Try these:
exit()
quit()
# Or press:
Ctrl+C (then type exit())
Ctrl+D (Linux/Mac)
Ctrl+Z (Windows)
Issue: Variables disappeared after error
Solution:
// REPL keeps variables unless:
// 1. You restart REPL
// 2. Error crashes REPL
// 3. You use time machine peeche()
// To preserve work:
// 1. Save important code to .cds file
// 2. Use history() to see past commands
Issue: Can't write functions in REPL
Solution:
// Codesi supports multi-line!
// Just start with { and it continues
codesi:1> karya add(a, b) {
...> vapas a + b
...> }
// Or write single line
codesi:1> karya add(a, b) { vapas a + b }
Error:
Line 5 par '}' ka unexpected use hai
Solution:
// Check matching braces
// ❌ Wrong - missing closing brace
agar (x > 5) {
likho("Big")
// ✅ Correct
agar (x > 5) {
likho("Big")
}
// Use editor with brace matching!
Error:
Line 3 par '(' ki ummeed thi
Solution:
// Conditions need parentheses
// ❌ Wrong
agar x > 5 {
likho("Big")
}
// ✅ Correct
agar (x > 5) {
likho("Big")
}
Error:
Line 7 par galat assignment hai
Solution:
// Can't assign to expressions
// ❌ Wrong
x + y = 10
// ✅ Correct
result = x + y
// Can assign to variables, array indices, object properties
x = 10 // ✅
arr[0] = 5 // ✅
obj.naam = "Raj" // ✅
Error:
Unterminated string
Solution:
// Check matching quotes
// ❌ Wrong
naam = "Rishaank
// ✅ Correct
naam = "Rishaank"
// Use same quote type
naam = "Rishaank" // ✅
naam = 'Rishaank' // ✅
naam = "Rishaank' // ❌ Mismatch
Error:
Variable 'x' define nahi hai
Solution:
// Define variable before using
// ❌ Wrong
likho(naam)
// ✅ Correct
naam = "Rishaank"
likho(naam)
// Check spelling
naame = "Rishaank"
likho(naam) // ❌ Typo: naam vs naame
Error:
Zero se divide nahi kar sakte
Solution:
// Check before dividing
// ❌ Wrong
result = 10 / 0
// ✅ Correct
agar (b != 0) {
result = a / b
} nahi_to {
likho("Cannot divide by zero")
}
// Or use try-catch
try {
result = a / b
} catch (e) {
likho("Error:", e.message)
}
Error:
Index range ke bahar hai
Solution:
arr = [1, 2, 3]
// ❌ Wrong
likho(arr[10]) // Only 3 elements!
// ✅ Correct - check length first
agar (10 < arr.lambai()) {
likho(arr[10])
} nahi_to {
likho("Index too large")
}
// Use negative indices for end
likho(arr[-1]) // Last element
Error:
Type mismatch in operation
Solution:
// Can't mix incompatible types
// ❌ Wrong
result = "10" * 2 // String * Number
// ✅ Correct - convert first
result = int_bnao("10") * 2 // 20
// Check types
agar (int_hai(value)) {
result = value * 2
}
Error:
Function 'xyz' define nahi hai
Solution:
// Define function before calling
// ❌ Wrong
greet("Raj")
karya greet(naam) {
likho("Hello", naam)
}
// ✅ Correct - define first
karya greet(naam) {
likho("Hello", naam)
}
greet("Raj")
// Check spelling and JAADU suggestions
likho("Hello") // JAADU suggests 'likho'
Error:
'break' sirf loop ke andar use kar sakte hain
Solution:
// Only use break/continue inside loops
// ❌ Wrong
agar (x > 5) {
break // Not in a loop!
}
// ✅ Correct
har i se 1 tak 10 {
agar (i == 5) {
break // Inside loop
}
}
Issue: Code takes too long to run
Solution:
1. Check for infinite loops:
// ❌ Infinite loop
jabtak (sach) {
likho("Forever")
// Missing break!
}
// ✅ Add exit condition
jabtak (sach) {
input = input_lo("Command: ")
agar (input == "exit") {
break
}
}
2. Optimize recursive functions:
// ❌ Slow - recalculates
karya fibonacci(n) {
agar (n <= 1) vapas n
vapas fibonacci(n-1) + fibonacci(n-2)
}
// ✅ Fast - iterative
karya fibonacci(n) {
agar (n <= 1) vapas n
a = 0
b = 1
har i se 2 tak n + 1 {
temp = a + b
a = b
b = temp
}
vapas b
}
3. Disable Samjho/Time Machine:
// These add overhead
samjhao_off()
time_machine_off()
Issue: Program uses too much RAM
Solution:
1. Time Machine snapshots:
// Limit snapshots
time_machine_on(50) // Instead of default 100
// Or disable
time_machine_off()
2. Large arrays:
// Don't create unnecessarily large arrays
// Process in chunks instead
A: JAADU only works with --jaadu flag:
codesi --jaaduDefault mode only shows suggestions.
A: REPL doesn't auto-save. Copy your code to a .cds file:
// Save important code as you write
// Use history() to see past commands
A: Not directly. Codesi is a standalone interpreter. Use:
# In Python
import subprocess
result = subprocess.run(['python', 'codesi_production.py', 'script.cds'])A: Codesi uses plain text output. For colored output, you'd need terminal support.
A: Use:
clear()
Or use terminal command:
- Windows:
cls - Mac/Linux:
clear(Ctrl+L)
A: No. Codesi is independent of Python libraries. It has its own built-in functions.
A: Use these tools:
- Samjho:
samjhao_on()- Explain execution - Time Machine:
time_machine_on()- Navigate history - Try-catch: Catch errors
- likho(): Print debug info
A: Codesi doesn't save logs by default. To save:
# Redirect output to file
codesi script.cds > output.log 2>&1A: Add try-catch at top level:
try {
// Your entire program
} catch (e) {
likho("Fatal error:", e.message)
}
- Check Documentation:
docs/folder - Search Issues: GitHub Issues
- Ask Community: GitHub Discussions
- Report Bug: Open new issue with:
- Codesi version
- Python version
- Operating system
- Complete error message
- Minimal code to reproduce
- Checked this troubleshooting guide
- Searched existing issues
- Tried on latest version
- Can reproduce consistently
- Have minimal example
When something goes wrong:
- Read the error message - It usually tells you what's wrong
- Check line number - Error messages show line numbers
- Enable Samjho - See what's happening step by step
- Use Time Machine - Go back and check state
- Add likho() - Print variables to see values
- Simplify - Remove code until it works, then add back
- Check examples - Compare with working examples
- Ask for help - With specific error message and code
Avoid issues before they happen:
- Use JAADU mode while learning
- Enable Samjho for new concepts
- Write comments to explain logic
- Test frequently - Don't write too much before testing
- Use try-catch for risky operations
- Validate input - Check user input before using
- Check types - Use
prakar()when unsure - Read docs - Check syntax before using new features
Happy Coding! 🚀
If this guide helped you, consider contributing your own solutions!