# Travis\_terminate command not found

**URL:** https://travis-ci.community/t/travis-terminate-command-not-found/4383
**Category:** Travis CI Discussions & Feedback
**Tags:** script-deployment, deployment, python
**Created:** [July 25, 2019, 9:20am UTC](https://travis-ci.community/t/travis-terminate-command-not-found/4383 "2019-07-25T09:20:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![justin](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/justin/32/2340_2.png) [@justin](https://travis-ci.community/u/justin)
#### Post date: [July 25, 2019, 9:20am UTC](https://travis-ci.community/t/travis-terminate-command-not-found/4383/1 "2019-07-25T09:20:30Z")

</div>

I am running a Python script during the `before_deploy` stage to determine the presence of a file. If that file is not found, I am trying to use the [poorly-documented](https://github.com/travis-ci/docs-travis-ci-com/issues/1899) `travis_terminate` command to halt the process:

```python
run_process(["travis_terminate", "0"])

```

This seems to be a common approach, as mentioned in [#1574](https://github.com/travis-ci/travis-ci/issues/1574) and other issues. However, this invocation results in a `FileNotFoundError`:

```auto
FileNotFoundError: [Errno 2] No such file or directory: 'travis_terminate': 'travis_terminate'

```

At first, I thought the cause was that I had not opted-into the (deprecated) [v0 conditions](https://docs.travis-ci.com/user/conditions-v0), but even after adding `conditions: v0` to the top of `.travis.yml`, the result is the same error.

The equivalent command for CircleCI, by the way, functions flawlessly:

```python
run_process(["circleci", "step", "halt"])

```

Why does calling `travis_terminate` result in a “file not found” error? Is it not available during the `before_deploy` stage? Or has the `travis_terminate` command been removed without warning? If so, what invocation can instead be used to immediately halt the process, with the ability to specify 0 or 1 exit codes?

---

<div class="post-metadata">

### Author: ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)
#### Post date: [July 25, 2019, 9:57am UTC](https://travis-ci.community/t/travis-terminate-command-not-found/4383/2 "2019-07-25T09:57:50Z")

</div>

`travis_terminate` is a shell function, defined in [https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis\_terminate.bash](https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_terminate.bash) which is imported (in unspecified manner) into the shell that runs user commands and is designed to run in the same shell as them. As such, you cannot run it from a Python subprocess.

I suggest your Python program returns an exit code depending on which you’ll call `travis_terminate`:

```auto
before_deploy:
    - ./is_deploy_needed.py || travis_terminate 0

```

---

<div class="post-metadata">

### Author: ![justin](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/justin/32/2340_2.png) [@justin](https://travis-ci.community/u/justin)
#### Post date: [August 6, 2019, 2:57pm UTC](https://travis-ci.community/t/travis-terminate-command-not-found/4383/3 "2019-08-06T14:57:52Z")

</div>

@native-api: Your guidance provided the clarity that was so sorely lacking. Many thanks for taking the time to respond and point me in the right direction. Much appreciated! 👏

As a side note, I needed `travis_terminate` in order to support Travis CI in [AutoPub](https://github.com/autopub/autopub), a tool that enables project maintainers to automate new package version releases upon pull request merge. Just thought I’d mention it in case [AutoPub](https://github.com/autopub/autopub) could be of use to somebody else. ✨
