Tar cannot open directory when extracting file

My config.yml file is set up to extract a tar.xz file to a directory. Whenever it tries to extract it, it fails with the error tar: -C: Cannot open: No such file or directory. I have tried on a docker image and a machine but both fail with the same error. I also tried running the exact same commands in a docker container on my computer and it works fine. My config.yml file looks like this:

version: 2
       image: ubuntu-1604:201903-01
        - checkout
        - run:
            name: Installed prerequisite packages
            command: |
                sudo apt update -q
                sudo apt install -y -q curl wget xz-utils
        - run:
            name: Extract and copy files
            command: |
                mkdir rootfs
                tar -xvf $TAR -C rootfs

:wave: @ThatWeirdAndrew would you mind moving the -C rootfs part to just after tar, so the new command looks like tar -C rootfs -xvf $TAR? According to tar's manpage, the -C switch is order-sensitive.

Now it says, tar: option requires an argument -- 'f'