tridactyl/tridactyl

Incompatible usage of sed for tutorial generation build step on Darwin

chrishollandaise opened this issue · 2 comments

Problem:

Hi y'all! I started using Tridactly about a month ago, and love it! I wanted to start tinkering and contributing, but ran across this build issue during my onboarding process. I am building on MacOS.

It appears that the scripts/make_tutorial.sh script tries to make an in-place edit on line 19, however the the way the command is formed (sed -i "s|\.md|.html|g" "$dest$fileroot.html") only supports GNU implementation of sed. The problem is that MacOS by default uses a BSD implementation which requires an extension argument.

Solution:

This is a well-known problem, and I noticed that other install.sh script circumvents this by specifying the file extension when creating a backup file.

The easiest fix is to append .bak to -i flag, which I did and build ran successfully. This is better (i.e. fewer barriers to entry for onboarding darwin folks) than having MacOS contributors install a GNU compatible version of sed (i.e. gsed) and shadowing the default sed. I can go ahead and make a PR request for this unless I am missing something here.

Steps to reproduce (on MacOS):

  1. Run through onboarding process outlined here
  2. Run yarn run build
  3. Tridactyl doesn't build and successfully and outputs following sed errors:
yarn run v1.22.21
$ sh scripts/build.sh
sed: 1: "../../../generated/stat ...": invalid command code .
sed: 1: "../../../generated/stat ...": invalid command code .
sed: 1: "../../../generated/stat ...": invalid command code .
sed: 1: "../../../generated/stat ...": invalid command code .
sed: 1: "../../../generated/stat ...": invalid command code .
sed: 1: "../../../generated/stat ...": invalid command code .
sed: 1: "../../../generated/stat ...": invalid command code .
sed: 1: "../../../generated/stat ...": invalid command code .
sed: 1: "../../../generated/stat ...": invalid command code .
sed: 1: "../../../generated/stat ...": invalid command code .
sed: 1: "../../../generated/stat ...": invalid command code .
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

System info:

  • Tridactyl version: 1.24.0
  • Operating system: Darwin 22.6.0 arm64

Hi, thanks for filing this issue.

Yeah, we have run into this before multiple times. If you fix it, could you also add a line to the script that runs shellcheck (CI/lint.sh I think) that checks to see if it has reappeared anywhere?

@bovine3dom Absolutely, I have a PR up. Should I have fixed all the other scripts. I got a decent working solution, but there are somethings you should look at on the PR. Let me know what you think.