Rspec - cannot load such file -- /home/circleci/repo

I am not 100% if it is a bug but; Setup Project shows "${TEST_FILES}" with double quotes:

bundle exec rspec --format progress \
                --format RspecJunitFormatter \
                --out /tmp/test-results/rspec.xml \
                --format progress \
                "${TEST_FILES}"

When I followed the instructions in Setup Project page, I kept getting cannot load such file. Later, I tried it without double quotes and it worked. :man_facepalming:

1 Like

That syntax is valid for interpolating a shell variable inside the quotes. I don’t know Rspec, but I assume from the name of the variable that it can potentially hold files plural, in which case the quotes would be necessary (and I assume it would break without the quotes in that case).

I tested this with a simple shell command:

export HELLO='1 2 3' ; echo "${HELLO}"
1 2 3

What value does $TEST_FILES have in this case? I wonder if it has its own quotes?

Yes it has.

TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
1 Like

Taking a look.

I ran into a similar issue with using variables. While it’s not as pretty, you can get around the issue with the following code:

bundle exec rspec --format progress \
                --format RspecJunitFormatter \
                --out /tmp/test-results/rspec.xml \
                --format progress \
                $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)

As far as Bash variable parsing is concerned, that last line in @ogirginc snippet has been fixed.

Thanks! :+1:

1 Like