Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[ENHANCEMENT]: Simplify couchdb wrapper script logic

Open
#6,117 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
shell
Domain
build-system

Research direction

Start with rel/files/couchdb.in and compare its current canonical_readlink and $0 handling with the proposed {{prefix}} change. Read the configure process and rel/couchdb.config to determine how custom installation roots are represented. Done means the wrapper works when execed without breaking deployments whose installation prefix is not the default.

Written by the indexing model from the issue text.

Description

enhancement needs-triage
Provide a brief overview of what the new feature is all about

I propose the following:

diff --git a/rel/files/couchdb.in b/rel/files/couchdb.in
index 332bfe0f2..7837d794f 100755
--- a/rel/files/couchdb.in
+++ b/rel/files/couchdb.in
@@ -12,19 +12,8 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
-canonical_readlink ()
-  {
-  FILE=$(dirname "$1")/$(basename "$1");
-  if [ -h "$FILE" ]; then
-    cd $(dirname "$1")
-    canonical_readlink $(readlink "$FILE");
-  else
-    cd "${1%/*}" && pwd -P;
-  fi
-}
-COUCHDB_BIN_DIR=$(canonical_readlink "$0")
-ERTS_BIN_DIR=$COUCHDB_BIN_DIR/../
-cd "$COUCHDB_BIN_DIR/../"
+ERTS_BIN_DIR="{{prefix}}"
+cd "$ERTS_BIN_DIR"
 
 export ROOTDIR=${ERTS_BIN_DIR%/*}

This makes the script work when it is execed. $0 cannot be relied upon when execing and it is kinda unreliable in general (there are bunch of edge cases related to it), it should be avoided wherever possible. prefix is the ideal substitute solving all inconveniences.

I would make a PR out of it, but the configure script is very rudimentary and there is (to my knowledge) no way to override the location of root other than editing rel/couchdb.config after configuring.

I find it likely that there are users/distros/packagers which install couchdb into custom locations but are unaware that rel/couchdb.config requires editing (I don't think that this fact is documented anywhere), so substituting {{prefix}} will lead to ., which will break existing and new deployments of couchdb.

This is all a result of couchdb's non-standard build process which was designed to not support installing couchdb. I think that I read somewhere that making couchdb properly installable is on the roadmap. If it ever gets implemented, this proposed change could be added too.

The advantages provided by this change are miniscule (I consider the exec and $0 things to be very minor issues, I see the main value of this change in simplifying the script and being able to dump canonical_readlink()), the disadvantages are significant.

Dominant language
Erlang
Stars
7k
Forks
1.1k
Avg merge
10h 14m
Merged PRs (30d)
36

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/couchdb

All issues in apache/couchdb

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.