How to resolve a permission error when installing gnuplot from homebrew

homebrewopen source

I am trying to install gnuplot on my mac. after trying brew install gnuplot, I get the following errors:

You must 'brew link lua jpeg' before gnuplot can be installed

And when I try brew link lua jpeg I get the following error:

Could not symlink file: /usr/local/Cellar/lua/5.1.4/include/lualib.h
/usr/local/include is not writable. You should change its permissions.

Any suggestion? BTW, my XCode and brew are updated.

Best Answer

sudo chown $(whoami) /usr/local/include
chmod +w /usr/local/include
brew link lua