Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Is there a way that I can uninstall osx-gcc-installer without first having to install Xcode, then run sudo /Developer/Library/uninstall-devtools —mode=all ?

I installed it on Mountain Lion, and I want to get rid of it so my CLI tools will work to install Octopress.

Is there a script or command that will help me totally remove osx-gcc-installer from my system?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

From what I'm seeing in the developer's scripts here, it looks like he is recommending that you install Xcode over the top of his "osx-gcc-installer" to be able to uninstall...At that point, you can run the uninstall-devtools script...

From the developer:

If something doesn't work as expected, feel free to install Xcode over this installation.

Once installed, you can remove Xcode completely with the following:

sudo /Developer/Library/uninstall-devtools -mode=all

Alternately, you can copy and paste the actual script content into a blank text document (maybe named "uninstall-devtools"), make it editable (chmod 755 uninstall-devtools), and then execute it (sudo ./uninstall-devtools -mode=all):

#!/usr/bin/perl
####################################################################################################
#
# Copyright (c) 2002-2011 Apple, Inc.
# Xcode 4.2
#
# NAME
#     uninstall-devtools -- Meta-script for running the various devtools uninstaller scripts.
#
# SYNOPSIS
#     sudo /Developer/Library/uninstall-devtools --mode=all
#     sudo /Developer/Library/uninstall-devtools --mode=xcodedir
#     sudo /Developer/Library/uninstall-devtools --mode=unixdev
#     sudo /Developer/Library/uninstall-devtools --mode=systemsupport
#
# Where the specified 'mode' value invokes the following devtools uninstaller scripts:
#
#     all:
#         /Library/Developer/Shared/uninstall-devtools
#         /Library/Developer/4.2/uninstall-devtools
#         /Developer/Library/uninstall-developer-folder
#
#     xcodedir:
#         /Developer/Library/uninstall-developer-folder
#
#     unixdev:
#         /Library/Developer/Shared/uninstall-devtools
#
#     systemsupport:
#         /Library/Developer/Shared/uninstall-devtools
#         /Library/Developer/4.2/uninstall-devtools
#
# The default value for 'mode' is 'all'.
#
# DESCRIPTION
#     This command runs the appropriate devtools uninstaller scripts according to the usage
#     specified on the command line.
####################################################################################################

my $do_nothing     = 0;
my $verbose        = 0;
my $warning        = 0;
my $debug          = 0;
my $help           = 0;
my $mode           = '';

get_options(
    'do-nothing' => \$do_nothing,
    'verbose' => \$verbose,
    'warning' => \$warning,
    'debug' => \$debug,
    'help' => \$help,
    'mode' => \$mode,
);

####################################################################################################

if ($help == 1) {
    print("Usage: $0 --mode=<all|xcodedir|unixdev|systemsupport>\n");
print <<"END";
This is a meta-script which invokes one or more of the devtools
uninstaller scripts, depending on which mode you select.

The recognized modes are:
all:
    /Library/Developer/Shared/uninstall-devtools
    /Library/Developer/4.2/uninstall-devtools
    /Developer/Library/uninstall-developer-folder

xcodedir:
    /Developer/Library/uninstall-developer-folder

unixdev:
    /Library/Developer/Shared/uninstall-devtools

systemsupport:
    /Library/Developer/Shared/uninstall-devtools
    /Library/Developer/4.2/uninstall-devtools

The default value for 'mode' is 'all'.
END
    exit(0);
}

####################################################################################################
# Determine if we are authorized to uninstall the devtools packages.
####################################################################################################

$| = 1;
if (($do_nothing == 0) && ($< != 0)) {
    die("ERROR: Must be run with root permissions -- prefix command with 'sudo'.\n");
}

####################################################################################################

my $uninstaller_script = $0;
my ($uninstaller_dir,$uninstaller_script_basename) = parse_name($uninstaller_script);
if ($uninstaller_dir eq '.') {
    die("ERROR: Must change to another directory before running this script, since the current directory is about to be deleted.\n");
}
my ($developer_dir,$developer_dir_basename) = parse_name($uninstaller_dir);

####################################################################################################

my @flags = ();
if ($do_nothing == 1) {
    push(@flags,'--do-nothing');
}
if ($verbose == 1) {
    push(@flags,'--verbose');
}
if ($warning == 1) {
    push(@flags,'--warning');
}
if ($debug == 1) {
    push(@flags,'--debug');
}

if (($mode eq '') || ($mode eq 'all')) {
    run_uninstaller_script("/Library/Developer/4.2/uninstall-devtools",\@flags);
    run_uninstaller_script("/Library/Developer/Shared/uninstall-devtools",\@flags);
    run_uninstaller_script("$developer_dir/Library/uninstall-developer-folder",\@flags);
} elsif ($mode eq 'xcodedir') {
    run_uninstaller_script("$developer_dir/Library/uninstall-developer-folder",\@flags);
} elsif ($mode eq 'unixdev') {
    run_uninstaller_script("/Library/Developer/Shared/uninstall-devtools",\@flags);
} elsif ($mode eq 'systemsupport') {
    run_uninstaller_script("/Library/Developer/4.2/uninstall-devtools",\@flags);
    run_uninstaller_script("/Library/Developer/Shared/uninstall-devtools",\@flags);
} else {
    die("Usage: $0 --mode=<all|xcodedir|shared|systemsupport>\n");
}
print("IMPORTANT: If you are going to install a previous version of the Developer Tools, be sure to restart the machine after installing.\n");

####################################################################################################

sub get_options {
    while (@_) {
    my $option_name = shift(@_);
    my $option_pointer = shift(@_);

    foreach my $arg (@ARGV) {
        if ($arg =~ /^--$option_name/) {
        my ($arg_name,$arg_value) = split(/=/,$arg);
                $arg_value = 1 if (!$arg_value);
        $$option_pointer = $arg_value;
        }
    }
    }
}

####################################################################################################

sub parse_name {
   my $name = shift;
   my ($dir_name,$base_name) = ($name =~ m{^(.*/)?(.*)}s);
   $dir_name =~ s|(.*)/$|$1|s;
   return ($dir_name,$base_name);
}

####################################################################################################

sub run_uninstaller_script {
    my $script = shift;
    my $flagsref = shift;

    if (-x $script) {
        my @args = ();
        push(@args,$script);
        foreach my $flag (@$flagsref) {
            push(@args,$flag);
        }

        system({$args[0]} @args);
    }
}

####################################################################################################
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.