Setting up ispell and Emacs on Mac OS X

I was trying to setup flyspell mode on new Mac and whenever i do

flyspell-buffer

but Emacs was throwing error -

Problem - Flyspell does not work with Emacs. Can't find ispell.

Mac OS X does not come with ispell or its replacement aspell. So the first thing is to install aspell using brew.

brew install aspell

Now to tell emacs to use aspell instead of ispell.

(setq ispell-program-name "aspell")

Problem

Even though, aspell is installed properly, Emacs is not able to find it in the path.

Solution

Instead of just aspell, specify the full path to the aspell executable.

(setq ispell-program-name "/usr/local/bin/aspell")

There were other solutions mentioned on the internet like updating the PATHenv variable and exec-path variable with usr/local/bin but it did not work for me.