Skip to content

Commit d782c03

Browse files
docs: mention .pants.bootstrap file (#20538)
The `.pants.bootstrap` file is not mentioned anywhere, but it can be helpful when declaring environment variables that are going to be accessible both in `pants.toml` to interpolate and any subprocess Pants may start (such as when doing `pants run script.py` and there's `os.getenv("ENVVAR")`).
1 parent 476e131 commit d782c03

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

docs/docs/using-pants/key-concepts/options.mdx

+27-1
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,13 @@ domain = "my.domain"
102102

103103
[python-repos]
104104
repo_host = "repo.%(domain)s"
105-
indexes.add = ["http://%(env.PY_REPO)s@%(repo_host)s/index
105+
indexes.add = ["https://%(env.PY_REPO)s@%(repo_host)s/index"]
106106
```
107107

108+
Learn more about exporting environment variables in the
109+
[`.pants.bootstrap`](../using-pants/key-concepts/options.mdx#pantsbootstrap-file)) Bash script that is sourced
110+
before Pants runs.
111+
108112
## Option types
109113

110114
Every option has a type, and any values you set must be of that type.
@@ -369,3 +373,25 @@ interpreter_constraints = ["==3.9.*"]
369373
```
370374

371375
If you want to ban this feature, set `[GLOBAL].pantsrc = false` in `pants.toml`.
376+
377+
## `.pants.bootstrap` file
378+
379+
If you need to set default values for environment variables without requiring all users to define them in the local
380+
environment, you can export them in the `.pants.bootstrap` Bash script. This file needs to be placed in the root of your
381+
workspace, and it is going to be sourced before invoking any Pants goal.
382+
383+
You can also add to this file any Bash code you want to execute before Pants runs, and any environment variables
384+
declared in this file are going to be available to any process that Pants launcher binary may start.
385+
386+
For example:
387+
388+
```bash title=".pants.bootstrap"
389+
# these variables are defined in our CI agents,
390+
# but this is set to support local development
391+
export DOCKER_DEFAULT_REPO="https://hub.docker.com/"
392+
export GIT_COMMIT="$(git rev-parse HEAD)"
393+
```
394+
395+
If you want to learn more about how
396+
[Pants launcher binary](../../getting-started/installing-pants#the-pants-binarys-implementation) works, see
397+
the [scie-pants](https://github.com/pantsbuild/scie-pants) project.

docs/docs/using-pants/troubleshooting-common-issues.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ This can be fixed by setting `ulimit -n 10000`. (10,000 should work in all cases
206206
:::note Tip: permanently configuring `ulimit -n`
207207
We recommend permanently setting this by either:
208208

209-
1. Adding `ulimit -n 10000` to your `pants.bootstrap` script.
209+
1. Adding `ulimit -n 10000` to your [`.pants.bootstrap`](../using-pants/key-concepts/options.mdx#pantsbootstrap-file) script.
210210
2. Adding `ulimit -n 10000` to your global `.bashrc` or equivalent.
211211

212212
The first two approaches have the benefit that they will be checked into version control, so every developer at your organization can use the same setting.

0 commit comments

Comments
 (0)