1

I've managed to wreck my Terminal of my Air's OS X (10.9.5) while running a sudo command (sudo mv git /etc/paths.d) during git installation. (Following https://stackoverflow.com/questions/4725389/how-to-get-started-with-git-on-mac)

Now I receive a continuous string of errors on every new Terminal window that I start, the first 3 lines of which are:

-bash: ???H??: command not found
-bash: command substitution: line 4: syntax error near unexpected token `('
-bash: command substitution: line 4: `:??H?u?H??HH?BH?E??H?? ]?ffff.?:?U??E???

enter image description here While the Terminal commands do go through after all the errors are listed, RStudio does not start, and the error pop-up states:

"Unexpected exception: Unmatched marking paranthesis ( or (. The error occurred while passing the regular expression fragment: ' " enter image description here This error stays even on reinstallation of RStudio (while R works correctly)

I've tried resetting the Terminal by deleting ~/Library/Preferences/com.apple.Terminal.plist but the error still persists.

Really appreciate your help!

--EDIT---

echo $PATH is also gives a string of errors, starting with /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:????:O"::D?M?A??H?

1
  • Also, the terminal continuously alternates between bash and perl 5.16 while the error list is printed, before finally settling on bash. Is there any way I can remove perl 5.16 to safely resolve this issue? Mar 11, 2017 at 21:06

1 Answer 1

0

Your PATH variable got contaminated by some irregular file content: either your git file in /etc/paths.d/, /etc/profile or ~/.MacOSX/environment.plist or all three are corrupted.

Use shiftcmdG in Finder to jump to each of the folders and check the content of them.

/etc/paths.d/ should contain a file git with the content /usr/local/git/bin. If you have installed other apps like X11 there may be additional files in paths.d - all containing paths.

The file profile in /etc/ should contain at least

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc
fi

The file environment.plist should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>PATH</key>
    <string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin</string>
</dict>
</plist>

The PATH string may contain other paths as well. The file may contain other keys - depending on other installs you have made previously.


If you have found irregular content in one of the files simply replace it with the content shown above. You have to be an admin to modify the first two files because they are root:wheel realm. If you use TextEdit or another text editor to modify them, be sure to save them as plain text and without file extension (i.e. .txt). You can ignore a missing ~/.MacOSX/environment.plist because it isn't supported in your environment (system version) anymore, besides you use some hacks.

5
  • Thanks @klanomath /etc/paths.d/ contains a Unix Executable File. Opening it in TextEdit gave a string of unintelligible characters, with no reference to /usr/local/git/bin (though with some references to locations in /usr/lib/.. in between the characters). Double-clicking opened git in Terminal, after the same string of errors. /etc/profile contains exactly information you described, with no other. Notably, the Terminal now alternates between path_helper and bash Max OSX 10.8 and higher does not support environment.plist The folder ~/.MacOSX is missing Mar 12, 2017 at 11:55
  • @ShubhayanGhoshal environment.list still works with some trickery in newer system versions ;-). I just wanted to ensure that its content isn't some binary or other irregular content.
    – klanomath
    Mar 12, 2017 at 11:59
  • I'll try resetting the environment variables by this procedure: [(dowdandassociates.com/blog/content/…. I think corruption of PATH is the cause of this issue. Mar 12, 2017 at 12:30
  • @ShubhayanGhoshal You don't have to create the environment.plist if none was present. But an already existing environment.plist mustn't contain gibberish. In your case it's the wrong content of /etc/paths.d/git. Simply replace the (binary) content with the string /usr/local/git/bin.
    – klanomath
    Mar 12, 2017 at 12:35
  • Deleted git from /etc/paths.d/. Terminal and RStudio issues resolved. May the God(s) welcome you into the gates of heaven. Mar 12, 2017 at 12:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .