# Root broken after removing build directory

**URL:** <https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593>\
**Category:** Newbie\
**Tags:** build, installation\
**Created:** [March 20, 2024, 3:24am UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593 "2024-03-20T03:24:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Y.S.Zhang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/cab0a1/32.png) [@Y.S.Zhang](https://root-forum.cern.ch/u/Y.S.Zhang)\
**Post date:** [March 20, 2024, 3:24am UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/1 "2024-03-20T03:24:37Z")

</div>

Dear experts,

I tried to build the root from scratch in a docker container. I build everything from the source and root prompt seems ok after installing it. However, root is broken after I deleted build directory. It shows me errors like

```auto
input_line_1:1:2: fatal error: module file '/home/username/packages/cern-root/build-v6-30-04/lib/libc.pcm' not found: module file not found
#include <new>
 ^
input_line_1:1:2: note: imported by module 'std' in '/opt/root-v6.30.04/lib/std.pcm'
Warning in cling::IncrementalParser::CheckABICompatibility():
  Failed to extract C++ standard library version.
Replaced symbol atexit cannot be found in JIT!
Replaced symbol at_quick_exit cannot be found in JIT!
Module libc not found.
Failed to load module std
<<< cling interactive line includer >>>: fatal error: module file '/home/username/packages/cern-root/build-v6-30-04/lib/libc.pcm' not found: module file not found
<<< cling interactive line includer >>>: note: imported by module '_Builtin_intrinsics' in '/opt/root-v6.30.04/lib/_Builtin_intrinsics.pcm'
Failed to load module _Builtin_intrinsics
Failed to load module ROOT_Foundation_C
Failed to load module ROOT_Rtypes
Failed to load module ROOT_Foundation_Stage1_NoRTTI
Failed to load module Core
...

```

I have truncated more error messages.

To reproduce the problem, one can follow the dockerfile as attached.

```Dockerfile
 FROM debian:latest
 COPY bash_install_root.sh /
 RUN apt-get update && apt-get upgrade && apt-get install -y git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev python3 libssl-dev gfortran libpcre3-dev xlibmesa-glu-dev libglew-dev libftgl-dev libmariadb-dev libfftw3-dev libcfitsio-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev python3-dev python3-numpy libxml2-dev libkrb5-dev libgsl0-dev qtwebengine5-dev nlohmann-json3-dev liblzma-dev libtbb-dev libvdt-dev libopenblas-dev libsm-dev libice-dev python3-pygments python3-yaml davix-dev libafterimage-dev libcfitsio-dev && bash bash_install_root.sh
 CMD ["/bin/bash", "-i"]

```

and a script called `bash_install_root.sh`,

```shell
#!/bin/bash
BaseDir="/home/username/packages/cern-root"
GitVerTag="v6-30-04"
VerTag="v6.30.04"
SourceDir="${BaseDir}/root"
BuildDir="${BaseDir}/build-${GitVerTag}"
InstallDir="/opt/root-${VerTag}"

echo "Installing root..."
echo "Cloning root >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
# bad practice to use -p
mkdir -p $InstallDir
mkdir -p $BaseDir && cd $BaseDir
git clone https://github.com/root-project/root.git ${SourceDir}
cd $SourceDir
git checkout -b $GitVerTag $GitVerTag
echo "Configuring root >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
mkdir -p ${BuildDir} && cd ${BuildDir}
cmake ${SourceDir} -DCMAKE_INSTALL_PREFIX=$InstallDir > ../cmake_config_${VerTag}.log 2>&1
echo "Building root >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
cmake --build . --target install > ../cmake_build_${VerTag}.log 2>&1
echo "Testing >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
${InstallDir}/bin/root -b -q
echo "Done >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"

```

I wonder if I made anything wrong in the cmake configuration. Suggestions are welcome! I would like to decouple the build directory from the installation.

Thanks!

* * *

_Please read [tips for efficient and successful posting](https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292) and [posting code](https://root-forum.cern.ch/t/posting-code-read-this-first/28293)_

_ROOT Version:_ 6.30.04  
_Platform:_ Debian latest  
_Compiler:_ gcc-12.2.0

* * *

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [March 20, 2024, 8:18am UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/2 "2024-03-20T08:18:56Z")

</div>

Hi Yousen,

I am sorry to see you experienced this issue.  
I add in the loop @mczurylo , who might be able to help here.

Best,  
D

---

<div class="post-metadata">

**Author:** ![mczurylo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mczurylo/32/33269_2.png) [@mczurylo](https://root-forum.cern.ch/u/mczurylo)\
**Post date:** [March 20, 2024, 9:01am UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/3 "2024-03-20T09:01:37Z")

</div>

Hi @Y.S.Zhang,

I will take a deeper look into your issue, but first of all I would like to ask if you considered using the already built docker images for 6.30.04: [Docker](https://hub.docker.com/r/rootproject/root) ?

Cheers,  
Marta

---

<div class="post-metadata">

**Author:** ![Y.S.Zhang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/cab0a1/32.png) [@Y.S.Zhang](https://root-forum.cern.ch/u/Y.S.Zhang)\
**Post date:** [March 20, 2024, 3:00pm UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/4 "2024-03-20T15:00:26Z")

</div>

Hi @mczurylo

Thanks for your kind help!

I do not want to use docker because I need simple gui.

The reason why I would like to build docker on debian is because I am working on debian and I want to package the binary from docker to my debian desktop.

I tried to build root directly on debian. However, I am not sure why I always encounter the issue

```auto
Module libc not found.

```

I built v6.28.06 last year and there was no such warning. I tried to upgrade to secured release and now I face this problem. The warning message event shows up for v6.28.06 now which is weird. I guess it is related to changes in my debian environment. I do not have an idea how to reproduce this separate issue. Similar issues were also asked in the fora but never answered. See [Module libc not found](https://root-forum.cern.ch/t/module-libc-not-found/49651)

When I build on fresh debian docker, there is no issue about `libc` not found. However, I have issue to isolate install from build.

---

<div class="post-metadata">

**Author:** ![mczurylo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mczurylo/32/33269_2.png) [@mczurylo](https://root-forum.cern.ch/u/mczurylo)\
**Post date:** [March 21, 2024, 3:16pm UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/5 "2024-03-21T15:16:30Z")

</div>

Hi @Y.S.Zhang,

Thank you for giving me some more details. So what I did now, was to use your script to simply build root on my macbook (could be possible there are still some differences). At first I could reproduce the issue and there was nothing in my install directory but then I realised the main issue with your script here is that you are trying to install root in /opt/ directory that normally requires the sudo rights. Additionally, another thing, which you may need is another cmake option: `-Dbuiltin_glew=ON` (and this should have been indicated by the error message while trying to run this script). So eventually, I have:

```auto
echo "Installing root..."
echo "Cloning root >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
# bad practice to use -p
sudo mkdir -p $InstallDir
mkdir -p $BaseDir && cd $BaseDir
git clone https://github.com/root-project/root.git ${SourceDir}
cd $SourceDir
git checkout -b $GitVerTag $GitVerTag
echo "Configuring root >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
mkdir -p ${BuildDir} && cd ${BuildDir}
cmake ${SourceDir} -DCMAKE_INSTALL_PREFIX=$InstallDir -Dbuiltin_glew=ON > ../cmake_config_${VerTag}.log 2>&1
echo "Building root >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
sudo cmake --build . -- install > ../cmake_build_${VerTag}.log 2>&1
echo "Testing >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
${InstallDir}/bin/root -b -q
echo "Done >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"

```

Let me know if this solves your issue or if we need to dig deeper.

Cheers,  
Marta

---

<div class="post-metadata">

**Author:** ![Y.S.Zhang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/cab0a1/32.png) [@Y.S.Zhang](https://root-forum.cern.ch/u/Y.S.Zhang)\
**Post date:** [March 21, 2024, 4:38pm UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/6 "2024-03-21T16:38:42Z")

</div>

Hi Marta,

Thanks for your help! I have two questions.

- What is the use for option built\_glew?
- I am afraid I am not clear why `/opt` needs root permission in a docker/podman environment. I have executables of root under `/opt` in docker/podman environment in my test on debian desktop.

In the docker environment, I can execute root unless I delete or rename the build directory. I am confused why root cannot recognize the install directory as path for library loading.

Cheers,

Yousen

---

<div class="post-metadata">

**Author:** ![mczurylo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mczurylo/32/33269_2.png) [@mczurylo](https://root-forum.cern.ch/u/mczurylo)\
**Post date:** [March 22, 2024, 3:24pm UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/7 "2024-03-22T15:24:06Z")

</div>

Hi @Y.S.Zhang,

but does executing the script itself work for you? Have you tried running it before building the docker image itself? It didn’t work for me in a sense that nothing was installed in the install directory because I could not access it. What happens if you change the install directory to somewhere else, for example, the same directory where you have your source and build directories?

Regarding Glew - it is CMake related, when I run the script I see:

```auto
CMake Error at cmake/modules/SearchInstalledSoftware.cmake:615 (message):
 Please enable builtin Glew due bug in latest CMake (use cmake option
 -Dbuiltin_glew=ON).
Call Stack (most recent call first):
 CMakeLists.txt:300 (include)

```

but it might be the case that you don’t see this issue, then you don’t need this option.

Cheers,  
Marta

---

<div class="post-metadata">

**Author:** ![Y.S.Zhang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/cab0a1/32.png) [@Y.S.Zhang](https://root-forum.cern.ch/u/Y.S.Zhang)\
**Post date:** [March 25, 2024, 2:18pm UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/8 "2024-03-25T14:18:24Z")

</div>

Dear Marta,

I have a full installation under `/opt/root-v6.30.04`. And I can have working functions under `/opt/root-v6.30/`. I tried a hello world example and it works perfectly. It is surprising that we have different permission to access the target directory using docker environment.

The system wide installation should be done no matter where the build directory is. I suppose root will search `rpath` for loading libraries. I tried to look through run path of root.

```auto
chrpath -l /opt/root-v6.30.04/bin/root
# RUNPATH=${ORIGIN}:${ORIGIN}/../lib

```

I am not sure where root searches for `$ORIGIN`.

I would expect it to be the installation directory. However, it seems not. The option `-Drpath=ON` is default on for root. I wonder what is the effects of this option.

I am also curious the effects of option `gnuinstall` which is default off, as indicated in the [instruction](https://root.cern/install/build_from_source/#location-independent-installation-gnuinstalloff) for build.

Thanks!

Yousen

---

<div class="post-metadata">

**Author:** ![mczurylo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mczurylo/32/33269_2.png) [@mczurylo](https://root-forum.cern.ch/u/mczurylo)\
**Post date:** [April 4, 2024, 7:39am UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/9 "2024-04-04T07:39:29Z")

</div>

Hi @Y.S.Zhang,

I’m sorry for the delayed response - maybe you’ve found a solution to your problem in the meantime, but let me post here what worked for me just in case. What I followed directly is the [Dockerfile for ubuntu](https://github.com/root-project/root-docker/blob/master/ubuntu/Dockerfile) that we use to build images and what I now used for your case is:

```auto
FROM debian:latest

ENV LANG=C.UTF-8

WORKDIR /opt

COPY bash_install_root.sh bash_install_root.sh

RUN apt-get update -qq \
 && apt-get -y install git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev python3 libssl-dev gfortran libpcre3-dev xlibmesa-glu-dev libglew-dev libftgl-dev libmariadb-dev libfftw3-dev libcfitsio-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev python3-dev python3-numpy libxml2-dev libkrb5-dev libgsl0-dev qtwebengine5-dev nlohmann-json3-dev liblzma-dev libtbb-dev libvdt-dev libopenblas-dev libsm-dev libice-dev python3-pygments python3-yaml davix-dev libafterimage-dev libcfitsio-dev\
 && bash bash_install_root.sh \
 && echo /opt/root/lib >> /etc/ld.so.conf \
 && ldconfig \
 && echo /opt/root/lib >> /etc/ld.so.conf \
 && ldconfig

ENV ROOTSYS /opt/root
ENV PATH $ROOTSYS/bin:$PATH
ENV PYTHONPATH $ROOTSYS/lib:$PYTHONPATH
ENV CLING_STANDARD_PCH none

CMD ["/bin/bash", "-i"]

```

This allows me to build a working version of root without changing your bash script. In order to build root inside the image I run your bash script and sourced the /bin/thisroot.sh.

Cheers,  
Marta

---

<div class="post-metadata">

**Author:** ![mczurylo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mczurylo/32/33269_2.png) [@mczurylo](https://root-forum.cern.ch/u/mczurylo)\
**Post date:** [April 4, 2024, 7:47am UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/10 "2024-04-04T07:47:51Z")

</div>

Hi @Y.S.Zhang,

one more thing - now ROOT 6.30.06 is out so you can also try installing this one instead of 6.30.04.

Cheers,  
Marta

---

<div class="post-metadata">

**Author:** ![Y.S.Zhang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/cab0a1/32.png) [@Y.S.Zhang](https://root-forum.cern.ch/u/Y.S.Zhang)\
**Post date:** [April 4, 2024, 2:11pm UTC](https://root-forum.cern.ch/t/root-broken-after-removing-build-directory/58593/11 "2024-04-04T14:11:19Z")

</div>

Hi @mczurylo thank you so much! The solution is very helpful!
