Try using rebar3

 * Use 3.15.2 version which is compatible with Erlang 20
 * Fauxton and docs converted to be used as rebar3 deps
 * Use get-deps only instead of update-deps
diff --git a/.gitignore b/.gitignore
index fe3e5ac..8d27dbc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -128,7 +128,8 @@
 src/jwtf/.rebar3/
 test/javascript/junit.xml
 
-/_build/
+_build/
+rebar.lock
 /src/bunt
 /src/credo/
 /src/httpotion/
diff --git a/Makefile b/Makefile
index eed3a8d..35db222 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@
 
 include version.mk
 
-REBAR?=$(shell echo `pwd`/bin/rebar)
+REBAR?=$(shell echo `pwd`/bin/rebar3)
 ERLFMT?=$(shell echo `pwd`/bin/erlfmt)
 
 # Handle the following scenarios:
@@ -140,8 +140,8 @@
 .PHONY: escriptize
 # target: escriptize - Build CLI tools
 escriptize: couch
-	@$(REBAR) -r escriptize apps=weatherreport
-	@cp src/weatherreport/weatherreport bin/weatherreport
+	@$(REBAR) escriptize apps=weatherreport
+	@cp _build/default/bin/weatherreport bin/weatherreport
 
 
 ################################################################################
@@ -171,10 +171,9 @@
 eunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(shell pwd)/bin/couchjs $(shell pwd)/share/server/main.js
 eunit: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
 eunit: couch
-	@COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) setup_eunit 2> /dev/null
 	@for dir in $(subdirs); do \
-            COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) -r eunit $(EUNIT_OPTS) apps=$$dir || exit 1; \
-        done
+	     COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) eunit $(EUNIT_OPTS) --application=$$dir || exit 1; \
+	done
 
 
 .PHONY: exunit
@@ -185,25 +184,25 @@
 exunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
 exunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(shell pwd)/bin/couchjs $(shell pwd)/share/server/main.js
 exunit: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
-exunit: couch elixir-init setup-eunit elixir-check-formatted elixir-credo
+exunit: couch elixir-init elixir-check-formatted elixir-credo
 	@mix test --trace $(EXUNIT_OPTS)
 
-setup-eunit: export BUILDDIR = $(shell pwd)
-setup-eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
-setup-eunit:
-	@$(REBAR) setup_eunit 2> /dev/null
+# setup-eunit: export BUILDDIR = $(shell pwd)
+# setup-eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
+# setup-eunit:
+# 	@$(REBAR) setup_eunit 2> /dev/null
 
 just-eunit: export BUILDDIR = $(shell pwd)
 just-eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
 just-eunit:
-	@$(REBAR) -r eunit $(EUNIT_OPTS)
+	@$(REBAR) eunit $(EUNIT_OPTS)
 
 .PHONY: soak-eunit
 soak-eunit: export BUILDDIR = $(shell pwd)
 soak-eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
 soak-eunit: couch
 	@$(REBAR) setup_eunit 2> /dev/null
-	while [ $$? -eq 0 ] ; do $(REBAR) -r eunit $(EUNIT_OPTS) ; done
+	while [ $$? -eq 0 ] ; do $(REBAR) eunit $(EUNIT_OPTS) ; done
 
 erlfmt-check:
 	ERLFMT_PATH=$(ERLFMT) python3 dev/format_check.py
@@ -339,25 +338,25 @@
 .PHONY: build-plt
 # target: build-plt - Build project-specific PLT
 build-plt:
-	@$(REBAR) -r build-plt $(DIALYZE_OPTS)
+	@$(REBAR) build-plt $(DIALYZE_OPTS)
 
 
 .PHONY: check-plt
 # target: check-plt - Check the PLT for consistency and rebuild it if it is not up-to-date
 check-plt:
-	@$(REBAR) -r check-plt $(DIALYZE_OPTS)
+	@$(REBAR) check-plt $(DIALYZE_OPTS)
 
 
 .PHONY: dialyze
 # target: dialyze - Analyze the code for discrepancies
 dialyze: .rebar
-	@$(REBAR) -r dialyze $(DIALYZE_OPTS)
+	@$(REBAR) dialyze $(DIALYZE_OPTS)
 
 
 .PHONY: introspect
 # target: introspect - Check for commits difference between rebar.config and repository
 introspect:
-	@$(REBAR) -r update-deps
+	@$(REBAR) get-deps
 	@build-aux/introspect
 
 ################################################################################
