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

Lockfiles: teach our staleness error message about <default> tool lockfiles #12654

Closed
Eric-Arellano opened this issue Aug 25, 2021 · 0 comments · Fixed by #12699
Closed

Lockfiles: teach our staleness error message about <default> tool lockfiles #12654

Eric-Arellano opened this issue Aug 25, 2021 · 0 comments · Fixed by #12699
Assignees

Comments

@Eric-Arellano
Copy link
Contributor

#12618 improves the error message for when a lockfile is stale/invalid a lot, although it does not handle the edge case where you're trying to use Pants's default lockfile and cannot do so for some reason. That will require special handling.

This may make the code less elegant because we'll need to plumb more information - we should prioritize excellent error messages over code readability.

Proposed messages for <default> case

Invalid requirements

You are using the <default> lockfile provided by Pants to install the tool black, but it is not compatible with your requirements.

Please either stop setting [black].version and[black].extra_requirements, or generate a lockfile by setting [black].lockfile to where you'd like to create the lockfile, then run ./pants generate-lockfiles.

It gets tricky for Pylint and MyPy that requirements can also come from first-party plugins!

You are using the <default> lockfile provided by Pants to install the tool pylint, but it is not compatible with your requirements.

Please either stop setting [pylint].version, [pylint].extra_requirements, and [pylint].source_plugins, or generate a lockfile by setting [pylint].lockfile to where you'd like to create the lockfile, then run ./pants generate-lockfiles.

Interpreter constraints

Sometimes tools set interpreter constraints via an option:

You are using the <default> lockfile provided by Pants to install the tool black, but it is not compatible with your interpreter constraints: ['==2.7']. (The default works with: ['>=3.6'])

Please either stop setting [black].interpreter_constraints or generate a lockfile by setting [black].lockfile to where you'd like to create the lockfile, then run ./pants generate-lockfiles.

Other times it's calculated from the user's code itself:

You are using the <default> lockfile provided by Pants to install the tool flake8, but it is not compatible with your code's interpreter constraints: ['==2.7']. (The default works with: ['>=3.6'])

Flake8 determines its interpreter constraints based on your code's own constraints. Please either change your code's constraints (see {docs_url('python-interpreter-compatibility')}), or generate a lockfile by setting [flake8].lockfile to where you'd like to create the lockfile, then run ./pants generate-lockfiles.

Proposed message for tools with custom lockfile

Invalid requirements

You are using the the lockfile 3rdparty/python/locks/black.txt to install the tool black, but it is not compatible with your requirements.

Please either change back [black].version and[black].extra_requirements to their previous values or regenerate the lockfile set by [black].lockfile by running ./pants generate-lockfiles.

(This could be made better by preserving what the previous values were and saying that. But we can do that later, if ever.)

It gets tricky for Pylint and MyPy that requirements can also come from first-party plugins!

You are using the the lockfile 3rdparty/python/locks/black.txt to install the tool pylint, but it is not compatible with your requirements.

Please either change back [pylint].version,[pylint].extra_requirements, and [pylint].source_plugins to their previous values, or regenerate the lockfile set by [pylint].lockfile by running ./pants generate-lockfiles.

Interpreter constraints

Sometimes tools set interpreter constraints via an option:

You are using the lockfile 3rdparty/python/locks/black.txt to install the tool black, but it is not compatible with your interpreter constraints: ['==2.7']. (Your lockfile works with: ['>=3.6'])

Please either change [black].interpreter_constraints or regenerate the lockfile set by [black].lockfile by running ./pants generate-lockfiles.

Other times it's calculated from the user's code itself:

You are using the lockfile 3rdparty/python/locks/flake8.txt to install the tool flake8, but it is not compatible with your interpreter constraints: ['==2.7']. (Your lockfile works with: ['>=3.6'])

Flake8 determines its interpreter constraints based on your code's own constraints. Please either change your code's constraints (see {docs_url('python-interpreter-compatibility')}), or regenerate the lockfile set by [flake8].lockfile by running ./pants generate-lockfiles.

Proposed messages for user lockfiles

TBD. Does not need to be implemented in Pants 2.7

@chrisjrn chrisjrn self-assigned this Aug 27, 2021
Eric-Arellano added a commit that referenced this issue Aug 27, 2021
…activate `./pants generate-lockfiles` by default (#12684)

Closes #11898. We now believe tool lockfiles are stable enough to be used without the `--experimental` feature gate and `experimental.python` backend.

Some remaining stabilization work:

- set `[python-setup].invalid_lockfile_behavior` to default to error
- change default for `--lockfile` to `<default>`
- rename `[python-setup].experimental_lockfile_custom_regeneration_command`
- continue improving error message for stale lockfiles #12654


[ci skip-rust]
[ci skip-build-wheels]
Eric-Arellano added a commit that referenced this issue Aug 29, 2021
…lack, Pytest, and Flake8 (#12689)

This is a breaking change: if you have changed the tool's `version` or `extra_requirements`, by default Pants will now error telling you to regenerate a lockfile (#12654). We are consciously breaking the Deprecation Policy because we believe the past of no lockfile (and using `[python-setup].requirement_constraints`) was very broken, and that it's crucial we have a sensible default. We'll try to document this breaking change well. 

[ci skip-rust]
[ci skip-build-wheels]
Eric-Arellano pushed a commit that referenced this issue Aug 31, 2021
…2699)

This changes the lockfile staleness messages to include information on how to reconfigure pants to resolve the error. Language is largely similar to that proposed in #12654, with minor changes:

* Language changes to explain the need for action on the user's part (_you can fix this by_ rather than _please change_ )

Closes #12654
chrisjrn pushed a commit to chrisjrn/pants that referenced this issue Aug 31, 2021
…ntsbuild#12699)

This changes the lockfile staleness messages to include information on how to reconfigure pants to resolve the error. Language is largely similar to that proposed in pantsbuild#12654, with minor changes:

* Language changes to explain the need for action on the user's part (_you can fix this by_ rather than _please change_ )

Closes pantsbuild#12654
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]
stuhood pushed a commit that referenced this issue Sep 2, 2021
…errypick of #12699). (#12717)

This changes the lockfile staleness messages to include information on how to reconfigure pants to resolve the error. Language is largely similar to that proposed in #12654, with minor changes:

* Language changes to explain the need for action on the user's part (_you can fix this by_ rather than _please change_ )

Closes #12654

Cherry-picks `1cfe8dd`.

[ci skip-rust]
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

Successfully merging a pull request may close this issue.

2 participants