CircleCI-Public / flutter-orb

Easily install Flutter SDK and package dependencies. Also wasily run unit test and lint. Supports Linux and macOS
https://circleci.com/developer/orbs/orb/tadashi0713/flutter-orb
MIT License
2 stars 15 forks source link

Install SDK broken on XCode 14.2.0 executor #27

Closed ajamespro closed 1 year ago

ajamespro commented 1 year ago

Orb version:

2.0.0

TLDR;

This should be the only thing that needs to change here:

- echo "export PATH=$INSTALL_LOCATION/flutter/bin:$PATH" >> "$BASH_ENV"
+ echo "export PATH=$INSTALL_LOCATION/flutter/bin:\$PATH" >> "$BASH_ENV"

What happened:

I think I discovered a bug, but also have a possible quick solution. Although the flutter/install_sdk command appears to succeed, there is some flakiness in the install and some errors in doctor. This manifests itself with an error any time ruby is invoked. Some examples:

Running flutter doctor: image

Running rbenv version image

From there, cocoapods and anything gem related breaks down in all kinds of ways, but I think it will be more helpful to show the cause and solution than to exhaust all the side effect errors that occur.

Additional Information:

The easiest way to replicate this is with the following config file.

config.yml ```yml version: 2.1 jobs: basic-install: macos: xcode: 14.2.0 steps: - run: rbenv version - flutter/install_sdk - run: rbenv version minimal-broken: macos: xcode: 14.2.0 steps: - run: name: '$PATH variable not escaped' command: | rbenv version echo "export PATH=/Users/distiller/development/flutter/bin:$PATH" >> "$BASH_ENV" rbenv version minimal-working: macos: xcode: 14.2.0 steps: - run: name: 'Escaped \$PATH variable' command: | rbenv version echo "export PATH=/Users/distiller/development/flutter/bin:\$PATH" >> "$BASH_ENV" rbenv version orbs: flutter: circleci/flutter@2.0.0 workflows: bug-report: jobs: - basic-install - minimal-broken - minimal-working ```

image

In here, the job basic-install is an integrated example which uses the orb and shows how the install breaks the bash command: rbenv version. The two jobs minimal-working and minimal-broken show where the root cause of this might be occurring. I suspect that ruby is doing something with the PATH variable, and the flutter sdk is overwriting this variable, rather than constructing it in $BASH_ENV.

Basic Install

Using the following steps, the first rbenv version succeeds but the second call fails just after installing:

steps:
  - run: rbenv version
  - flutter/install_sdk
  - run: rbenv version

image

Broken

minimal-broken, performing the PATH overwrite with current code.

command: |
  rbenv version
  echo "export PATH=/Users/distiller/development/flutter/bin:$PATH" >> "$BASH_ENV"
  rbenv version

image

Working

vs minimal-working, which adds an escaped character next to the $ sign in $PATH

command: |
  rbenv version
  echo "export PATH=/Users/distiller/development/flutter/bin:\$PATH" >> "$BASH_ENV"
  rbenv version

image

Expected behavior:

rbenv version should not exit with an error after installing flutter sdk on xcode 14.2 executor.

ryanbourdais commented 1 year ago

Hi @ajamespro thank you so much for all the investigation you did into this issue, it was a massive help. I have just drafted up a PR to fix this and this should be fixed in the next release.