Emacs GUI won't start when launched from the Terminal

When I type

brew install emacs

at the Terminal, the following message displays:

Warning: emacs 25.3 is already installed

However, when I type

emacs &

the only thing that happens is that the following message is displayed:

[1] 21302

but the Emacs GUI isn't launched. I have another apple computer where typing

emacs &

launches the Emacs GUI. How can I make the Emacs GUI launch by executing a command from the Terminal?


macOS Sierra Version 10.12.6


The installation command should end with the option --with-cocoa:

brew install emacs --with-cocoa

But first execute

brew uninstall emacs

or else Homebrew will refuse to reinstall Emacs.

As an alternative to brew install emacs --with-cocoa, Homebrew recommends running

brew cask install emacs

(you get this recommendation in the end of the brew install emacs --with-cocoa run). However, I've found that this doesn't work, and ends with the following error message:

Error: It seems there is already an App at '/Applications/Emacs.app'.


Acknowledgements

This answer is essentially copied from here.


Update as of July 23 2019: The --with-cocoa option is not supported any longer. Follow these steps.

  1. brew uninstall emacs
  2. rm -rf /Applications/Emacs.app/z
  3. brew cask install emacs