Software⏱️ 3 min read📅 2026-06-19

How to Fix: How to fix error: Could not symlink lib/gcc/4.9?

Error fixing libgcc symlink issue with homebrew on macOS.

Quick Answer: Adjust the permissions of /usr/local/lib/gcc to allow writing, then try brew link gcc again.

The 'Could not symlink lib/gcc/4.9' error occurs when Homebrew is unable to link the GCC library due to permission issues with the '/usr/local/lib/gcc' directory.

This error can be frustrating for users trying to install or update GCC on their macOS systems, as it prevents them from accessing the latest version of the compiler.

🔍 Why This Happens

  • The primary reason for this error is that Homebrew requires write permissions to the '/usr/local/lib/gcc' directory. This is a security feature to prevent unauthorized modifications to system libraries.
  • However, in some cases, the issue may also be caused by incorrect permissions or ownership of the directory.

🛠️ Step-by-Step Verified Fixes

Adjusting Permissions and Ownership

  1. Step 1: Open the Terminal app on your MacBook Pro and navigate to the '/usr/local/lib/gcc' directory using the 'cd' command. For example: cd /usr/local/lib/gcc
  2. Step 2: Use the 'sudo' command to change the ownership of the directory to the current user's ID, for example: sudo chown -R $USER:$USER /usr/local/lib/gcc
  3. Step 3: Next, use the 'chmod' command to change the permissions of the directory to allow write access. For example: chmod -R u+w /usr/local/lib/gcc
  4. Step 4: Restart Homebrew by running the 'brew update' and 'brew install gcc' commands.

Resetting Homebrew's Cache

  1. Step 1: Open the Terminal app on your MacBook Pro and run the 'brew cleanup' command to remove any unnecessary files from the Homebrew cache.
  2. Step 2: Next, run the 'brew update' command to refresh the list of available packages.
  3. Step 3: Finally, attempt to install GCC again using the 'brew install gcc' command.

✨ Wrapping Up

By following these steps, you should be able to resolve the 'Could not symlink lib/gcc/4.9' error and successfully install or update GCC on your macOS system.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions