application-accelerator-samples icon indicating copy to clipboard operation
application-accelerator-samples copied to clipboard

Tiltfile OUTPUT_TO_NULL_COMMAND not recognized on Windows

Open andrew-woosnam opened this issue 3 years ago • 3 comments

Describe the bug After cloning the steeltoe-weatherforecast accelerator to a Windows OS, running tilt up fails by default, raising a "path not found" error:

Successfully loaded Tiltfile (3.024ms)
   sample-app â"‚ 
   sample-app â"‚ Initial Build
   sample-app â"‚ STEP 1/1 â€" Deploying
   sample-app â"‚      Running cmd: tanzu apps workload apply -f config/workload.yaml --update-strategy replace --debug --live-update --local-path . --source-image your-registry.io/project/steeltoe-weatherforecast-source --build-env BP_DEBUG_ENABLED=true --namespace default --yes  > /dev/null  && kubectl get workload sample-app --namespace default -o yaml
   sample-app â"‚      The system cannot find the path specified.
   sample-app â"‚ 
   sample-app â"‚ ERROR: Build Failed: apply command exited with status 1

To Reproduce Steps to reproduce the behavior:

  1. Open the steeltoe-weatherforecast accelerator in Windows
  2. Invoke tilt up from the root project directory

Expected behavior tilt up command to succeed.

Additional context

  • This error goes away after removing the OUTPUT_TO_NULL_COMMAND from the default Tiltfile's apply_cmd string.
  • > NUL might be a suitable Windows equivalent to > /dev/null

andrew-woosnam avatar Dec 12 '22 19:12 andrew-woosnam

Update: we should be able to override this env var before invoking tilt up (making it runnable on Windows), but in general I'm guessing NUL might be a friendlier default than /dev/null, assuming a majority of folks using this accelerator will be using Windows?

andrew-woosnam avatar Dec 13 '22 18:12 andrew-woosnam

another option is to use apply_cmd_bat as well in the tiltfile the relevant part could look like:

  apply_cmd="tanzu apps workload apply -f config/workload.yaml --debug --live-update" +
            " --local-path " + LOCAL_PATH +
            " --source-image " + SOURCE_IMAGE +
            " --namespace " + NAMESPACE +
            " --build-env BP_DEBUG_ENABLED=true" +
            " --yes " +
            " > /dev/null " +
            " && kubectl get workload " + NAME + " --namespace " + NAMESPACE + " -o yaml",
  apply_cmd_bat="tanzu apps workload apply -f config/workload.yaml --debug --live-update" +
            " --local-path " + LOCAL_PATH +
            " --source-image " + SOURCE_IMAGE +
            " --namespace " + NAMESPACE +
            " --build-env BP_DEBUG_ENABLED=true" +
            " --yes " +
            " > NUL " +
            " && kubectl get workload " + NAME + " --namespace " + NAMESPACE + " -o yaml",

based on tilt docs:

apply_cmd_bat ( Union [ str , List [ str ]]) – If non-empty and on Windows, takes precedence over apply_cmd . Ignored on other platforms. If a string, executed as a Windows batch command executed with cmd /S /C ; if a list, will be passed to the operating system as program name and args.

This will allow the accelerator Tilt config to work on any OS. while i hardcoded the values, there could be 2 VARS set at the top something like:

OUTPUT_TO_NULL_COMMAND_WIN = ' > NUL '
OUTPUT_TO_NULL_COMMAND = ' > /dev/null '

vrabbi avatar Dec 14 '22 19:12 vrabbi

@trisberg I think this issue can be closed now that tanzu apps has added -oyaml

TimHess avatar Feb 24 '23 15:02 TimHess