Testing on the Bash track

When trying to run the bats program I get a
-bash: bats: command not found error.

Any ideas what I need to do to resolve. I installed bats as per the instructions. See attached image for results of that.

Is /home/Colin/bin in your $PATH?
Is /home/Colin/bin/bats executable?

No.
Yes.
After adding the directory to my PATH and running: bats raindrops.bats
/home/Colin/bin/bats: line 2: $‘\r’: command not found
: invalid option name line 3: set: pipefail

  1. How did you install bats?
  2. How are you running bats?

\r is a carriage return which should not exist in that file and is often the result of a copy/paste or running a file intended for Windows.

On a Mac, I’d recommend installing both bash and bats with Homebrew.

To fix bats: sed -i '' 's/\r$//' ~/bin/bats

In the testing on the Bash track section I followed the instructions:

For Windows (MINGW64/Cygwin)
$ git clone https://github.com/bats-core/bats-core.git
$ cd bats-core
$ ./install.sh $HOME```

Does no further comments or questions from Isaac or Glenn mean no further suggestions as to how to resolve the problem I have with running the bash testing locally (other than to update my system) ?

Or can I supply any other information that may help?

If yes to first and no to second let me know and I will persist with making submissions with the Editor instead even if it is not my preferred option.

In my case I have an old Lenovo Thinkpad Edge with Windows 7 and Cygwin installed. bats is not a package available in Cygwin so I just followed the Exercism instructions with the git clone…

Had this problem too, but fixed it. On Mac:

→ edits. - don’t super know what I am doing

  1. DO use homebrew to install bash and bats, as it installs bats-core (you want) not straight up bats (you don’t want)
  2. DO put the ‘wrapper function’ from the bash track test running notes into ~/.bash_profile if you have no ~/.bashrc. ->not sure this matters, didn’t affect anything
  3. Go ‘live’ with source ~/.bash_profile, → not sure to do this, further test showed works without
  4. download exercism exercises AFTER the above, else you will not have a working my_test.bats file you need for running the tests. → tested again and also not the key point
  5. DON’T source ~/.bash_profile from a vscode window but from a normal terminal window. → half right, actually just download the track exercise from a terminal window not vscode terminal window
  6. Don’t worry when you get a exercism:2: command not found: readarray error, that seems not to matter. → probably not correct if the ‘wrapper function’ function is important on mac, tried seems not

Likely to edit this again.

2 Likes

Thanks for sharing!

Should we be adding this to the track docs somewhere? (Probably a question more to maintainers)