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

Keys not recorded in YML on first run. #175

Closed
ileitch opened this issue Oct 2, 2017 · 7 comments
Closed

Keys not recorded in YML on first run. #175

ileitch opened this issue Oct 2, 2017 · 7 comments

Comments

@ileitch
Copy link
Contributor

ileitch commented Oct 2, 2017

Given a simple Podfile config:

plugin 'cocoapods-keys', {
  :project => "TTKit",
  :keys => [
    "TophatHmacKey",
  ]
}

and an empty macOS keychain and no files generated in ~/.cocoapods/keys, I can demonstrate that the TophatHmacKey is not recorded in the generated YML, and thus is not included in the generated ObjC class.

In a nutshell, this commit from @colinta makes no sense: 7743a9b

It appears the reasoning for the commit is that we need to re-save the keychain if the user was prompted and provided a value for a missing key. However, saving of a new key is performed here & here which loads and saves its own instance of CocoaPodsKeys::Keyring. Once all missing key values have been provided and saved the line from the commit is executed which saves a Keyring instanced created before the missing keys were saved. The end result is that the YML is overwritten with an empty keys array.

This output should make things more clear:

$ pod install

====================
PreInstaller.setup
has existing keyring? false
====================

 CocoaPods-Keys has detected a keys mismatch for your setup.
 What is the key for TophatHmacKey
 > abc123


====================
KeyringLiberator.save_keyring: {"keys"=>["TophatHmacKey"], "path"=>"/Users/ian/code/tt/ios", "name"=>"TTKit"}

/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-keys-2.0.0/lib/pod/command/keys/set.rb:43:in `run'
/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-keys-2.0.0/lib/preinstaller.rb:72:in `block in setup'
/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-keys-2.0.0/lib/preinstaller.rb:50:in `each'
/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-keys-2.0.0/lib/preinstaller.rb:50:in `setup'
/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-keys-2.0.0/lib/plugin.rb:17:in `setup'
/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-keys-2.0.0/lib/plugin.rb:11:in `block in singleton class'
/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-1.3.1/lib/cocoapods/hooks_manager.rb:109:in `block (3 levels) in run'
... truncated for brevity ...
====================

Saved TophatHmacKey to TTKit.

====================
KeyringLiberator.save_keyring: {"keys"=>[], "path"=>"/Users/ian/code/tt/ios", "name"=>"TTKit"}

/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-keys-2.0.0/lib/preinstaller.rb:75:in `setup'
/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-keys-2.0.0/lib/plugin.rb:17:in `setup'
/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-keys-2.0.0/lib/plugin.rb:11:in `block in singleton class'
/Users/ian/.rvm/gems/ruby-2.3.4/gems/cocoapods-1.3.1/lib/cocoapods/hooks_manager.rb:109:in `block (3 levels) in run'
... truncated for brevity ...
====================

Analyzing dependencies
Fetching podspec for `Keys` from `Pods/CocoaPodsKeys`
... truncated for brevity ...
Pod installation complete! There are 42 dependencies from the Podfile and 46 total pods installed.

$ cat ~/.cocoapods/keys/f0a91780cf6fd09582d758ff310a3a31.yml
---
keys: []
path: "/Users/ian/code/tt/ios"
name: TTKit

Note: the final call in setup has line 75 in the backtrace, this is due my debugging modifications. The line number without any modifications is 68.

Perhaps there used to be some caching of Keyring instances that made this work previously, but it seems to be now that 7743a9b should be reverted.

There appears to be at least one other bug report of this incorrect behavior: #153

ileitch added a commit to ileitch/cocoapods-keys that referenced this issue Oct 2, 2017
@ileitch
Copy link
Contributor Author

ileitch commented Dec 4, 2017

@orta ping?

@BasThomas
Copy link
Contributor

We're hitting this too; would you be interested in merging a pull request to fix this?

@ashfurrow
Copy link
Collaborator

Yeah, for sure. We've just always re-ran pod install, but getting this fixed would be 👍

@BasThomas
Copy link
Contributor

@ileitch do you want to open a pull request from your fork? :)

@ileitch
Copy link
Contributor Author

ileitch commented Jan 4, 2019

#192

ileitch added a commit to ileitch/cocoapods-keys that referenced this issue Jan 4, 2019
orta added a commit that referenced this issue Jan 4, 2019
@orta
Copy link
Owner

orta commented Jan 4, 2019

Fixed by #192 and shipped in 2.0.7

@orta orta closed this as completed Jan 4, 2019
@BasThomas
Copy link
Contributor

Awesome, thanks @orta :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants