Skip to content

Commit 256ce63

Browse files
committed
Fix Class MMBackend duplication bug on launch
This issue was detected on both Homebrew and Github released MacVim for v8.1 on a fresh install of OS High Sierra with no .vim or .vimrc configuration Basically, when starting vim from the command line, it produces the following error: ``` objc[4513]: Class MMBackend is implemented in both /usr/local/Cellar/macvim/8.1-153/MacVim.app/Contents/bin/../MacOS/Vim (0x10b303f38) and /usr/local/Cellar/macvim/8.1-153/MacVim.app/Contents/MacOS/Vim (0x217f5bf38). One of the two will be used. Which one is undefined. ``` If launching graphical interface, the error shows up twice. The issue was traced to the use of '/../' in the binary path for launching the application which somehow pollutes the library path for the executable, finding copies of the MMBackend class in both the absolute path and the quazi-relative path. To resolve this, the relative component was removed from the path resolution of the actual Vim binary by actually dropping down a directory from the script location. It also simplifies the dereferencing of any link chains to that script.
1 parent 75ee1a5 commit 256ce63

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

src/MacVim/mvim

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@
1111
# Bjorn Winckler (Aug 13 2007).
1212

1313
# Find Vim executable
14-
if [ -L "$0" ]; then
15-
# readlink -f
16-
curdir=`pwd -P`
17-
self_path=$0
18-
cd "`dirname $self_path`"
19-
while [ -L "$self_path" ]; do
20-
self_path=`readlink $self_path`
21-
cd "`dirname $self_path`"
22-
self_path=`basename $self_path`
23-
done
24-
binary="`pwd -P`/../MacOS/Vim"
25-
cd "$curdir"
26-
else
27-
binary="`dirname "$0"`/../MacOS/Vim"
28-
fi
14+
orig_path="$(pwd -P)"
15+
self_path="$0"
16+
while [ -L "$self_path" ]; do # dereference links
17+
link="$(basename "$self_path")"
18+
cd "$(dirname "$self_path")"
19+
self_path="$(readlink "$link")"
20+
done
21+
cd "$(dirname "$self_path")"
22+
binary="$(dirname "$(pwd -P)")/MacOS/Vim"
23+
cd "$orig_path"
24+
2925
if ! [ -x "$binary" ]; then
3026
echo "Sorry, cannot find Vim executable."
3127
exit 1

0 commit comments

Comments
 (0)