diff --git a/configure b/configure
index 0bcbfae..495fa80 100755
--- a/configure
+++ b/configure
@@ -21,7 +21,7 @@
 
 PACKAGE_AUTHOR_NAME="The Apache Software Foundation"
 
-REBAR3_BRANCH="main"
+REBAR3_BRANCH="3.15.2"
 
 # TEST=0
 WITH_PROPER="true"
@@ -126,22 +126,6 @@
                 continue
                 ;;
 
-            --rebar)
-                if [ -x "$2" ]; then
-                    version=`$2 --version 2> /dev/null | grep -o "2\.[6-9]\.[0-9]"`
-                    if [ $? -ne 0 ]; then
-                        printf 'Rebar >=2.6.0 and <3.0.0 required' >&2
-                        exit 1
-                    fi
-                    eval REBAR=$2
-                    shift 2
-                    continue
-                else
-                    printf 'ERROR: "--rebar" requires valid path to executable.\n' >&2
-                    exit 1
-                fi
-                ;;
-
             --rebar3)
                 if [ -x "$2" ]; then
                     eval REBAR3=$2
@@ -290,18 +274,6 @@
 {spidermonkey_version, "$SM_VSN"}.
 EOF
 
-install_local_rebar() {
-    if [ ! -x "${rootdir}/bin/rebar" ]; then
-        if [ ! -d "${rootdir}/src/rebar" ]; then
-            # git clone --depth 1 https://github.com/apache/couchdb-rebar.git ${rootdir}/src/rebar
-            git clone https://github.com/apache/couchdb-rebar.git ${rootdir}/src/rebar
-        fi
-        make -C ${rootdir}/src/rebar
-        mv ${rootdir}/src/rebar/rebar ${rootdir}/bin/rebar
-        make -C ${rootdir}/src/rebar clean
-    fi
-}
-
 install_local_rebar3() {
     if [ ! -x "${rootdir}/bin/rebar3" ]; then
         if [ ! -d "${rootdir}/src/rebar3" ]; then
@@ -327,15 +299,8 @@
     fi
 }
 
-if [ -z "${REBAR}" ]; then
-    install_local_rebar
-    REBAR=${rootdir}/bin/rebar
-fi
-
-if [ -z "${REBAR3}" ] && [ "${ERLANG_VER}" != "20" ]; then
-    install_local_rebar3
-    REBAR3=${rootdir}/bin/rebar3
-fi
+install_local_rebar3
+REBAR3=${rootdir}/bin/rebar3
 
 if [ -z "${ERLFMT}" ] && [ "${ERLANG_VER}" != "20" ]; then
     install_local_erlfmt
@@ -345,7 +310,7 @@
 # only update dependencies, when we are not in a release tarball
 if [ -d .git  -a $SKIP_DEPS -ne 1 ]; then
     echo "==> updating dependencies"
-    ${REBAR} get-deps update-deps
+    ${REBAR3} get-deps
 fi
 
 # External repos frequently become integrated with the primary repo,
diff --git a/rebar.config.script b/rebar.config.script
index da3fc58..6d1b5cf 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -153,15 +153,14 @@
 {snappy,           "snappy",           {tag, "CouchDB-1.0.7"}},
 
 %% Non-Erlang deps
-{docs,             {url, "https://github.com/apache/couchdb-documentation"},
-                   {tag, "3.2.1-1"}, [raw]},
-{fauxton,          {url, "https://github.com/apache/couchdb-fauxton"},
-                   {tag, "v1.2.8"}, [raw]},
+{docs,             "documentation",    {tag, "rebar3-bogus-app"}},
+{fauxton,          "fauxton",          {tag, "rebar3-bogus-app"}},
+
 %% Third party deps
 {folsom,           "folsom",           {tag, "CouchDB-0.8.4"}},
 {hyper,            "hyper",            {tag, "CouchDB-2.2.0-7"}},
 {ibrowse,          "ibrowse",          {tag, "CouchDB-4.4.2-5"}},
-{jiffy,            "jiffy",            {tag, "CouchDB-1.0.9-1"}},
+{jiffy,            "jiffy",            {tag, "1.1.1"}},
 {mochiweb,         "mochiweb",         {tag, "CouchDB-v2.21.0-1"}},
 {meck,             "meck",             {tag, "0.9.2"}},
 {recon,            "recon",            {tag, "2.5.2"}}
