How to check if command line tools is installed

后端 未结 10 2121
执念已碎
执念已碎 2020-11-30 18:02

I have a macbook pro with OS X 10.8.2. XCode is installed. I know this as it appears in the Applications directory. There are also the xcodebuild and xcode-select files in /

10条回答
  •  庸人自扰
    2020-11-30 18:37

    Yosemite

    Below are a few extra steps on a fresh Mac that some people might need. This adds a little to @jnovack's excellent answer.

    Update: A few other notes when setting this up:

    Make sure your admin user has a password. A blank password won't work when trying to enable a root user.

    System Preferences > Users and Groups > (select user) > Change password
    

    Then to enable root, run dsenableroot in a terminal:

    $ dsenableroot
    username = mac_admin_user
    user password:
    root password:
    verify root password:
    
    dsenableroot:: ***Successfully enabled root user.
    

    Type in the admin user's password, then the new enabled root password twice.

    Next type:

    sudo gcc
    

    or

    sudo make
    

    It will respond with something like the following:

    WARNING: Improper use of the sudo command could lead to data loss
    or the deletion of important system files. Please double-check your
    typing when using sudo. Type "man sudo" for more information.
    
    To proceed, enter your password, or type Ctrl-C to abort.
    
    Password:
    
    
    You have not agreed to the Xcode license agreements. You must agree to 
    both license agreements below in order to use Xcode.
    

    Press enter when it prompts to show you the license agreement.

    Hit the Enter key to view the license agreements at 
    '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'
    
    IMPORTANT: BY USING THIS SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE 
    FOLLOWING APPLE TERMS:
    
    //...
    

    Press q to exit the license agreement view.

    By typing 'agree' you are agreeing to the terms of the software license 
    agreements. Type 'print' to print them or anything else to cancel, 
    [agree, print, cancel]
    

    Type agree. And then it will end with:

    clang: error: no input files 
    

    Which basically means that you didn't give make or gcc any input files.

    Here is what the check looked like:

    $ xcode-select -p
    /Applications/Xcode.app/Contents/Developer
    

    Mavericks

    With Mavericks, it is a little different now.

    When the tools were NOT found, this is what the command pkgutil command returned:

    $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
    No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
    

    To install the command line tools, this works nicely from the Terminal, with a nice gui and everything.

    $ xcode-select --install
    

    http://macops.ca/installing-command-line-tools-automatically-on-mavericks/

    When they were found, this is what the pkgutil command returned:

    $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
    package-id: com.apple.pkg.CLTools_Executables
    version: 5.0.1.0.1.1382131676
    volume: /
    location: /
    install-time: 1384149984
    groups: com.apple.FindSystemFiles.pkg-group com.apple.DevToolsBoth.pkg-group com.apple.DevToolsNonRelocatableShared.pkg-group 
    

    This command returned the same before and after the install.

    $ pkgutil --pkg-info=com.apple.pkg.DeveloperToolsCLI
    No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
    

    Also I had the component for the CLT selected and installed in xcode's downloads section before, but it seems like it didn't make it to the terminal...

    Hope that helps.

提交回复
热议问题