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


#1

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:


#2

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?


#3

Yes it has.

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

#4

Taking a look.


#5

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)

#6

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


#7

Thanks! :+1:


#8