How do we use a variable from one step into the next step?

We’d like to pass an argument (e.g. foo_version) to a step from an orb (e.g. foo/install). The value of the argument is taken from the previous step.

We tried something like this but it doesn’t work.

    steps:
      - run: echo "export FOO_VERSION='1.9.5'" >> $BASH_ENV
      - foo/install:
          foo_version: $FOO_VERSION

While in theory, CircleCI sources $BASH_ENV before each step, as described here, I’ve seen some cases where it has to be sourced explicitly, for example when the shell the container uses is not bash (which is kind of mentioned on that page).

So if it’s an option, maybe try seeing if explicitly setting the shell to bash (if it’s not already), as in the example in the docs, helps.