Running the shell with a global alias alias -g dir="dir --color auto" leads to the following error on startup:
spaceship_dir:local:3: not valid in this context: --color

Spaceship version: 3.2.0
Zsh version: zsh 5.1.1 (x86_64-ubuntu-linux-gnu)
Zsh framework: none
Zsh plugin manager: none
Terminal emulator: GNOME Terminal
Operating system: Linux
.zshrcalias -g dir="dir --color auto"
autoload -U promptinit; promptinit
prompt spaceship
Modifying line 24 of sections/dir.zsh from
https://github.com/denysdovhan/spaceship-prompt/blob/dde0bafb94262be829efe8f926d3f012f9bddcf5/sections/dir.zsh#L24
to
local dir=""
seems to solve the problem.
Thank you for the report and PR @gurpreetatwal.
I'm unable to reproduce this with similar configuration.

Hmm, thats odd. You made it a global alias right?
Another (perhaps safer) option is:
local 'foo'
Technically, I believe there is a semantic difference between "empty value" and "no value."
Hmm, thats odd. You made it a global alias right?
Right, this will only repro with a global alias. I suspect @salmanulfarzy did not use a global alias, otherwise alias dir would have expanded to alias dir --color auto (and that command would have then failed instead of producing output).
It shouldn't matter too much in this case since the variable is assigned a value immediately after, but putting it in quotes best mimics the current behavior.
Sorry @gurpreetatwal @nfischer, Missed the global aliasing :man_facepalming:
This also happens on newer versions of Zsh and spaceship-prompt. This is not limited to local dir, Every unassigned local variable initializations are causing problems.
As noted in Zsh aliasing doc we should quote these variables.

.zshrcalias -g venv='source ./env/bin/activate'
autoload -Uz promptinit; promptinit
prompt spaceship
Most helpful comment
Sorry @gurpreetatwal @nfischer, Missed the global aliasing :man_facepalming:
This also happens on newer versions of
Zshandspaceship-prompt. This is not limited tolocal dir, Every unassigned local variable initializations are causing problems.As noted in
Zshaliasing doc we should quote these variables..zshrc