Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-58904

Escaped or single-quoted DESTDIR causes malformed .ninja and resmoke.ini

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.3, 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v5.0
    • Dev Platform 2021-08-09

      Generate a build.ninja file which explicitly sets DESTDIR to $BUILD_ROOT/install using either escaping (i.e. DESTDIR=\$BUILD_ROOT/install) or single-quoting (i.e. DESTDIR='$BUILD_ROOT/install'). For instance:

      python buildscripts/scons.py CCFLAGS='-gsplit-dwarf' --variables-files=etc/scons/developer_versions.vars --disable-warnings-as-errors --link-model=dynamic --opt=off VARIANT_DIR=ninja DESTDIR=\$BUILD_ROOT/install --variables-files=etc/scons/mongodbtoolchain_stable_clang.vars --ninja --modules= --install-mode=hygienic ICECC=icecc CCACHE=ccache NINJA_PREFIX=build-mongo NINJA_SUFFIX=ninja generate-ninja
      

      After the file is generated, the SCONS invocation recorded in build.ninja and the contents of resmoke.ini both appear correct:

      SCONS_INVOCATION = /home/ubuntu/python-env/mongo-python3/bin/python "buildscripts/scons.py" $
          "CCFLAGS=-gsplit-dwarf" "--variables-files=etc/scons/developer_versions.vars" $
          "--disable-warnings-as-errors" "--link-model=dynamic" "--opt=off" "VARIANT_DIR=ninja" $
          "DESTDIR=\$BUILD_ROOT/install" $
          "--variables-files=etc/scons/mongodbtoolchain_stable_clang.vars" "--ninja" "--modules=" $
          "--install-mode=hygienic" "ICECC=icecc" "CCACHE=ccache" "NINJA_PREFIX=build-mongo" $
          "NINJA_SUFFIX=ninja" __NINJA_NO=1 $out
      
      [resmoke]
      install_dir = build/install/bin
      

      However, if you now build the server using ninja, it will cause the resmoke.ini file to become corrupted:

      [resmoke]
      install_dir = \\/install/bin
      

      This will prevent any resmoke tests from being run:

      buildscripts/resmoke.py run jstests/noPassthrough/change_stream_sharded_startafter_invalidate.js
      ...
      [j0] Starting mongod on port 20000...
      'PATH=/home/ubuntu/mongo-dev/mongo:/data/multiversion:/home/ubuntu/mongo-dev/mongo/\\/install/bin:/home/ubuntu/python-env/mongo-python3/bin:/home/ubuntu/.nvm/versions/node/v16.4.0/bin:/opt/go/bin:/home/ubuntu/mongo/build/install/bin
      ...
      [j0] Failed to start mongod on port 20000: [Errno 2] No such file or directory: '/home/ubuntu/mongo-dev/mongo/\\\\/install/bin/mongod': '/home/ubuntu/mongo-dev/mongo/\\\\/install/bin/mongod'
      

      If build.ninja is subsequently auto-regenerated due to any changes in SConstruct or Sconscript files, the build.ninja file will itself become similarly corrupted:

      SCONS_INVOCATION = /home/ubuntu/python-env/mongo-python3/bin/python "buildscripts/scons.py" $
          "CCFLAGS=-gsplit-dwarf" "--variables-files=etc/scons/developer_versions.vars" $
          "--disable-warnings-as-errors" "--link-model=dynamic" "--opt=off" "VARIANT_DIR=ninja" $
          "DESTDIR=\\/install" "--variables-files=etc/scons/mongodbtoolchain_stable_clang.vars" $
          "--ninja" "--modules=" "--install-mode=hygienic" "ICECC=icecc" "CCACHE=ccache" $
          "NINJA_PREFIX=build-mongo" "NINJA_SUFFIX=ninja" __NINJA_NO=1 $out
      

            Assignee:
            daniel.moody@mongodb.com Daniel Moody
            Reporter:
            bernard.gorman@mongodb.com Bernard Gorman
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: