[SERVER-48885] Pathsplit bug in build.ninja generated file with PATH components containing spaces Created: 15/Jun/20  Updated: 29/Oct/23  Resolved: 09/Jul/20

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: 4.5.1
Fix Version/s: 4.4.1, 4.7.0

Type: Bug Priority: Major - P3
Reporter: Sara Golemon Assignee: Ryan Egesdahl (Inactive)
Resolution: Fixed Votes: 0
Labels: macos, macos-catalina
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4
Sprint: Dev Platform 2020-06-29, Dev Platform 2020-07-13
Participants:

 Description   

While attempting to build on macOS Catalina, I received an error: 

/bin/sh: Fusion.app/Contents/Public: No such file or directory

Which immediately looks like a path split on "VMware Fusion" and is confirmed by looking in build.ninja and seeing many repetitions of the following pattern:

build +auth_op_observer_test: CMD build/install/bin/db_auth_test | build/install/bin/db_auth_test $
    || _generated_sources
  pool = console
  cmd = build/install/bin/db_auth_test -fileNameFilter auth_op_observer_test
  env = PATH=/usr/local/bin:/opt/bin:/bin:/usr/bin $
      PATHOSX=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware $
      Fusion.app/Contents/Public 

Manually editing this file to include a backslash after "VMware\ " resolves the issue.

scons invocation:

python3.7 buildscripts/scons.py --link-model=static -j24 MONGO_VERSION=0.0.0 MONGO_GIT_HASH=unknown --ninja build.ninja

macOS: 10.15.2
Xcode: 11.1 (11A1027)
python: 3.7.2 (Homebrew)



 Comments   
Comment by Githook User [ 06/Aug/20 ]

Author:

{'name': 'Ryan Egesdahl', 'email': 'ryan.egesdahl@mongodb.com', 'username': 'deriamis'}

Message: SERVER-48885 Environment variables values with spaces can cause build failures

If any environment variable (including PATH) were to somehow make its
way into your build.ninja, it would cause build failures due to the fact
that the shell splits it into separate arguments. This can happen
sometimes especially on OSX, where the PATHOSX environment variable gets
(incorrectly) copied by SCons into the current build environment.
Regardless of whatever SCons should be doing, we will quote environment
variable values in Ninja builds to ensure it doesn't happen again.

(cherry picked from commit c7348f391124e681d9c62aceb0e13e0d07fca8bc)
Branch: v4.4
https://github.com/mongodb/mongo/commit/873fac7144b8d98587bc7e41a708b3120a1cdd83

Comment by Andrew Morrow (Inactive) [ 13/Jul/20 ]

Tagging this for backport to v4.4.

Comment by Githook User [ 09/Jul/20 ]

Author:

{'name': 'Ryan Egesdahl', 'email': 'ryan.egesdahl@mongodb.com', 'username': 'deriamis'}

Message: SERVER-48885 Environment variables values with spaces can cause build failures

If any environment variable (including PATH) were to somehow make its
way into your build.ninja, it would cause build failures due to the fact
that the shell splits it into separate arguments. This can happen
sometimes especially on OSX, where the PATHOSX environment variable gets
(incorrectly) copied by SCons into the current build environment.
Regardless of whatever SCons should be doing, we will quote environment
variable values in Ninja builds to ensure it doesn't happen again.
Branch: master
https://github.com/mongodb/mongo/commit/c7348f391124e681d9c62aceb0e13e0d07fca8bc

Comment by Ryan Egesdahl (Inactive) [ 26/Jun/20 ]

This is related to the fact that Ninja does not allow setting environments on shell executions (which is just weird and nonstandard), and the fact that we aren't quoting shell variables on *NIX builds (but we do on Windows). It's a little hackish the way we set the environment even then, but I'm going try just quoting the environment variables and see what happens.

Generated at Thu Feb 08 05:18:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.