maxim-lobanov / setup-cocoapods

Set up your GitHub Actions workflow with a specific version of Cocoapods
MIT License
31 stars 6 forks source link

Intermitten ERROR: While executing gem ... (NoMethodError) undefined method `name' for nil:NilClass #20

Closed penchef closed 10 months ago

penchef commented 3 years ago

Hey @maxim-lobanov ! Thanks for your action, real nice!

We've seen some intermittent failures, which I can't figure out why they happen. Do you have any clue what's going on there?

Intermittent Failure:

Run maxim-lobanov/setup-cocoapods@v1
Podfile points to the Cocoapods 1.10.2
/usr/local/lib/ruby/gems/2.7.0/bin/pod --version
1.11.2
/usr/local/opt/ruby@2.7/bin/gem uninstall cocoapods --all --executables
/usr/local/opt/ruby@2.7/bin/gem install cocoapods -v 1.10.2 --no-document
Removing pod
Removing sandbox-pod
Successfully uninstalled cocoapods-1.11.2
ERROR:  While executing gem ... (NoMethodError)
    undefined method `name' for nil:NilClass
Error: The process '/usr/local/opt/ruby@2.7/bin/gem' failed with exit code 1

This is our yml:

name: CD

jobs:
  build_release_ios:
    name: Release
    runs-on: macos-10.15
       steps:
....
      - name: Setup Cocoapods
        uses: maxim-lobanov/setup-cocoapods@v1
        with:
          podfile-path: ios/Podfile.lock

Podfile.lock: COCOAPODS: 1.10.2

A parallel job (executing the same code, just for another whitelabel flavor) is sucessfull

Run maxim-lobanov/setup-cocoapods@v1
Podfile points to the Cocoapods 1.10.2
/usr/local/lib/ruby/gems/2.7.0/bin/pod --version
1.11.2
/usr/local/opt/ruby@2.7/bin/gem uninstall cocoapods --all --executables
/usr/local/opt/ruby@2.7/bin/gem install cocoapods -v 1.10.2 --no-document
Removing pod
Removing sandbox-pod
Successfully uninstalled cocoapods-1.11.2
Successfully installed ruby-macho-1.4.0
Successfully installed molinillo-0.6.6
Successfully installed thread_safe-0.3.6
Successfully installed tzinfo-1.2.9
Successfully installed activesupport-5.2.6
Successfully installed cocoapods-core-1.10.2
Successfully installed cocoapods-1.10.2
7 gems installed
Cocoapods 1.10.2 has been installed successfully
dmeyer-pfg commented 1 year ago

I am seeing this issue intermittently as well. The issue appears to be due a race condition where the async command to remove the existing version of cocoapods has not completed prior to attempting to install the version specified by the user. For reference, here is the code I am referring to. This is the change that should be made. I'll open a PR.

+ await exec.exec("gem", ["uninstall", "cocoapods", "--all", "--executables", "--ignore-dependencies"]);
- exec.exec("gem", ["uninstall", "cocoapods", "--all", "--executables", "--ignore-dependencies"]);
xxfast commented 1 year ago

Running into this more frequently here

maxim-lobanov commented 10 months ago

Thank you for contribution and fixing this issue! I have released v1.4.0 version with fix and updated v1 tag