Skip to content

Instantly share code, notes, and snippets.

@fscm
Created April 29, 2025 16:55
Show Gist options
  • Select an option

  • Save fscm/153ab5e85455423e33613ff96f7c25a1 to your computer and use it in GitHub Desktop.

Select an option

Save fscm/153ab5e85455423e33613ff96f7c25a1 to your computer and use it in GitHub Desktop.

Revisions

  1. fscm created this gist Apr 29, 2025.
    81 changes: 81 additions & 0 deletions install_unrar.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,81 @@
    # [macOS] Install unrar tool from source

    Instructions on how to install the `unrar` command on macOS from source.

    ## Prerequisites

    macOS Command Line Tools need to be installed on your local computer.

    To install the Command Line Tools run the following command:

    ```sh
    xcode-select --install
    ```

    ## Get the source

    To obtain the GNU Tar tool source code run the following commands:

    ```sh
    mkdir -p ~/.src/unrar
    curl --silent --location --retry 3 "https://www.rarlab.com/rar/unrarsrc-7.1.6.tar.gz" | tar xz --no-same-owner --strip-components=1 -C ~/.src/unrar
    cd ~/.src/unrar
    ```

    ## Configure

    No configuration required.

    ## Build

    To build the source code run the following command:

    ```sh
    make --silent --no-print-directory -f makefile unrar
    ```

    ## Install

    To install the tool run the following commands:

    ```sh
    sudo install -v -m 0755 unrar /usr/local/bin
    ```

    ## Verify

    Run the following command on a terminal window:

    ```sh
    unrar
    ```

    ## Libraries

    First clean the previous build objects using the following command:

    ```sh
    rm -f *.o
    ```

    To build the libraries run the following command:

    ```sh
    make --silent --no-print-directory -f makefile lib
    ```

    To install the libraries run the following command:

    ```sh
    mv libunrar.so libunrar.dylib
    sudo install -v libunrar.* /usr/local/lib
    ```

    ## Clean up

    After installing the tool you can remove the downloaded source code using the following commands:

    ```sh
    cd ~
    rm -rf ~/.src
    ```