@@ -193,13 +192,11 @@
 
 AddConfig = [
     {require_otp_vsn, "20|21|22|23|24"},
-    {deps_dir, "src"},
     {deps, lists:map(MakeDep, DepDescs ++ OptionalDeps)},
-    {sub_dirs, SubDirs},
-    {lib_dirs, ["src"]},
+    {project_app_dirs, SubDirs},
     {erl_opts, [{i, "../"}, {d, 'COUCHDB_ERLANG_VERSION', VerString}]},
     {eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]},
-    {plugins, [eunit_plugin]},
+    {escript_main_app, weatherreport}, % a hack for rebar3 support
     {dialyzer, [
         {plt_location, local},
         {plt_location, COUCHDB_ROOT},
diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script
index ba907b0..c2bf0ee 100644
--- a/src/couch/rebar.config.script
+++ b/src/couch/rebar.config.script
@@ -90,11 +90,11 @@
 
 CouchJSConfig = case SMVsn of
     "78" ->
-        "priv/couch_js/86/config.h";
+        "src/couch/priv/couch_js/86/config.h";
     "91" ->
-        "priv/couch_js/86/config.h";
+        "src/couch/priv/couch_js/86/config.h";
     _ ->
-        "priv/couch_js/" ++ SMVsn ++ "/config.h"
+        "src/couch/priv/couch_js/" ++ SMVsn ++ "/config.h"
 end.
 ConfigSrc = [["#define ", K, " ", V, $\n] || {K, V} <- ConfigH].
 ConfigBin = iolist_to_binary(ConfigSrc).
@@ -165,6 +165,8 @@
         }
 end.
 
+
+
 CouchJSSrc = case SMVsn of
     "1.8.5" -> ["priv/couch_js/1.8.5/*.c"];
     "60" -> ["priv/couch_js/60/*.cpp"];
@@ -196,7 +198,7 @@
 IcuWinEnv = [{"CFLAGS", "$DRV_CFLAGS /DXP_WIN"},
              {"LDFLAGS", "$LDFLAGS icuin.lib icudt.lib icuuc.lib"}].
 
-ComparePath = "priv/couch_ejson_compare.so".
+ComparePath = "src/couch/priv/couch_ejson_compare.so".
 CompareSrc = ["priv/couch_ejson_compare/*.c"].
 
 BaseSpecs = [
@@ -210,7 +212,7 @@
 ].
 
 SpawnSpec = [
-    {"priv/couchspawnkillable", ["priv/spawnkillable/*.c"]}
+    {"src/couch/priv/couchspawnkillable", ["src/couch/priv/spawnkillable/*.c"]}
 ].
 
 %% hack required until switch to enc/rebar3
@@ -223,15 +225,28 @@
     {win32, _} ->
         BaseSpecs ++ SpawnSpec;
     _ ->
-        {ok, CSK} = file:read_file("priv/spawnkillable/couchspawnkillable.sh"),
-        ok = CopyIfDifferent("priv/couchspawnkillable", CSK),
-        os:cmd("chmod +x priv/couchspawnkillable"),
+        {ok, CSK} = file:read_file("src/couch/priv/spawnkillable/couchspawnkillable.sh"),
+        ok = CopyIfDifferent("src/couch/priv/couchspawnkillable", CSK),
+        os:cmd("chmod +x src/couch/priv/couchspawnkillable"),
         BaseSpecs
 end.
+
 PlatformDefines = [
    {platform_define, "win32", 'WINDOWS'}
 ].
 AddConfig = [
+    {plugins, [{pc, "~> 1.0"}]},
+    {artifacts, [
+        "priv/couchjs",
+        "src/couch/priv/couch_ejson_compare.so",
+        "priv/couchspawnkillable"
+    ]},
+    {provider_hooks, [
+        {post, [
+            {compile, {pc, compile}},
+            {clean, {pc, clean}}
+        ]}
+    ]},
     {port_specs, PortSpecs},
     {erl_opts, PlatformDefines ++ [
         {d, 'COUCHDB_VERSION', Version},
diff --git a/src/docs b/src/docs
new file mode 120000
index 0000000..a148f33
--- /dev/null
+++ b/src/docs
@@ -0,0 +1 @@
+../_build/default/lib/docs
\ No newline at end of file
diff --git a/src/fauxton b/src/fauxton
new file mode 120000
index 0000000..624d7e4
--- /dev/null
+++ b/src/fauxton
@@ -0,0 +1 @@
+../_build/default/lib/fauxton
\ No newline at end of file