Sunday, March 13, 2022

[SOLVED] sed -e unknown option to `s'

Issue

I have a GitHub workflow set up, and for some weird reason that I do not know, when I've added a new environment variable (using sed to set it up) this error occurred:

sed: -e expression #1, char 32: unknown option to `s'
Error: Process completed with exit code 1.

This is the last lines of the .yml file:

[...]
        run: |
          npm run build --if-present
          # There are a lot of sed commands here which were running as expected
          sed -i -e 's/"<API token>"/"${{secrets.API_TOKEN}}"/g' .env # This is one of the commands, it is executed normally with no errors
          sed -i -e 's/"<Mongo path>"/"${{secrets.MONGO_PATH}}"/g' .env
          # When the line above was added, the error started occurring

Full output:

npm run build --if-present
  [...]
  sed -i -e 's/"<API token>"/"***"/g' .env
  sed -i -e 's/"<Mongo path>"/"***"/g' .env
  shell: /usr/bin/bash -e {0}

> [email protected] build
> cp -n .env.example .env

sed: -e expression #1, char 32: unknown option to `s'
Error: Process completed with exit code 1.

I have tried replacing the slashes with @ as I saw on other answers but it did not work.

The workflow works perfectly fine without the line I've mentioned.


Solution

Alright, turns out that replacing the slashes with | worked. Apparently, sed was confused as the MongoDB path had a lot of slashes.



Answered By - Vin
Answer Checked By - Dawn Plyler (WPSolving Volunteer)