appveyor / ci

AppVeyor community support repository
https://www.appveyor.com
344 stars 64 forks source link

Unexpected "echo" behavior under Ubuntu build #2436

Open avishnyakov opened 6 years ago

avishnyakov commented 6 years ago

Hey guys, seeing unexpected behaviour while using "echo" under Ubuntu builds:

Weird one:

build_script:
  - DOCS_PROFILE=$APPVEYOR_REPO_BRANCH 
  - echo "Building docs profile: $DOCS_PROFILE"

Output:

Running "build_script" scripts
DOCS_PROFILE=$APPVEYOR_REPO_BRANCH
$DOCS_PROFILE"
The requested service 'echo "building docs profile (AppVeyor.BuildAgent.Service.IShellExecutor)' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

Good one:

build_script:
  - DOCS_PROFILE=$APPVEYOR_REPO_BRANCH 
  - 'echo "Building docs profile: $DOCS_PROFILE"'

Couldn't spot anything obvious in the doco, decided to put it here.

FeodorFitsner commented 6 years ago

Thanks for reporting that. I can explain what happens.

When you put a command like:

- echo "Building docs profile: $DOCS_PROFILE"

in YAML notation it's "hash", i.e. - key: value where, in your case, key is everything before : - echo "Building docs profile and value is everything after : - $DOCS_PROFILE"

AppVeyor supports multiple command "processors" by introducing command suffixes, such as cmd:, ps:, pwsh:, sh:. The error you see is coming from a "factory" responsible for instantiation of correct command processor by command prefix.

So, the issue is the bug. Correct behavior would be displaying more friendly error: Unknown command prefix.