CocoaPods / CocoaPods

The Cocoa Dependency Manager.
https://cocoapods.org/
Other
14.59k stars 2.64k forks source link

CocoaPods 1.16 breaks Pods that depends on `.git` folder #12674

Open andreabusi opened 1 month ago

andreabusi commented 1 month ago

Report

What did you do?

We have a custom pod that use the prepare_command option to execute a script. That script performs some operations in order to install some dependencies and update a git submodule contained in the repo.

This pod works properly until CocoaPods v1.15.2, but it's broken with v1.16 (and 1.16.1).

To replicate the issue, we recreate a sample that mimic our configuration:

In the sample project, we created this Podfile:

platform :ios, '13.0'
use_frameworks!

target 'GitPodSample' do
  pod 'GitPods', :git => 'https://github.com/comelit/cocoapods-gitissue.git', :branch => 'main'
end

Executing pod install using CocoaPods v1.16 doesn't work.

We already investigate and the issue seems related to this change, that didn't copy the .git folder in the cache directory: https://github.com/CocoaPods/CocoaPods/pull/12349/commits/bc5fdc61839bee9d58c5b04504e6e0cbabbe15c9

What did you expect to happen?

We expect that the pod is properly installed (as in CocoaPods v1.15.x)

What happened instead?

pod install fails with an error:

> pod install
Analyzing dependencies
Pre-downloading: `GitPods` from `https://github.com/comelit/cocoapods-gitissue.git`, commit `aad676950b3d5dc0116442e4b1276f0a6bedec66`
[!] Failed to download 'GitPods': [!] /bin/bash -c
set -e
./installer.sh pod-init

  ____ _ _   ____           _
 / ___(_) |_|  _ \ ___   __| |___
| |  _| | __| |_) / _ \ / _` / __|
| |_| | | |_|  __/ (_) | (_| \__ \
 \____|_|\__|_|   \___/ \__,_|___/

/Users/andrea/Library/Caches/CocoaPods/Pods/External/GitPods/862e56d2989b3938f0a33816d00dfecd/

fatal: not a git repository (or any of the parent directories): .git

CocoaPods Environment

Stack

   CocoaPods : 1.16.1
        Ruby : ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin23]
    RubyGems : 3.4.10
        Host : macOS 14.7 (23H124)
       Xcode : 16.1 (16B40)
         Git : git version 2.39.5 (Apple Git-154)
Ruby lib dir : /Users/andrea/.rbenv/versions/3.2.2/lib
Repositories : bitbucket-comelit-comelit-pods - git - https://bitbucket.org/comelit/comelit-pods.git @ 8ef03af318478502a4c7d678eb8f25cb3a3cca6b

               bubidevs-bubidevs-pods - git - git@github.com:BubiDevs/bubidevs-pods.git @ 072d3e8c26431b60baf996d5a399178d6a70e8ff

               cocoapods - git - https://github.com/CocoaPods/Specs.git @ fcf23bd107256407e97c2abfc2401949dab1d5fa

               comelit-pods - git - https://andreabusi@bitbucket.org/comelit/comelit-pods.git @ 8ef03af318478502a4c7d678eb8f25cb3a3cca6b

               trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /Users/andrea/.rbenv/versions/3.2.2/bin/pod

Plugins

cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.1
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0

Podfile

platform :ios, '13.0'
use_frameworks!

target 'GitPodSample' do
  pod 'GitPods', :git => 'https://github.com/comelit/cocoapods-gitissue.git', :branch => 'main'
end

Project that demonstrates the issue

svenmuennich commented 1 month ago

We have the same setup (prepare_command that interacts with a git submodule) and have the same issue since v1.16.0.

filipealva commented 4 weeks ago

could be that this pod just doesn't work with xcodeproj 1.26.0?

I had similar issues and ensuring to work with a cocoapods version that works with a xcodeproj up to 1.25.0 fixed it

might be a different issue, though

andreabusi commented 4 weeks ago

could be that this pod just doesn't work with xcodeproj 1.26.0?

I had similar issues and ensuring to work with a cocoapods version that works with a xcodeproj up to 1.25.0 fixed it

might be a different issue, though

I've just tried to fix the xcodeproj version, but the issue still occours.

I think that the issue has been introduced by the usage of rsync instead of FileUtils package. Inspecting this commit, the .git folder is excluded from the rsync, that cause the issue.

jkuchar commented 4 weeks ago

The folder is removed after git download. I have checked, while it was processing the first step and it was there. After moving the result into cache, .git folder was not present anymore.

andreabusi commented 3 weeks ago

I created a test version of the CocoaPods gem removing the --exclude=.git option and it seems to work properly. Here is my branch: https://github.com/andreabusi/CocoaPods/tree/fix/fix_rsync_git_folder

I don't know if it's the right approach. @amorde could you please help us to identify if the option --exclude=.git in your commit is done by a purpouse or we can remove it?

amorde commented 2 weeks ago

that was added by @justinseanmartin to fix a performance issue, and I believe removing it would effectively break that optimization. I'm not familiar enough with the issue to know for sure though.

andreabusi commented 2 weeks ago

that was added by @justinseanmartin to fix a performance issue, and I believe removing it would effectively break that optimization. I'm not familiar enough with the issue to know for sure though.

Thanks for the reply. I understand that the fix has been added for a reason, but the side effects are quite huge, because a lot of pods depends from the .git folder. How can we manage it?

andreabusi commented 1 week ago

Any update on this? The issue is becoming very critical for us

/cc @justinseanmartin @amorde