Cli tool will only run a job if the branch you're on matches one of the workflow conditions in which said job is used

This seems so intuitive to me that I basically feel that the cli tool is useless for local testing of jobs?

What’s the justiftication of this requirement?

To get any thing done in this regard i have to create a temporary workflow that doesn’t have any conditions.

If my pipeline looks like :

version: 2.1

jobs:
    foo:
        executor:
            name: linux
        steps:
            - run:
                name: "Foo Runs Something"
                command: echo "Something"

workflows:
  version: 2

  do_stuff:
    when:
        - equals: [
            <<pipeline.git.branch>>,
            develop
        ]

    jobs:
        - foo
        

And I’m on feature/AB-12345-test-stuff then when I run:

circleci local execute --job foo

I get the error :

❯ circleci local execute --job foo
Docker image digest: sha256:35d5389d587ca45d1fd79940e34fa916c8ca2ef7b9515f1c0920d722dff8d02a
====>> Spin up environment
Build-agent version  ()
Error: 
Configuration errors: 1 error occurred:
        * Cannot find a job named `foo` to run in the `jobs:` section of your configuration file.
If you expected a workflow to run, check your config contains a top-level key called 'workflows:'



Step failed
Task failed
Error: 1 error occurred:
        * Cannot find a job named `foo` to run in the `jobs:` section of your configuration file.
If you expected a workflow to run, check your config contains a top-level key called 'workflows:'

so i need to modify my pipeline to look like:

version: 2.1

jobs:
    foo:
        executor:
            name: linux
        steps:
            - run:
                name: "Foo Runs Something"
                command: echo "Something"

workflows:
  version: 2
  some_other_temp_name:
    jobs:
        - foo
        
  do_stuff:
    when:
        - equals: [
            <<pipeline.git.branch>>,
            develop
        ]

    jobs:
        - foo

and then it will run it.

:face_vomiting: