Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[!] Failed to download 'profile': can't modify frozen String #10920

Closed
1 task done
Buju77 opened this issue Sep 6, 2021 · 13 comments · Fixed by CocoaPods/cocoapods-downloader#119
Closed
1 task done

Comments

@Buju77
Copy link

Buju77 commented Sep 6, 2021

Report

What did you do?

Integrated one of our own hosted pod using the branch name:

pod 'profile', git: 'ssh://git@blub.com:7999/profile.git', branch: 'epic/activities'

and run the command normally:

pod update --clean-install --verbose

What did you expect to happen?

Install all pod dependencies correctly.

What happened instead?

Pod update failed during 'Fetching external sources' phase with can't modify frozen String. ❌

But pod update does work if I use the commit: '...' option instead of branch: '...'. ✅

Using the branch option also works fine using Cocoapods 1.9.1. This error only happened after upgrading to CP 1.10.2 now (we only upgraded recently).

CocoaPods Environment

Cocoapods 1.10.2
Xcode 12.5.1
macOS 11.5
Ruby 2.6.3p62 (2019-04-16 revision 67580)

Error

Fetching external sources
-> Pre-downloading: 'profile' from `ssh://git@blub.com:7999/profile.git`, branch `epic/activities`
  $ /usr/bin/git ls-remote ssh://git@blub.com:7999/profile.git epic/activities
  48f4b0a9e4241b2a93087dabca405f19ca239ea3	refs/heads/epic/activities
[!] Failed to download 'profile': can't modify frozen String

/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb:120:in `rescue in block in pre_download'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb:115:in `block in pre_download'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/user_interface.rb:86:in `titled_section'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb:113:in `pre_download'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/downloader_source.rb:13:in `fetch'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:989:in `fetch_external_source'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:968:in `block (2 levels) in fetch_external_sources'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:967:in `each'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:967:in `block in fetch_external_sources'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/user_interface.rb:64:in `section'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:966:in `fetch_external_sources'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:117:in `analyze'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer.rb:414:in `analyze'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/user_interface.rb:64:in `section'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer.rb:160:in `install!'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/command/update.rb:63:in `run'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/command.rb:52:in `run'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/bin/pod:55:in `<top (required)>'
/Users/cloud/.rvm/gems/ruby-2.6.3/bin/pod:23:in `load'
/Users/cloud/.rvm/gems/ruby-2.6.3/bin/pod:23:in `<main>'
/Users/cloud/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `eval'
/Users/cloud/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `<main>'
@dnkoutso
Copy link
Contributor

dnkoutso commented Sep 6, 2021

hmm interesting, I will try with the link you provided.

@dnkoutso dnkoutso added this to the 1.11.1 milestone Sep 6, 2021
@dnkoutso
Copy link
Contributor

dnkoutso commented Sep 6, 2021

do you happen to have an open source pod or something that i can download? The one you specified I do not have access so I cant verify.

@dnkoutso
Copy link
Contributor

dnkoutso commented Sep 6, 2021

it seems we are catching an exception and re-throwing but we are missing the underlying message:

begin
  download_result = Downloader.download(download_request, target, :can_cache => can_cache)
rescue Pod::DSLError => e
  raise Informative, "Failed to load '#{name}' podspec: #{e.message}"
rescue => e
  raise Informative, "Failed to download '#{name}': #{e.message}"
end

Can you also run with pod install --verbose and see if there is a separate stacktrace printed?

@dnkoutso dnkoutso added the s1:awaiting input Waiting for input from the original author label Sep 6, 2021
@dnkoutso
Copy link
Contributor

dnkoutso commented Sep 6, 2021

Alternatively please modify your /Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb file inside the pre_download method and add a puts e right below the rescue => e line on 119 and before the raise line on 120. This might give us more insight about what the underlying error is.

@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Sep 6, 2021
@dnkoutso dnkoutso added the s1:awaiting input Waiting for input from the original author label Sep 6, 2021
@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Sep 6, 2021
@dnkoutso dnkoutso added the s1:awaiting input Waiting for input from the original author label Sep 6, 2021
@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Sep 6, 2021
@dnkoutso dnkoutso added the s1:awaiting input Waiting for input from the original author label Sep 6, 2021
@Buju77
Copy link
Author

Buju77 commented Sep 6, 2021

do you happen to have an open source pod or something that i can download? The one you specified I do not have access so I cant verify.

sry, I can't provide that. this is a private repo from the company. the blub.com is just a redacted url 😅

Alternatively please modify your /Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb file inside the pre_download method and add a puts e right below the rescue => e line on 119 and before the raise line on 120. This might give us more insight about what the underlying error is.

ok cool thx. I'll try that in the morning when I'm in the office again. The weird thing is, the error is only happening in this one repo. If we do the same thing in other repo, it works fine. So definitely interesting to see what the underlying error is.

@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Sep 6, 2021
@dnkoutso dnkoutso added the s1:awaiting input Waiting for input from the original author label Sep 6, 2021
@Buju77
Copy link
Author

Buju77 commented Sep 7, 2021

ok so pod install --verbose also gives the same stacktrace:

