# Error while building percona mongodb server from source (6.0.16-13 and 7.0.12-7)

**URL:** <https://forums.percona.com/t/error-while-building-percona-mongodb-server-from-source-6-0-16-13-and-7-0-12-7/32365>\
**Category:** Percona Server for MongoDB\
**Tags:** percona, mongodb\
**Created:** [August 17, 2024, 9:30pm UTC](https://forums.percona.com/t/error-while-building-percona-mongodb-server-from-source-6-0-16-13-and-7-0-12-7/32365 "2024-08-17T21:30:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prakash\_S](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/prakash_s/32/17711_2.png) [@Prakash\_S](https://forums.percona.com/u/Prakash_S)\
**Post date:** [August 17, 2024, 9:30pm UTC](https://forums.percona.com/t/error-while-building-percona-mongodb-server-from-source-6-0-16-13-and-7-0-12-7/32365/1 "2024-08-17T21:30:09Z")

</div>

Hi, I am following the below link to build mongodb server pro from source code.

> **[Percona Server for MongoDB 6.0 - Build from source code](https://docs.percona.com/percona-server-for-mongodb/6.0/install/source.html#use-the-build-script)**
>
> This document guides you though the steps how to build Percona Server for MongoDB from source code.

Below are the steps i tried to build 6.0.16-13 version,

1. `wget https://raw.githubusercontent.com/percona/percona-server-mongodb/psmdb-6.0.16-13/percona-packaging/scripts/psmdb_builder.sh -O psmdb_builder.sh`

2. 

```auto
docker run -ti -u root -v /tmp/psmdb:/tmp/psmdb centos:7 sh -c '
set -o xtrace
cd /tmp/psmdb
bash -x ./psmdb_builder.sh --builddir=/tmp/psmdb/test --install_deps=1
bash -x ./psmdb_builder.sh --builddir=/tmp/psmdb/test --repo=https://github.com/percona/percona-server-mongodb.git --branch=release-6.0.16-13 --psm_ver=6.0.16 --psm_release=13 --mongo_tools_tag=100.10.0 --enable_fipsmode=1 --get_sources=1'

```

1. 

```auto
docker run -ti -u root -v /tmp/psmdb:/tmp/psmdb centos:7 sh -c '
set -o xtrace
cd /tmp/psmdb
bash -x ./psmdb_builder.sh --builddir=/tmp/psmdb/test --install_deps=1
bash -x ./psmdb_builder.sh --builddir=/tmp/psmdb/test --repo=https://github.com/percona/percona-server-mongodb.git \
--branch=release-6.0.16-13 --psm_ver=6.0.16 --psm_release=13 --mongo_tools_tag=100.10.0 --full-featured=1 --enable_fipsmode=1 --build_src_rpm=1'

```

1. 

```auto
docker run -ti -u root -v /tmp/psmdb:/tmp/psmdb oraclelinux:9 sh -c '
set -o xtrace
cd /tmp/psmdb
bash -x ./psmdb_builder.sh --builddir=/tmp/psmdb/test --install_deps=1
bash -x ./psmdb_builder.sh --builddir=/tmp/psmdb/test --repo=https://github.com/percona/percona-server-mongodb.git \
--branch=release-6.0.16-13 --psm_ver=6.0.16 --psm_release=13 --mongo_tools_tag=100.10.0 --full-featured=1 --enable_fipsmode=1 --build_rpm=1'

```

I am able to do step #2 (get\_sources) and #3 (build\_src\_rpm) but during the #4, i am getting the below error,

**+ cp -r /tmp/psmdb/test/rpmbuild/BUILD/./percona-server-mongodb-6.0.16-13/mongo-tools /tmp/psmdb/test/rpmbuild/BUILD//src/github.com/mongodb**  
**+ pushd /tmp/psmdb/test/rpmbuild/BUILD//src/github.com/mongodb/mongo-tools**  
**/tmp/psmdb/test/rpmbuild/BUILD/src/github.com/mongodb/mongo-tools /tmp/psmdb/test/rpmbuild/BUILD /tmp/psmdb/test/rpmbuild/BUILD/percona-server-mongodb-6.0.16-13**  
**+ . ./set\_tools\_revision.sh**  
**++ export PSMDB\_TOOLS\_COMMIT\_HASH=6d4f001be3fcf673de04d20176e90ee02ef233a9**  
**++ PSMDB\_TOOLS\_COMMIT\_HASH=6d4f001be3fcf673de04d20176e90ee02ef233a9**  
**++ export PSMDB\_TOOLS\_REVISION=6.0.16-13**  
**++ PSMDB\_TOOLS\_REVISION=6.0.16-13**  
**+ sed -i 15d buildscript/build.go**  
**+ sed -i 195,204d buildscript/build.go**  
**+ sed -i ‘s:versionStr,:“6.0.16-13”,:’ buildscript/build.go**  
**+ sed -i ‘s:gitCommit):“6d4f001be3fcf673de04d20176e90ee02ef233a9”):’ buildscript/build.go**  
**+ ./make build**  
**# [github.com/mongodb/mongo-tools/buildscript](http://github.com/mongodb/mongo-tools/buildscript)**  
**buildscript/build.go:195:2: syntax error: non-declaration statement outside function body**  
**error: Bad exit status from /var/tmp/rpm-tmp.7XRhkh (%build)**  
**RPM build errors:**  
\*\* Bad exit status from /var/tmp/rpm-tmp.7XRhkh (%build)\*\*  
**+ return\_code=1**  
**+ ‘[’ 1 ‘!=’ 0 ‘]’**  
**+ exit 1**

I tried with latest 7.0.12-7 and also older versions of 6.x, but the build\_rpm step is always failed in this step. Please suggest how to resolve this issue and i am in need of rpm package for mongod and mongo shell?

---

<div class="post-metadata">

**Author:** ![Prakash\_S](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/prakash_s/32/17711_2.png) [@Prakash\_S](https://forums.percona.com/u/Prakash_S)\
**Post date:** [August 19, 2024, 6:37am UTC](https://forums.percona.com/t/error-while-building-percona-mongodb-server-from-source-6-0-16-13-and-7-0-12-7/32365/2 "2024-08-19T06:37:28Z")

</div>

Can anyone please help on resolving this error or is there any other approach to build rpm for mongod pro version ?

---

<div class="post-metadata">

**Author:** ![Sandra\_Romanchenko](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sandra_romanchenko/32/84_2.png) [@Sandra\_Romanchenko](https://forums.percona.com/u/Sandra_Romanchenko)\
**Post date:** [August 19, 2024, 7:47am UTC](https://forums.percona.com/t/error-while-building-percona-mongodb-server-from-source-6-0-16-13-and-7-0-12-7/32365/3 "2024-08-19T07:47:08Z")

</div>

Hi,

PSMDB 6.0.16-13 and 7.0.12-7 is supposed to have mongo tools 100.9.5 version, please try to use this version for all the build steps.
