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

How to Fix: brew doctor giving error on a directory that has been removed

Error fixing brew doctor issue with removed directory

Quick Answer: Try running brew doctor again after verifying the directory has been completely removed and its contents are no longer accessible.

The error 'Some directories in your path end in a slash' occurs when Homebrew detects a directory in the system's PATH that ends with a trailing slash. This can cause issues with other commands, including brew doctor. The affected directory is typically a macOS application or library directory.

This error can be frustrating for Linux newcomers as it may seem like the issue has been resolved by deleting the application or library. However, the problem persists due to how macOS handles directories in the PATH.

🔍 Why This Happens

  • The primary cause of this error is that macOS stores the path to an application or library directory with a trailing slash. When Homebrew checks the system's PATH for these directories, it detects the trailing slash and reports the issue.
  • Another possible cause is that the directory itself still contains files or other contents, even though its parent directory has been deleted.

🚀 How to Resolve This Issue

Editing system configuration to remove trailing slashes

  1. Step 1: Open the Terminal app on your Mac and run the following command to edit the system configuration file: nano /etc/paths
  2. Step 2: Locate the line that contains the path to the affected directory, which ends with a trailing slash. For example: /Applications/Mkvtoolnix.app/Contents/MacOS/
  3. Step 3: Delete the trailing slash at the end of the line using the following command: sudo sed -i '' 's//$//g' /etc/paths'
  4. Step 4: Restart the Terminal app or run brew doctor again to verify that the error has been resolved.

Deleting remaining contents of the affected directory

  1. Step 1: Locate the parent directory of the deleted application or library using the following command: ls -l /Applications/Mkvtoolnix.app/Contents/
  2. Step 2: Delete any remaining files or directories within the parent directory using the following command: rm -rf /Applications/Mkvtoolnix.app/Contents/
  3. Step 3: Run brew doctor again to verify that the error has been resolved.

✨ Wrapping Up

To resolve the 'brew doctor' error of a directory ending in a trailing slash, edit the system configuration file to remove the trailing slash or delete any remaining contents of the affected directory. This should resolve the issue and allow Homebrew to run correctly.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions