# ERROR: Invalid requirement: '<package> ; extra == "test"' - Expected end of string after extra specifier

- **ID:** `pip/invalid-requirement-parse-error-from-env-markers`
- **Domain:** pip
- **Category:** config_error
- **Error Code:** `ERROR`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

The requirement string contains environment markers (e.g., extra, python_version) with incorrect syntax, such as missing parentheses, extra spaces, or unsupported operators.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| pip 21.0+ | active | — | — |
| Python 3.8-3.12 | active | — | — |
| setuptools 58+ | active | — | — |

## Workarounds

1. **Correct the marker syntax: use 'package ; extra == "test"' (note the spacing) or 'package; extra == "test"' (no space before semicolon). For multiple conditions: 'package; extra == "test" and python_version >= "3.8"'** (95% success)
   ```
   Correct the marker syntax: use 'package ; extra == "test"' (note the spacing) or 'package; extra == "test"' (no space before semicolon). For multiple conditions: 'package; extra == "test" and python_version >= "3.8"'
   ```
2. **pip install --dry-run -r requirements.txt 2>&1 | grep -E 'Invalid requirement'** (85% success)
   ```
   pip install --dry-run -r requirements.txt 2>&1 | grep -E 'Invalid requirement'
   ```
3. **Replace the invalid requirement with a simpler version: 'package[test]' if the extra is defined in the package itself, or split into separate requirement lines with conditional installation using pip's --extra-index-url.** (80% success)
   ```
   Replace the invalid requirement with a simpler version: 'package[test]' if the extra is defined in the package itself, or split into separate requirement lines with conditional installation using pip's --extra-index-url.
   ```

## Dead Ends

- **Removing all environment markers from the requirement** — This changes the package's dependency behavior, potentially breaking conditional dependencies. (70% fail)
- **Using double quotes instead of single quotes in the requirements file** — The error is about marker syntax, not quote style; pip parses both quote types the same way. (95% fail)
- **Escaping the semicolon with a backslash** — Backslash escaping is not supported in pip requirement strings; it will cause a different parse error. (90% fail)
