Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the effect of using set -e in .travis.yml or in scripts #1672

Closed
cotsog opened this issue Jan 19, 2018 · 6 comments
Closed

Document the effect of using set -e in .travis.yml or in scripts #1672

cotsog opened this issue Jan 19, 2018 · 6 comments

Comments

@cotsog
Copy link
Contributor

cotsog commented Jan 19, 2018

Using set -e in .travis.yml or in scripts can cause weird behaviour on Travis CI. It would be nice to give visibility on this in our docs.

Thanks to @maelvalais for the suggestion!

@BanzaiMan
Copy link
Contributor

This is discussed in https://docs.travis-ci.com/user/customizing-the-build/#Implementing-Complex-Build-Steps

Note the set -ev at the top. The -e flag causes the script to exit as soon as one command returns a non-zero exit code. This can be handy if you want whatever script you have to exit early. It also helps in complex installation scripts where one failed command wouldn’t otherwise cause the installation to fail.

If you have ideas on where to put this for more prominence, I'm happy to discuss that with you.

@fcastilloec
Copy link

What about using set -e on .travis.yml itself, not on scripts used by Travis?
It seems that there's no problem when doing this on Linux, but OSX shows errors that shouldn't, specifically with rvm.
You can see this comment that mentions the exact problem I'm running into.

@maelvls
Copy link

maelvls commented Feb 5, 2018

set -e does not seem to cause problems in scripts called from .travis.yml. However, inside .travis.yml itself, it may break things (unless we set set +e shortly after) as some internal travis (rvm-related) commands often fail causing the build to unexpectedly stop with no clear error (on osx mainly).

It would be good to mention that using set -e inside .travis.yml itself may break things 👍 Or to remind people to do set +e as soon as possible after set -e

@fcastilloec
Copy link

@maelvalais actually, using set +e immediately after a command is run under set -e on OSX also causes problems with rvm, I'm not sure why. This is not the case with Linux, where set -e and set +e work without problems inside .travis.yml itself.

@BanzaiMan
Copy link
Contributor

BanzaiMan commented Feb 5, 2018

RVM is not the only thing that can break when set errexit is set in .travis.yml. I'd advise against using it.

@maelvls
Copy link

maelvls commented Feb 5, 2018

then maybe we could add something like
_
⚠️ Don't use set -e in .travis.yml, otherwise the build may stop unexpectedly because of benign non-zero status in internal travis scripts (see issue #1672).
_
in the docs? 😁

olehermanse added a commit to olehermanse/core that referenced this issue Feb 6, 2018
Doing this can cause some internal travis commands to fail
the entire build. It is not recommended, see:
travis-ci/docs-travis-ci-com#1672

Also includes some mac-specific fixes.

Signed-off-by: Ole Herman Schumacher Elgesem <[email protected]>
daviddavis pushed a commit to pulp/pulp that referenced this issue Mar 5, 2018
alanjds added a commit to alanjds/grumpy that referenced this issue Mar 21, 2018
alanjds added a commit to alanjds/grumpy that referenced this issue Mar 21, 2018
rvm (#6307) strikes back && On OSX do sudo, on Linux dont.

Found the culprit: rvm provides `cd` binary!

See:
touist/touist@5d7a327#diff-354f30a63fb0907d4ad57269548329e3R52
See:
https://github.com/rvm/rvm/blob/ff63fa117bd05e581ecbf2b0378d9ddbb263deb1/scripts/cd#L14
See:
travis-ci/travis-ci#8703 (comment)
and
travis-ci/travis-ci#8703 (comment)

Install pip locally

Fix: Travis on OSX swallows error logs

See: travis-ci/travis-ci#6018

"never use set -e directly in .travis.yml"

See: travis-ci/docs-travis-ci-com#1672 (comment)
See: travis-ci/travis-ci#6307 (comment)

On OSX, do sudo. On Linux, dont.
JM1 added a commit to JM1/hbrs-cmake that referenced this issue Nov 6, 2018
Otherwise the build may stop unexpectedly because of being non-zero status in internal travis scripts.
See travis-ci/docs-travis-ci-com#1672
JM1 added a commit to JM1/hbrs-cmake that referenced this issue Nov 6, 2018
Otherwise the build may stop unexpectedly because of being non-zero status in internal travis scripts.
See travis-ci/docs-travis-ci-com#1672
JM1 added a commit to JM1/hbrs-mpl that referenced this issue Nov 6, 2018
Otherwise the build may stop unexpectedly because of being non-zero status in internal travis scripts.
See travis-ci/docs-travis-ci-com#1672
JM1 added a commit to JM1/hbrs-mpl that referenced this issue Nov 6, 2018
Otherwise the build may stop unexpectedly because of being non-zero status in internal travis scripts.
See travis-ci/docs-travis-ci-com#1672
ptbrowne added a commit to cozy/cozy-client that referenced this issue Feb 18, 2020
By moving the set -e inside its own file, it should prevent Travis bugs
where set -e prevents travis own error handling to pick up the logs

See travis-ci/docs-travis-ci-com#1672 for more
information
viewizard added a commit to Samsung/netcoredbg that referenced this issue Nov 25, 2020
Note, we can't use `set -e` here, since build may stop unexpectedly because of benign non-zero status in internal travis scripts (see travis-ci/docs-travis-ci-com#1672).
vt-alt added a commit to vt-alt/gost-engine that referenced this issue Jan 7, 2021
vt-alt added a commit to vt-alt/gost-engine that referenced this issue Jan 7, 2021
It can cause weird behaviour:
  travis-ci/docs-travis-ci-com#1672

Co-authored-by: Vitaly Chikunov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants