Troubleshooting
Most problems fall into a few groups. Otter error messages name the line, say what went wrong in plain words, and often suggest a fix - start by reading them.
Installation and PATH
"Running scripts is disabled on this system": allow scripts for the current terminal only. It expires when you close the window.
PowerShell
Set-ExecutionPolicy -Scope Process Bypass
"otter is not recognized as an internal or external command": the terminal was opened before Otter was added to your PATH. Close it and open a new one. To check the PATH, run:
PowerShell
[Environment]::GetEnvironmentVariable('Path', 'User')
You can always run Otter by its full path, for example & "C:\Tools\Otter\otter.cmd" hello.ot.
Syntax errors
A syntax error means Otter could not read the program. It shows the line, a marker where the problem is, and a suggestion. These are the real messages:
Output
Otter Syntax Error
Line 1:
say "Hello
^
This string never closes.
Try:
Add a closing quote.
Fix: close the text with a second double quote.
Runtime errors
A runtime error means the program is well formed but something went wrong while it ran.
Output
Otter Runtime Error
Line 1:
say greeting
Otter could not find the variable "greeting". It has not been given a value yet.
Try:
greeting is 0
Fix: give the variable a value before you use it. Otter never guesses that a missing variable means empty or false.
Output
Otter Runtime Error
Line 1:
say 10 divided by 0
I cannot divide by zero.
Fix: check the divisor first, with an if, before dividing.
Output
Otter Runtime Error
Line 4:
greet
"greet" needs 1 value but was given 0.
Try:
greet person
Fix: pass every value the function asks for.
Output
Otter Runtime Error
Line 2:
add 1 to score
I can only add to a number or a list, but "score" holds some text.
Fix: make sure the variable holds a number: score is 0, not score is "high".
File errors
Output
Otter Runtime Error
Line 1:
read "missing.txt" into content
I could not find a file called "missing.txt".
Try:
if file "missing.txt" exists
Fix: check the name and folder, or test for the file first. Relative paths are relative to the folder you ran otter from.
Otter
if file "missing.txt" exists
read "missing.txt" into content
say content
otherwise
say "There is no missing.txt yet."
.
Common mistakes
- A property is written property of thing (name of person), never person.name.
- A block ends with a period on its own line. A period is never used for anything else.
- Some words Otter uses in statements, such as percent, cannot be variable names. Pick another (rate instead of percent).
- One calculation per statement: bill times rate make product, then product divided by 100 make tip.
Reporting a problem
If Otter reports "a bug in Otter", or a message is unclear, please open an issue with the smallest program that shows it, the exact message, your Otter version (otter --version), and your Windows version.
Open an issue on GitHub
The otter command