/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb:120:in `rescue in block in pre_download'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb:115:in `block in pre_download'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/user_interface.rb:86:in `titled_section'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb:113:in `pre_download'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/downloader_source.rb:13:in `fetch'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:989:in `fetch_external_source'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:968:in `block (2 levels) in fetch_external_sources'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:967:in `each'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:967:in `block in fetch_external_sources'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/user_interface.rb:64:in `section'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:966:in `fetch_external_sources'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer/analyzer.rb:117:in `analyze'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer.rb:414:in `analyze'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/user_interface.rb:64:in `section'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/installer.rb:160:in `install!'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/command/install.rb:52:in `run'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/command.rb:52:in `run'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/bin/pod:55:in `<top (required)>'
/Users/cloud/.rvm/gems/ruby-2.6.3/bin/pod:23:in `load'
/Users/cloud/.rvm/gems/ruby-2.6.3/bin/pod:23:in `<main>'
/Users/cloud/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `eval'
/Users/cloud/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `<main>'

@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Sep 7, 2021
@Buju77
Copy link
Author

Buju77 commented Sep 7, 2021

Alternatively please modify your /Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb file inside the pre_download method and add a puts e right below the rescue => e line on 119 and before the raise line on 120. This might give us more insight about what the underlying error is.

just tried this, but unfortunately also just prints:

can't modify frozen String

@Buju77
Copy link
Author

Buju77 commented Sep 7, 2021

ok, so I've tracked down the line that crashes, which is the Downloader.preprocess_options(request.params) in downloader.rb#132

I've added bunch of puts for debugging in that method:

    def self.preprocess_request(request)
      puts "============= DEBUG =============== creating Request.new() now ..."
      puts "============= DEBUG =============== spec: #{request.spec}"
      puts "============= DEBUG =============== real: #{request.released_pod?}"
      puts "============= DEBUG =============== name: #{request.name}"
      puts "============= DEBUG =============== para: #{request.params}"
      # puts "============= DEBUG =============== prep: #{Downloader.preprocess_options(request.params)}" # would crashes here

      begin
        crashing_params = Downloader.preprocess_options(request.params) # boom 💥 
      rescue => e
        puts "============= DEBUG =============== error: #{e}"
      end

      req = Request.new(
        :spec => request.spec,
        :released => request.released_pod?,
        :name => request.name,
        :params => Downloader.preprocess_options(request.params))
      puts "============= DEBUG =============== after creating"
      req
    end

and this is the output:

Fetching external sources
-> Pre-downloading: 'profile' from `ssh://git@blub.com:7999/profile.git`, branch `master`
============= DEBUG =============== preprocess_request
============= DEBUG =============== creating Request.new() now ...
============= DEBUG =============== spec:
============= DEBUG =============== real: false
============= DEBUG =============== name: profile
============= DEBUG =============== para: {:git=>"ssh://git@blub.com:7999/profile.git", :branch=>"master"}
  $ /usr/bin/git ls-remote ssh://git@blub.com:7999/profile.git master
  862052ef4a1df40d1d801a341b280eec78c9137d	refs/heads/master
============= DEBUG =============== error: can't modify frozen String
[!] Failed to download 'profile': can't modify frozen String

/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb:123:in `rescue in block in pre_download'
/Users/cloud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.10.2/lib/cocoapods/external_sources/abstract_external_source.rb:115:in `block in pre_download'
...

Where is Downloader.preprocess_options() implemented? I couldn't find it in the repo to add more debug puts 🤔

@Buju77
Copy link
Author

Buju77 commented Sep 7, 2021

so, after some further digging, I finally found the line that causes this error. It is actually a new line that was recently introduced in cocoapods-downloader 1.5.0 release 7 days ago:

https://github.com/CocoaPods/cocoapods-downloader/compare/1.4.0...1.5.0#diff-10b883c026b3c31048ba1993c70a5c8975ed81384dc1f19182c224cada97648c (seems like I am unable to post a direct link to the diff 🤷‍♂️ )

Screenshot 2021-09-07 at 13 13 09

encoded_branch_name = branch_name.force_encoding(Encoding::ASCII_8BIT)

This line causes the "can't modify frozen string" exception

@Buju77
Copy link
Author

Buju77 commented Sep 7, 2021

lol seems like the issue is fixed by using encode method instead of force_encoding ✅ 🎉

encoded_branch_name = branch_name.encode(Encoding::ASCII_8BIT)

@Buju77
Copy link
Author

Buju77 commented Sep 7, 2021

I've opened a PR now. Would really appreciate it if somebody could release the bugfix pretty soon :)

@dnkoutso
Copy link
Contributor

dnkoutso commented Sep 7, 2021

awesome! I will take a look, we can ship cocoapods-downloader 1.5.1 for this. I will help you land the PR.

@dnkoutso
Copy link
Contributor

dnkoutso commented Sep 7, 2021

This was fixed in cocoapods-downloader and shipped with version 1.5.1. Please use gem update cocoapods-downloader if you encounter this error.

@dnkoutso dnkoutso closed this as completed Sep 7, 2021
@dnkoutso dnkoutso removed this from the 1.11.1 milestone Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants