Virtual-environments: No output on “Process completed with exit code 1”

Created on 22 Jul 2020  ·  1Comment  ·  Source: actions/virtual-environments

Associated community ticket: https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821

In this ticket, the customer has a run step to execute some command lines in the container job (image: centos:7).
One of the command lines is calling a .sh script file (see here). But this command line failed and returned the error message like as below:

##[error]Process completed with exit code 1.

The customer enabled the debug logging to try get more information about this error, but the debug logs seem were not helpful. It still only returned the same one error message.

According to my troubleshooting, the error seems was returned by a certain command line in the called .sh script.
The customer also run the same type workflow on Ubuntu 18.04, 20.04, and on macOS, but without any failures there.
And he just tried running the exact same commands in the same CentOS docker container that the failing workflow is using, and I cannot reproduce the error.

Containers DeploymenRelease bug

Most helpful comment

Issue:
https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/9
##[error]Process completed with exit code 1.

Fix:
. scl_source enable llvm-toolset-6.0 || true

or

. $INSTALL_DIR/bin/thisbdm.sh replace to $INSTALL_DIR/bin/thisbdm.sh

Explanation:

  1. https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/7?u=al-cheb
 - name: System tests BioDynaMo
       shell: bash
       working-directory: build
       run: |
         set -x

Line:

2020-07-23T11:30:35.2865130Z +++ /usr/bin/scl_enabled llvm-toolset-6.0
2020-07-23T11:30:35.3275453Z ##[error]Process completed with exit code 1.

I found out which part of code is executing this line:

  1. https://github.com/BioDynaMo/biodynamo/blob/5092924f4caf7a90ed815031c2b00b259a7ca571/cmake/env/thisbdm.sh#L374
  2. executing line . scl_source enable llvm-toolset-6.0
  3. failed line at the scl_source code
# Now check if the collection isn't already enabled
/usr/bin/scl_enabled $arg > /dev/null 2> /dev/null      <- failed line
    if [ $? -ne 0 ]; then
for     _scls+=($arg)
    _scl_prefixes+=($_scl_prefix)
    fi;
done

Fix:

run: |
        . scl_source enable devtoolset-7 || true
        . scl_source enable llvm-toolset-6.0 || true
        . /etc/profile.d/modules.sh || true
        module load mpi
        . $INSTALL_DIR/bin/thisbdm.sh
        git config --system user.name "Test User"
        git config --system user.email [email protected]
        xvfb-run -d -s "-screen 0 2560x1440x24" make run-demos

alt text

  1. https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/9?u=al-cheb

@senui,

Case with source:
The /usr/bin/scl_enabled llvm-toolset-6.0 encounters a exit 1 which is different from zero. It will terminate the scl_source code instantaneously due to the exit statement and that's why:
. $INSTALL_DIR/bin/thisbdm.sh - failed and $INSTALL_DIR/bin/thisbdm.sh - works

Looks like it by design:

return [n]

Causes a function to exit with the return value specified by n. If used outside a function, but during execution of a script by the . (source) command, it causes the shell to stop executing that script and return either n or the exit status of the last command executed within the script as the exit status of the script. If used outside a function and not during execution of a script by ., the return status is false.

source filename [arguments]
    Read and execute commands from filename in the current shell environment and
    return **the exit status of the last command executed from filename**. 

https://askubuntu.com/questions/182012/is-there-a-difference-between-and-source-in-bash-after-all?lq=1

Reproduce behavior:

Without source( ./test.sh):

steps:
      - name: Test

        run: |
          cat <<EOF > $HOME/subscript.sh
          #!/bin/sh
          exit 1
          EOF
          chmod +x $HOME/subscript.sh

          cat <<EOF > test.sh
          #!/bin/bash
          $HOME/subscript.sh
          if [ $? -ne 0 ]; then
              echo PASS
          fi;
          EOF

          chmod +x ./test.sh
          echo START
          ./test.sh
          echo END

alt text

With source(source ./test.sh):

steps:
      - name: Test

        run: |
          cat <<EOF > $HOME/subscript.sh
          #!/bin/sh
          exit 1
          EOF
          chmod +x $HOME/subscript.sh

          cat <<EOF > test.sh
          #!/bin/bash
          $HOME/subscript.sh
          if [ $? -ne 0 ]; then
              echo PASS
          fi;
          EOF

          chmod +x ./test.sh
          echo START
          source ./test.sh
          echo END

alt text

