Skip to content

Failed to invoke nproc alias #2

@bradhowes

Description

@bradhowes
(venv) howes% ./open_spiel/scripts/build_and_run_tests.sh
++ CXX=g++
++ [[ darwin18 == \d\a\r\w\i\n* ]]
++ alias 'nproc=sysctl -n hw.physicalcpu'
++ CXX=/usr/local/bin/g++-7
+++ nproc
./open_spiel/scripts/build_and_run_tests.sh: line 37: nproc: command not found
++ MAKE_NUM_PROCS=

Apparently nproc alias is not expanded in the build_and_run_tests.sh script in the $(nproc) expression. My fix:

diff --git a/open_spiel/scripts/build_and_run_tests.sh b/open_spiel/scripts/build_and_run_tests.sh
index ba0ec84..a4a64ab 100755
--- a/open_spiel/scripts/build_and_run_tests.sh
+++ b/open_spiel/scripts/build_and_run_tests.sh
@@ -29,13 +29,14 @@ set -e  # exit when any command fails
 set -x
 
 CXX=g++
+NPROC=nproc
 if [[ "$OSTYPE" == "darwin"* ]]; then  # Mac OSX
-  alias nproc="sysctl -n hw.physicalcpu"
+  NPROC="sysctl -n hw.physicalcpu"
   CXX=/usr/local/bin/g++-7
 fi
 
-MAKE_NUM_PROCS=$(nproc)
-let TEST_NUM_PROCS=4*$(nproc)
+MAKE_NUM_PROCS=$(${NPROC})
+let TEST_NUM_PROCS=4*${MAKE_NUM_PROCS}
 
 PYVERSION=$(python3 -c 'import sys; print(sys.version.split(" ")[0])')
 PY_VERSION_MAJOR=$(python3 -c 'import sys; print(sys.version_info.major)')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions