Closed HongliYu closed 7 years ago
Its happening with me too. Any fix coming soon ?
If you have a close look at the crash, it says "launch path not accessible". Can you tell me whether you've set ClangFormat-Xcode to use the bundled version of clang-format, or the system-provided one and then check that whichever one you're trying to use exists?
I can stop this from crashing, but if the binary can't be launched the plugin is not going to format your code.
Run the project, the plugin automatically installed in /Users/baidu/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins.Open Xcode load bundle, use the plugin then format and crash. which path is not accessible? @tonyarnold
@tonyarnold thanks. Worked for me.
I'm having the same issue, but only on my MacBook Pro. @nijindal what was your resolution?
I've tried examining the location of the plug-in and the clang-format executable. They all seem accessible and the same as on my desktop. Any help would be appreciated.
Found the problem: I was bitten by two issues, simultaneously.
NSString *shellString =
[environmentDict objectForKey:@"SHELL"] ?: @"/bin/bash";
NSPipe *outputPipe = [NSPipe pipe];
NSPipe *errorPipe = [NSPipe pipe];
NSTask *task = [[NSTask alloc] init];
task.standardOutput = outputPipe;
task.standardError = errorPipe;
task.launchPath = shellString;
task.arguments = @[ @"-l", @"-c", @"which clang-format" ];
I have a long forgotten
`echo "BASH PROFILE" `
in my .bash_profile that gets echoed when I login or create a new bash shell. The plugin would mistake the "BASH PROFILE" string for the output of which
. And it would then check to see if that command exists and is executable. If not, then it falls back to the internal clang-format. The fix is to skip the -l, but I am not sure why it is there in the first place.
Also, keep in mind that bash-profiles can sometimes contain date
and other commands that write to the screen, plus configuration text or scripts that can take a bit of time to execute. I am not sure that it is a good idea to always follow this path for each reformat of a file or block of text. For one, this path to the system clang-format should be cached. For another, it may be best not to use bash with the -l option.
Just merged #120 anyone wanna confirm that it fixes this issue for them?
Gonna close this issue, just reopen it here if that change didn't fix it for you.
https://gist.github.com/anonymous/e08a03316acda747ceb4