With source || true (source ./test.sh || true):

    steps:
      - name: Test

        run: |
          cat <<EOF > $HOME/subscript.sh
          #!/bin/sh
          exit 1
          EOF
          chmod +x $HOME/subscript.sh

          cat <<EOF > test.sh
          #!/bin/bash
          $HOME/subscript.sh
          if [ $? -ne 0 ]; then
              echo PASS
          fi;
          EOF

          chmod +x ./test.sh
          echo START
          source ./test.sh || true
          echo END

alt text

>All comments

Issue:
https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/9
##[error]Process completed with exit code 1.

Fix:
. scl_source enable llvm-toolset-6.0 || true

or

. $INSTALL_DIR/bin/thisbdm.sh replace to $INSTALL_DIR/bin/thisbdm.sh

Explanation:

  1. https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/7?u=al-cheb
 - name: System tests BioDynaMo
       shell: bash
       working-directory: build
       run: |
         set -x

Line:

2020-07-23T11:30:35.2865130Z +++ /usr/bin/scl_enabled llvm-toolset-6.0
2020-07-23T11:30:35.3275453Z ##[error]Process completed with exit code 1.

I found out which part of code is executing this line:

  1. https://github.com/BioDynaMo/biodynamo/blob/5092924f4caf7a90ed815031c2b00b259a7ca571/cmake/env/thisbdm.sh#L374
  2. executing line . scl_source enable llvm-toolset-6.0
  3. failed line at the scl_source code
# Now check if the collection isn't already enabled
/usr/bin/scl_enabled $arg > /dev/null 2> /dev/null      <- failed line
    if [ $? -ne 0 ]; then
for     _scls+=($arg)
    _scl_prefixes+=($_scl_prefix)
    fi;
done

Fix:

run: |
        . scl_source enable devtoolset-7 || true
        . scl_source enable llvm-toolset-6.0 || true
        . /etc/profile.d/modules.sh || true
        module load mpi
        . $INSTALL_DIR/bin/thisbdm.sh
        git config --system user.name "Test User"
        git config --system user.email [email protected]
        xvfb-run -d -s "-screen 0 2560x1440x24" make run-demos

alt text

  1. https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/9?u=al-cheb

@senui,

Case with source:
The /usr/bin/scl_enabled llvm-toolset-6.0 encounters a exit 1 which is different from zero. It will terminate the scl_source code instantaneously due to the exit statement and that's why:
. $INSTALL_DIR/bin/thisbdm.sh - failed and $INSTALL_DIR/bin/thisbdm.sh - works

Looks like it by design:

return [n]

Causes a function to exit with the return value specified by n. If used outside a function, but during execution of a script by the . (source) command, it causes the shell to stop executing that script and return either n or the exit status of the last command executed within the script as the exit status of the script. If used outside a function and not during execution of a script by ., the return status is false.

source filename [arguments]
    Read and execute commands from filename in the current shell environment and
    return **the exit status of the last command executed from filename**. 

https://askubuntu.com/questions/182012/is-there-a-difference-between-and-source-in-bash-after-all?lq=1

Reproduce behavior:

Without source( ./test.sh):

steps:
      - name: Test

        run: |
          cat <<EOF > $HOME/subscript.sh
          #!/bin/sh
          exit 1
          EOF
          chmod +x $HOME/subscript.sh

          cat <<EOF > test.sh
          #!/bin/bash
          $HOME/subscript.sh
          if [ $? -ne 0 ]; then
              echo PASS
          fi;
          EOF

          chmod +x ./test.sh
          echo START
          ./test.sh
          echo END

alt text

With source(source ./test.sh):

steps:
      - name: Test

        run: |
          cat <<EOF > $HOME/subscript.sh
          #!/bin/sh
          exit 1
          EOF
          chmod +x $HOME/subscript.sh

          cat <<EOF > test.sh
          #!/bin/bash
          $HOME/subscript.sh
          if [ $? -ne 0 ]; then
              echo PASS
          fi;
          EOF

          chmod +x ./test.sh
          echo START
          source ./test.sh
          echo END

alt text

With source || true (source ./test.sh || true):

    steps:
      - name: Test

        run: |
          cat <<EOF > $HOME/subscript.sh
          #!/bin/sh
          exit 1
          EOF
          chmod +x $HOME/subscript.sh

          cat <<EOF > test.sh
          #!/bin/bash
          $HOME/subscript.sh
          if [ $? -ne 0 ]; then
              echo PASS
          fi;
          EOF

          chmod +x ./test.sh
          echo START
          source ./test.sh || true
          echo END

alt text

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frankieroberto picture frankieroberto  ·  4Comments

ydnar picture ydnar  ·  3Comments

orj picture orj  ·  4Comments

MSP-Greg picture MSP-Greg  ·  3Comments

ethomson picture ethomson  ·  4Comments