[
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\nindent_style = space\nindent_size = 4\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: CI\n\non:\n  pull_request:\n    types:\n      - opened\n      - synchronize\n      - reopened\n    paths-ignore:\n      - \"**.md\"\n  push:\n    branches:\n      - master\n    paths-ignore:\n      - \"**.md\"\n\njobs:\n  test:\n    name: Test asdf-erlang plugin\n    strategy:\n      matrix:\n        os:\n          - ubuntu-latest\n          - macos-latest\n    runs-on: ${{ matrix.os }}\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v2\n      - name: Install system packages on Ubuntu\n        if: ${{ runner.os == 'Linux' }}\n        run: sudo apt-get update; sudo apt-get -y install build-essential autoconf m4 libwxgtk3.2-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev xsltproc fop libxml2-utils libncurses-dev\n\n      - name: Install system packages on macOS\n        if: ${{ runner.os == 'macOS' }}\n        run: brew install autoconf openssl@1.1\n\n      - name: Test plugin\n        uses: asdf-vm/actions/plugin-test@v1\n        with:\n          command: erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), \"releases\", erlang:system_info(otp_release), \"OTP_VERSION\"])), io:fwrite(re:replace(Version, \"(^\\\\s+)|(\\\\s+$)\", \"\", [global,{return,list}])), halt().' -noshell\n\n  lint:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n      - name: Run ShellCheck\n        run: scripts/shellcheck.bash\n\n  format:\n    runs-on: macos-latest\n\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v3\n\n      - name: Install shfmt\n        run: brew install shfmt\n\n      - name: Run shfmt\n        run: scripts/shfmt.bash\n"
  },
  {
    "path": ".gitignore",
    "content": "kerl\nkerl-home\n"
  },
  {
    "path": ".tool-versions",
    "content": "shellcheck 0.7.1\nshfmt 3.3.0\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: c\nscript: |-\n  travis_wait 40 asdf plugin-test erlang . --asdf-plugin-gitref $TRAVIS_COMMIT erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), \"releases\", erlang:system_info(otp_release), \"OTP_VERSION\"])), io:fwrite(re:replace(Version, \"(^\\\\s+)|(\\\\s+$)\", \"\", [global,{return,list}])), halt().' -noshell\nbefore_script:\n  - git clone https://github.com/asdf-vm/asdf.git\n  - . asdf/asdf.sh\nos:\n  - linux\n  - osx\ninstall:\n  - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install -y xsltproc fop; fi\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017 asdf version manager\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# asdf-erlang\n\nErlang plugin for [asdf](https://github.com/asdf-vm/asdf) version manager that relies on [kerl](https://github.com/kerl/kerl) for builds.\n\nThis plugin aims to combine the best of both worlds by using kerl.\n\nkerl's compatibility and build scripts, together with asdf's easy version switching and support for the .tool-versions file. You do not need to have kerl already installed to use this. The plugin will install it's own version of kerl automatically.\n\n## Install\n\n```\nasdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git\n```\n\n**Important**: Make sure to read the [Before asdf install](#before-asdf-install) section below to install dependencies!\n\n## Use\n\nCheck [asdf](https://github.com/asdf-vm/asdf) readme for instructions on how to install & manage versions of Erlang. To specify custom options you [can set environment variables just as you would when using kerl](https://github.com/kerl/kerl#kerl_base_dir). For example, to skip the Java dependency during installation use:\n\n```\nexport KERL_CONFIGURE_OPTIONS=\"--disable-debug --without-javac\"\nasdf install erlang <version>\n```\n\nYou can also install Erlang from git, or provide the url to a fork and build from git.\n\n```\nasdf install erlang ref:master\n\nexport OTP_GITHUB_URL=\"https://github.com/basho/otp\"\nasdf install erlang ref:basho\n```\n\nSee [kerl](https://github.com/kerl/kerl) for the complete list of customization options. Note that the `KERL_BASE_DIR` and `KERL_CONFIG` environment variables are set by the plugin when it runs kerl so it will not be possible to customize them.\n\n## Before `asdf install`\n\n### Ubuntu and Debian\n\nNote that if you are using a previous version of Linux, you may need a different version of one of the below\nlibraries.\n\n#### Ubuntu 16.04 LTS \"Xenial Xerus\"\n\nInstall the build tools (dpkg-dev g++ gcc libc6-dev make debianutils m4 perl)\n`apt-get -y install build-essential autoconf`\n\nNeeded for HiPE (native code) support, but already installed by autoconf\n`apt-get -y install m4`\n\nNeeded for terminal handling (libc-dev libncurses5 libtinfo-dev libtinfo5 ncurses-bin)\n`apt-get -y install libncurses5-dev`\n\nFor building with wxWidgets (start observer or debugger!). Note that you may need to select the right `wx-config` before installing Erlang.\n`apt-get -y install libwxgtk3.0-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev`\n\nFor building ssl (libssh-4 libssl-dev zlib1g-dev)\n`apt-get -y install libssh-dev`\n\nODBC support (libltdl3-dev odbcinst1debian2 unixodbc)\n`apt-get -y install unixodbc-dev`\n\nFor building documentation:\n`apt-get install xsltproc fop`\n\nIf you want to install all the above:\n`apt-get -y install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop`\n\n#### Ubuntu 20.04 LTS\n\nIf you need to use `wxWebView` in Erlang you'll want to install a library for it:\n`apt-get -y install libwxgtk-webview3.0-gtk3-dev`\n\nIf you want to install all the above:\n`apt-get -y install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk`\n\n#### Ubuntu 24.04 LTS\nIf you want to install all the above:\n`apt-get -y install build-essential autoconf m4 libwxgtk3.2-dev libwxgtk-webview3.2-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk`\n\n#### Debian 12 (bookworm)\n\nTo install the whole dependency suite:\n`apt-get -y install build-essential autoconf m4 libncurses-dev libwxgtk3.2-dev libwxgtk-webview3.2-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils openjdk-17-jdk`\n\n#### Debian 13 (trixie)\n\nTo install the whole dependency suite:\n`apt-get -y install build-essential autoconf m4 libncurses-dev libwxgtk3.2-dev libwxgtk-webview3.2-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils openjdk-21-jdk`\n\n### Arch Linux\n\nProvides most of the needed build tools.\n`pacman -S --needed base-devel`\n\nNeeded for terminal handling\n`pacman -S ncurses`\n\nFor building with wxWidgets (start observer or debugger!). Make sure `wx-config --selected-config` prints `gtk3-unicode-...` before installing Erlang. Older OTP builds may require wxgtk2, in that case install `wxgtk2-dev` from AUR.\n`pacman -S glu mesa wxwidgets-gtk3 libpng`\n\nFor building ssl\n`pacman -S libssh`\n\nODBC support\n`sudo pacman -S unixodbc`\n\nFor building documentation and elixir reference builds:\n`sudo pacman -S libxslt fop`\n\n#### Dealing with ODBC issues on arch\n\nYou may encounter an ODBC error with an output along these lines:\n\n```\nerror: ld returned 1 exit status\n[x86_64-pc-linux-gnu/Makefile:112: ../priv/bin/x86_64-pc-linux-gnu/odbcserver] Error 1\n\nor\n\n* odbc           : ODBC library - link check failed\n```\n\nThis issue has been discussed [here](https://github.com/asdf-vm/asdf-erlang/issues/286) and also appears on kerl. There are\na link error on Kerl auto configure. If you see this, add a export flag `--with-odbc` to KERL-CONFIGURE. Here is\nan example that skips the java dependency and also sets a specific (and existing)\npath for unixodbc installed via pacman:\n```\nexport KERL_CONFIGURE_OPTIONS=\"--without-javac --with-odbc=/var/lib/pacman/local/unixodbc-$(pacman -Q unixodbc | cut -d' ' -f2)\"\nasdf install erlang <version>\n```\n\n### OSX\n\nNote, for MacOS 10.15.4 and newer, 22.3.1 is the earliest version that can be installed through `kerl` (and, therefore, `asdf`). Earlier versions will fail to compile. See [this issue](https://github.com/kerl/kerl/issues/335#issuecomment-605487028) for details.\n\nInstall the build tools\n`brew install autoconf`\n\nInstall OpenSSL\n`brew install openssl@1.1`  _Erlang 24.1 and older require OpenSSL 1.1, [read more here](https://github.com/erlang/otp/issues/4577#issuecomment-925962048)_\n\nNote, Erlang 25.1 and newer [support OpenSSL 3.0, even for production use.](https://github.com/erlang/otp/releases/tag/OTP-25.1)\nIf you want to build Erlang with openssl@3.0, install it by `brew install openssl`\n\nFor building with wxWidgets (start observer or debugger!). Note that you may need to select the right `wx-config` before installing Erlang.\n`brew install wxwidgets`\n\nFor building documentation and elixir reference builds:\n`brew install libxslt fop`\n\n#### Dealing with OpenSSL issues on macOS\n\nYou may encounter an SSL error with an output along these lines:\n\n```\ncrypto : No usable OpenSSL found\nssh : No usable OpenSSL found\nssl : No usable OpenSSL found\n```\n\nThis issue has been documented [on `kerl`](https://github.com/kerl/kerl/issues/320). If you see this\nerror, you can use the [`--with-ssl`](https://github.com/asdf-vm/asdf-erlang/issues/82#issuecomment-415930974)\nflag with a path before installing Erlang. Here is an example that skips the java dependency and also sets a specific (and existing)\npath for [OpenSSL](https://github.com/kerl/kerl#kerl-and-openssl) installed via brew on macOS.\n\n```\nexport KERL_CONFIGURE_OPTIONS=\"--without-javac --with-ssl=$(brew --prefix openssl@1.1)\"\nasdf install erlang <version>\n```\n\n### CentOS & Fedora\n\nThese steps assume a most recent build of CentOS (currently\ntested on CentOS 7.5 x64 & Fedora 28 x64)\n\nInstall the build tools\n`sudo yum install -y git gcc g++ automake autoconf`\n\nNeeded for terminal handling\n`sudo yum install -y ncurses-devel`\n\nFor building with wxWidgets (start observer or debugger!). Note that you may need to select the right `wx-config` before installing Erlang.\n`sudo yum install -y wxGTK-devel wxBase`\n\nFor building ssl\n`sudo yum install -y openssl-devel`\n\nFor jinterface\n`sudo yum install -y java-1.8.0-openjdk-devel`\n\nODBC support\n`sudo yum install -y libiodbc unixODBC-devel.x86_64 erlang-odbc.x86_64`\n\nFor the documentation to be built\n`sudo yum install -y libxslt fop`\n\n### Solus\n\nInstall the build tools\n\n```bash\nsudo eopkg it -c system.devel\n```\n\nFor building with wxWidgets (start observer or debugger!). Note that you may need to select the right `wx-config` before installing Erlang.\n\n```bash\nsudo eopkg install wxwidgets-devel libx11-devel mesalib-devel libglu-devel fop\n```\n\nFor ODBC support\n\n```bash\nsudo eopkg install unixodbc-devel\n```\n\nFor jinterface\n\n```bash\nsudo eopkg install openjdk-8 openjdk-8-devel\n```\n\nIf you want to install all of the above\n\n```bash\n# Install build tools\nsudo eopkg it -c system.devel\n\nsudo eopkg install wxwidgets-devel libx11-devel mesalib-devel libglu-devel fop unixodbc-devel openjdk-8 openjdk-8-devel\n```\n\n#### OpenJDK issues on Solus\n\nI ran into an issue where `javac` wasn't a recognized command in the terminal despite having installed `openjdk-8` and `openjdk-8-devel`. Turns out it wasn't added to `PATH` by default. So simply add it to `PATH` like so:\n\n```bash\n# In ~/.bashrc add these to add Java to PATH\nJAVA_HOME=/usr/lib64/openjdk-8\nPATH=$PATH:$JAVA_HOME/bin\n\n# In terminal\nsource ~/.bashrc\n```\n\n### openSUSE Tumbleweed\n\nEven after you have installed the dependencies below, the Erlang installer will warn that g++ and openssl-devel appear missing.  This is safe to ignore.\n\nThe basic stuff to get Erlang to compile:\n\n```\nsudo zypper install unzip make automake autoconf gcc-c++ ncurses-devel\n```\n\nFor crypto, ssh, and others (you probably want this):\n\n```\nsudo zypper install libssh-devel libopenssl-devel\n```\n\nFor wx GUIs (observer, debugger, etc):\n\n```\nsudo zypper install wxGTK3-3_2-devel\n```\n\nTo build documentation:\n\n```\nsudo zypper install fop libxml2-tools libxslt-tools\n```\n\nFor ODBC support:\n\n```\nsudo zypper install unixODBC-devel\n```\n\nFor jinterface:\n\n```\nsudo zypper install java-1_8_0-openjdk-devel\n```\n\n## Getting Erlang documentation\n\nErlang may come with documentation included (as man pages, pdfs and html files,\nor even embedded documentation (via `c:h` function)).\n\nFor man pages this allows typing `erl -man ets` to get info on `ets` module.\n\nFor embedded documentation (on [OTP 23\\+](https://www.erlang.org/downloads/23)):\n- In Erlang's `erl`: via [`c:h/1,2,3`](https://erlang.org/doc/man/c.html#h/1) and [`c:ht/1,2,3`](https://erlang.org/doc/man/c.html#ht/1) for types\n- In Elixir's `iex` (Elixir 1.7+): via [`h/1`](https://hexdocs.pm/iex/IEx.Helpers.html#h/1) and [`t/1`](https://hexdocs.pm/iex/IEx.Helpers.html#t/1) for types\n\n`asdf-erlang` uses kerl for builds, and [kerl](https://github.com/kerl/kerl) is\ncapable of building the docs for specified version of Erlang in required\nformats.\n\nFor kerl to be able to build Erlang documentation two requirements have to be met:\n1. `KERL_BUILD_DOCS` environment variable has to be set to value `yes`\n2. Additional dependencies have to be installed. For detailed list of dependencies for your OS please refer to the specific section above\n\nAdditionally, HTML and Man formats can be ignored entirely:\n- `KERL_INSTALL_HTMLDOCS` set to `no` to not install HTML docs\n- `KERL_INSTALL_MANPAGES` set to `no` to skip Man pages.\n\nBy default, docs in both of these formats are installed if `KERL_BUILD_DOCS` is set.\n\n*It may be a good idea to disable those formats to **save space***, since **docs can easily take around 200MB** in addition to 100MB of base installation, yet to *still have docs inside shell*.\n\n**Note:** Environment variable has to be set before `asdf install erlang <version>` is executed, to take effect.\n\n### Setting the environment variable in bash\n\nType: `export KERL_BUILD_DOCS=yes` to create `KERL_BUILD_DOCS` environment variable and set it to `true`.\nRepeat the same for `KERL_INSTALL_HTMLDOCS` `KERL_INSTALL_MANPAGES` if required (see above).\n\nThis line could be added to your `.bashrc` in case you want `KERL_BUILD_DOCS` to be set for future (future installations of Erlang).\n\nTo remove environment variable: `unset KERL_BUILD_DOCS`.\n\n### Setting the environment variable in fish shell\n\nType: `set -xg KERL_BUILD_DOCS yes` to set environment variable.\nRepeat the same for `KERL_INSTALL_HTMLDOCS` `KERL_INSTALL_MANPAGES` if required (see above).\n\nIn case you want it to be persisted between sessions (machine reboots - for example for future installations) type `set -xU KERL_BUILD_DOCS yes`.\n\nTo remove environment variable type: `set -e KERL_BUILD_DOCS`.\n\n### Use a specific version of kerl\n\nOverriding the default kerl version shouldn't ever be necessary, but if you want to you a specific version of kerl you can set:\n\n```shell\nexport ASDF_KERL_VERSION=\"2.1.1\"\n```\n"
  },
  {
    "path": "bin/install",
    "content": "#!/usr/bin/env bash\n\n# Unoffical Bash \"strict mode\"\n# http://redsymbol.net/articles/unofficial-bash-strict-mode/\nset -euo pipefail\n#ORIGINAL_IFS=$IFS\nIFS=$'\\t\\n' # Stricter IFS settings\n\n# shellcheck source=lib/utils.sh\nsource \"$(dirname \"$0\")/../lib/utils.sh\"\n\ninstall_erlang() {\n    ensure_kerl_setup\n    local build_name\n\n    install_dependency_checks\n    ensure_kerl_config_opts\n    set_unixodbc_opt\n    set_ssl_opt\n    add_openjdk_to_path\n    ensure_ulimit\n\n    echo \"[asdf-erlang] 📦 Building with $(env | grep KERL_CONFIGURE_OPTIONS)\"\n\n    build_name=\"asdf_$ASDF_INSTALL_VERSION\"\n\n    export MAKEFLAGS=\"-j$ASDF_CONCURRENCY\"\n\n    if $(kerl_path) list installations | grep -q \"$build_name\"; then\n        echo \"[asdf-erlang] 🧹 Cleanup kerl installation $build_name\"\n        $(kerl_path) delete installation \"$build_name\" || true\n    else\n        echo \"[asdf-erlang] ❄️ No kerl installation to cleanup for $build_name\"\n    fi\n    if $(kerl_path) list builds | grep -q \"$build_name\"; then\n        echo \"[asdf-erlang] 🧹 Cleanup kerl build $build_name\"\n        $(kerl_path) delete build \"$build_name\" || true\n    else\n        echo \"[asdf-erlang] ❄️ No kerl build to cleanup for $build_name\"\n    fi\n\n    if [ \"$ASDF_INSTALL_TYPE\" = \"ref\" ]; then\n        $(kerl_path) build git \"${OTP_GITHUB_URL:-https://github.com/erlang/otp.git}\" \"$ASDF_INSTALL_VERSION\" \"$build_name\"\n    else\n        $(kerl_path) build \"$ASDF_INSTALL_VERSION\" \"$build_name\"\n    fi\n\n    # We hide all output from this command so the\n    # \"You can activate this installation running the following command:\"\n    # that doesn't apply is hidden\n    echo \"👷🏼 kerl install $build_name $ASDF_INSTALL_PATH\"\n    $(kerl_path) install \"$build_name\" \"$ASDF_INSTALL_PATH\" >/dev/null 2>&1\n\n    echo \"🧹 Cleanup kerl build $build_name\"\n    $(kerl_path) cleanup \"$build_name\"\n\n    echo \"🔗 Linking app executables $ASDF_INSTALL_PATH\"\n    link_app_executables \"$ASDF_INSTALL_PATH\"\n    cleanup_custom_env_vars\n    echo \"👍 Installed erlang ${ASDF_INSTALL_VERSION}\"\n}\n\nlink_app_executables() {\n    local install_path=$1\n\n    # Link other executables to the bin directory so that asdf shims are created for them\n    cd \"$install_path/bin\"\n\n    # ln call may fail if multiple executables are found with the same name, so\n    # we loop over all files matching these patterns, and symlink only if\n    # file with same name does not already exist in \"$install_path/bin\"\n    for file in ../lib/*/bin/* ../lib/*/priv/bin/*; do\n        bin_name=\"$(basename \"$file\")\"\n\n        if [ ! -e \"./$bin_name\" ]; then\n            ln -s \"$file\" .\n        fi\n    done\n}\n\ninstall_dependency_checks() {\n    if [[ \"$OSTYPE\" == \"darwin\"* ]]; then\n        installed_packages=()\n        for package in fop openssl unixodbc openjdk wxmac; do\n            if brew list --versions \"$package\" >/dev/null 2>&1; then\n                installed_packages+=(\"$package\")\n            else\n                if [ \"$package\" = \"wxmac\" ]; then\n                    echo \"[asdf-erlang] ⚠️ Warning: $package is optional and not installed. You can install it using 'brew install --build-from-source wxmac'.\"\n                    echo \"[asdf-erlang] ⚠️ Note: wxmac is required for building Erlang/OTP with a working :observer\"\n                else\n                    echo \"[asdf-erlang] ⚠️ Warning: $package is optional and not installed. Please install it using 'brew install $package'.\"\n                fi\n            fi\n        done\n    fi\n}\n\nensure_kerl_config_opts() {\n    if [[ -z \"${KERL_CONFIGURE_OPTIONS:-}\" ]]; then\n        export KERL_CONFIGURE_OPTIONS=\"\"\n    fi\n}\n\nset_unixodbc_opt() {\n    if [[ \"$OSTYPE\" == \"darwin\"* ]]; then\n        # If no unixodbc is installed, then skip.\n        if ! brew --prefix unixodbc >/dev/null 2>&1; then\n            return\n        fi\n\n        if [[ ! \"$KERL_CONFIGURE_OPTIONS\" =~ unixodbc ]]; then\n            local kerl_unixodbc_opt\n            kerl_unixodbc_opt=\" --with-odbc=$(brew --prefix unixodbc)\"\n            export KERL_CONFIGURE_OPTIONS+=\" $kerl_unixodbc_opt\"\n            echo \"[asdf-erlang] 🛟 Added unixodbc to KERL_CONFIGURE_OPTIONS: $kerl_unixodbc_opt\"\n        fi\n\n        # If CC not set, then set CC.\n        # ELSE add the unixodbc include path to CC.\n        if [ -z \"${CC:-}\" ]; then\n            CC=\"/usr/bin/clang -I$(brew --prefix unixodbc)/include\"\n            export CC\n            echo \"[asdf-erlang] 🛟 No CC found. Setting CC to: $CC\"\n            CC_SET_BY_ASDF_ERLANG=1 # so that we can clear it later.\n        elif [[ \"$CC\" != *unixodbc* ]]; then\n            CC+=\" -I$(brew --prefix unixodbc)/include\"\n            export CC\n            echo \"[asdf-erlang] 🛟 Added unixodbc include path to CC: $CC\"\n        fi\n\n        # If LDFLAGS not set, then set LDFLAGS.\n        # ELSE add the unixodbc library path to LDFLAGS.\n        if [ -z \"${LDFLAGS:-}\" ]; then\n            LDFLAGS=\"-L$(brew --prefix unixodbc)/lib\"\n            export LDFLAGS\n            echo \"[asdf-erlang] 🛟 No LDFLAGS found. Setting LDFLAGS to: $LDFLAGS\"\n            LDFLAGS_SET_BY_ASDF_ERLANG=1 # so that we can clear it later.\n        elif [[ \"$LDFLAGS\" != *unixodbc* ]]; then\n            local unixodbc_lib_path\n            unixodbc_lib_path=\"$(brew --prefix unixodbc)/lib\"\n            export LDFLAGS+=\" -L$unixodbc_lib_path\"\n            echo \"[asdf-erlang] 🛟 Added $unixodbc_lib_path to LDFLAGS env var\"\n        fi\n    fi\n}\n\nadd_openjdk_to_path() {\n    if [[ \"$OSTYPE\" == \"darwin\"* ]]; then\n        if ! brew --prefix openjdk >/dev/null 2>&1; then\n            return\n        fi\n\n        local openjdk_path\n        openjdk_path=\"$(brew --prefix openjdk)\"\n        if [[ \":$PATH:\" != *\":$openjdk_path/bin:\"* ]]; then\n            export PATH=\"$openjdk_path/bin:$PATH\"\n            echo \"[asdf-erlang] 🛟 OpenJDK has been added to PATH for this terminal session: $openjdk_path/bin\"\n            echo \"[asdf-erlang] Please ensure this is included in your shell's dot files (.zshrc, .bashrc, etc.)\"\n        fi\n    fi\n}\n\nensure_ulimit() {\n    if [ \"$(ulimit -n)\" -lt 1000 ]; then\n        ulimit -n 65536\n        echo \"[asdf-erlang] 🛟 ulimit was low. It has been set to 65536 for this terminal session\"\n    fi\n}\n\nset_ssl_opt() {\n    if [[ \"$OSTYPE\" == \"darwin\"* ]]; then\n        # If this is a ref install, then we don't need to set the ssl option.\n        # Reason: Don't want to handle that for now.\n        if [[ \"$ASDF_INSTALL_TYPE\" == \"ref\" ]]; then\n            echo \"[asdf-erlang] ⚠️ Skipping setting --with-ssl in KERL_CONFIGURE_OPTIONS for ref install\"\n            return\n        fi\n\n        otp_major=$(echo \"$ASDF_INSTALL_VERSION\" | cut -d. -f1)\n        otp_minor=$(echo \"$ASDF_INSTALL_VERSION\" | cut -d. -f2)\n\n        # Copied IF condition check from the kerl binary to match their version check.\n        # We only have to fix/handle newer erlang+openssl versions because of kerl looking for openssl@3.0 instead of openssl#3.\n        # The erlang version that use openssl 1.1 should be fine (or as is).\n        if [ \"$otp_major\" = 'git' ] || [ \"$otp_major\" -lt 25 ] || { [ \"$otp_major\" -eq 25 ] && [ \"$otp_minor\" -lt 1 ]; }; then\n            echo \"[asdf-erlang] ⚠️ Skipping setting --with-ssl in KERL_CONFIGURE_OPTIONS. This erlang version uses openssl v1.x\"\n            return\n        fi\n\n        # Only set the ssl option for newer erlang versions that use openssl@3.\n        if ! brew --prefix openssl@3 >/dev/null 2>&1; then\n            echo \"[asdf-erlang] ⚠️ Skipping setting --with-ssl in KERL_CONFIGURE_OPTIONS. brew prefix path for openssl@3 not found.\"\n            return\n        fi\n\n        # If openssl is not already in KERL_CONFIGURE_OPTIONS, then add it.\n        if [[ ! \"$KERL_CONFIGURE_OPTIONS\" =~ openssl ]]; then\n            local kerl_ssl_opt\n            kerl_ssl_opt=\" --with-ssl=$(brew --prefix openssl@3)\"\n            export KERL_CONFIGURE_OPTIONS+=\" $kerl_ssl_opt\"\n            echo \"[asdf-erlang] 🛟 Added openssl to KERL_CONFIGURE_OPTIONS: $kerl_ssl_opt\"\n        fi\n    fi\n}\n\ncleanup_custom_env_vars() {\n    if [[ \"${LDFLAGS_SET_BY_ASDF_ERLANG:-}\" == \"1\" ]]; then\n        unset LDFLAGS\n    fi\n\n    if [[ \"${CC_SET_BY_ASDF_ERLANG:-}\" == \"1\" ]]; then\n        unset CC\n    fi\n}\n\ninstall_erlang\n"
  },
  {
    "path": "bin/list-all",
    "content": "#!/usr/bin/env bash\n\n# Unoffical Bash \"strict mode\"\n# http://redsymbol.net/articles/unofficial-bash-strict-mode/\nset -euo pipefail\n#ORIGINAL_IFS=$IFS\nIFS=$'\\t\\n' # Stricter IFS settings\n\n# shellcheck source=lib/utils.sh\nsource \"$(dirname \"$0\")/../lib/utils.sh\"\n\nlist_all() {\n    ensure_kerl_setup\n    \"$(kerl_path)\" list releases all | tr '\\n' ' '\n}\n\nlist_all\n"
  },
  {
    "path": "bin/uninstall",
    "content": "#!/usr/bin/env bash\n\n# Unoffical Bash \"strict mode\"\n# http://redsymbol.net/articles/unofficial-bash-strict-mode/\nset -euo pipefail\n#ORIGINAL_IFS=$IFS\nIFS=$'\\t\\n' # Stricter IFS settings\n\n# shellcheck source=lib/utils.sh\nsource \"$(dirname \"$0\")/../lib/utils.sh\"\n\nensure_kerl_setup\n\nif [ \"$ASDF_INSTALL_VERSION\" == \"\" ]; then\n    echo \"Please provide the version you want to uninstall\"\n    exit 1\nfi\n\n# Remove the installation and build if the installation was done by kerl\nif $(kerl_path) list installations | grep \"$ASDF_INSTALL_PATH\"; then\n    $(kerl_path) delete build \"asdf_$ASDF_INSTALL_VERSION\" || true\n    $(kerl_path) delete installation \"$ASDF_INSTALL_PATH\" || true\nfi\n\n# Finally make sure the directory is actually removed regardless of what the\n# previous kerl commands did\nrm -rf \"$ASDF_INSTALL_PATH\" || true\n"
  },
  {
    "path": "lib/utils.sh",
    "content": "export KERL_VERSION=\"${ASDF_KERL_VERSION:-4.4.0}\"\n\nhandle_failure() {\n    function=$1\n    error_message=$2\n    $function && exit_code=$? || exit_code=$?\n\n    if [ \"$exit_code\" -ne 0 ]; then\n        printf \"%s\\\\n\" \"$error_message\" 1>&2\n    fi\n\n    return \"$exit_code\"\n}\n\nensure_kerl_setup() {\n    handle_failure set_kerl_env 'Failed to set kerl environment'\n    handle_failure ensure_kerl_installed 'Failed to install kerl'\n    handle_failure update_available_versions 'Failed to update available versions'\n}\n\nensure_kerl_installed() {\n    if [ ! -f \"$(kerl_path)\" ]; then\n        download_kerl\n    elif [ \"$(\"$(kerl_path)\" version)\" != \"$KERL_VERSION\" ]; then\n        # If the kerl file already exists and the version does not match, remove\n        # it and download the correct version\n        rm \"$(kerl_path)\"\n        download_kerl\n    fi\n}\n\ndownload_kerl() {\n    # Print to stderr so asdf doesn't assume this string is a list of versions\n    printf \"Downloading kerl...\\\\n\" >&2\n\n    local kerl_url=\"https://raw.githubusercontent.com/kerl/kerl/${KERL_VERSION}/kerl\"\n\n    curl -Lo \"$(kerl_path)\" \"$kerl_url\"\n    chmod +x \"$(kerl_path)\"\n}\n\nkerl_path() {\n    printf \"%s\\\\n\" \"$(dirname \"$(dirname \"$0\")\")/kerl\"\n}\n\nset_kerl_env() {\n    local kerl_home\n    kerl_home=\"$(dirname \"$(dirname \"$0\")\")/kerl-home\"\n    mkdir -p \"$kerl_home\"\n    export KERL_BASE_DIR=\"$kerl_home\"\n    export KERL_BUILD_BACKEND=\"git\"\n    export KERL_CONFIG=\"$kerl_home/.kerlrc\"\n    export KERL_DOWNLOAD_DIR=\"${ASDF_DOWNLOAD_PATH:-}\"\n}\n\nupdate_available_versions() {\n    \"$(kerl_path)\" update releases >/dev/null\n}\n"
  },
  {
    "path": "scripts/shellcheck.bash",
    "content": "#!/usr/bin/env bash\n\nexec shellcheck -s bash -x bin/* -x lib/*\n"
  },
  {
    "path": "scripts/shfmt.bash",
    "content": "#!/usr/bin/env bash\n\nexec shfmt -d bin/* lib/*\n"
  }
]