undefined method `-' for nil:NilClass #449

Closed
humblehacker opened this Issue Aug 8, 2012 · 14 comments

Projects

None yet

5 participants

@humblehacker

Report

  • What did you do?

    I just upgraded to cocoapods 0.11.0.

    pod install
    
  • What did you expect to happen?

    pod install to be successful

  • What happened instead?

Stack

   CocoaPods : 0.11.0
        Ruby : ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
    RubyGems : 1.8.24
        Host : Mac OS X 10.8 (12A269)
       Xcode : 4.4 (4F250)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 2264495529aa52c7353433e26af4a8727bdbea70

Podfile

          platform :ios, '4.3'

pod 'SDWebImage'
pod 'RestKit'

Error

undefined method `-' for nil:NilClass
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/local_pod.rb:419:in `public_header_mappings'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/local_pod.rb:418:in `each'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/local_pod.rb:418:in `public_header_mappings'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/local_pod.rb:349:in `link_headers'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/installer/target_installer.rb:72:in `install!'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/installer/target_installer.rb:67:in `each'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/installer/target_installer.rb:67:in `install!'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/installer.rb:113:in `install!'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/installer.rb:111:in `each'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/installer.rb:111:in `install!'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/command/install.rb:53:in `run'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/lib/cocoapods/command.rb:72:in `run'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.11.0/bin/pod:12
/usr/bin/pod:23:in `load'
/usr/bin/pod:23
@humblehacker

Reverted to cocoapods 0.10.0. Problem went away.

@fabiopelosin
Member

Definitely there is an issue there! 0.10.0 Should have no problems.

@Zyphrax
Zyphrax commented Aug 9, 2012

I encountered the same bug with the RestKit pod in 0.11.0.
Version 0.10.0 works fine.

@BenjaminDigeon

I encountered the same bug with the RestKit pod in 0.11.0.

@alloy alloy was assigned Aug 9, 2012
@alloy
Member
alloy commented Aug 9, 2012

@irrationalfab FYI, I’m taking a look at this atm.

@fabiopelosin
Member

I've solved it, push coming soon.

@fabiopelosin
Member

Were you starting to look at it or do you already have the patch?

@alloy
Member
alloy commented Aug 9, 2012

I have a patch, but I was investigating why we had the unless headers.empty? guard in LocalPod#header_files_by_spec in the first place.

Does your patch also address the problem by just adding an empty array to the results hash of LocalPod#header_files_by_spec?

@alloy
Member
alloy commented Aug 9, 2012

It was introduced here, but I don’t see a clear reason for it.

@alloy
Member
alloy commented Aug 9, 2012

@irrationalfab Here’s my diff:

diff --git a/lib/cocoapods/local_pod.rb b/lib/cocoapods/local_pod.rb
index f652d07..100b300 100644
--- a/lib/cocoapods/local_pod.rb
+++ b/lib/cocoapods/local_pod.rb
@@ -224,7 +224,7 @@ module Pod
       result = {}
       source_files_by_spec.each do |spec, paths|
         headers = paths.select { |f| f.extname == '.h' }
-        result[spec] = headers unless headers.empty?
+        result[spec] = headers
       end
       result
     end
diff --git a/spec/unit/local_pod_spec.rb b/spec/unit/local_pod_spec.rb
index abae233..345ba76 100644
--- a/spec/unit/local_pod_spec.rb
+++ b/spec/unit/local_pod_spec.rb
@@ -55,6 +55,14 @@ describe Pod::LocalPod do
       files.should == [ @pod.root + "Classes/Banana.h" ]
     end

+    it 'returns an empty list if the specification has no header files (for instance with a meta/wrapper spec)' do
+      spec = @pod.specifications.first
+      # no header files for this subspec
+      subspec = spec.subspec('MetaSpec') { |_| }
+      @pod.add_specification(subspec)
+      @pod.header_files_by_spec[subspec].should == []
+    end
+
     it 'returns an expanded list the files to clean' do
       clean_paths = @pod.clean_paths.map { |p| p.to_s.gsub(/.*Pods\/BananaLib/,'') }
       clean_paths.should.include "/.git/config"
@fabiopelosin
Member

I went' the other route and checked if they were empty. See 3c31a30

@alloy
Member
alloy commented Aug 9, 2012

@irrationalfab I don’t think that’s correct (as I commented on the commit itself). In addition, the header_mappings method also relies on header_files_by_spec not returning nil for any of the specs, my change fixes that too.

I’m just a bit concerned that I don’t understand the reason why specs with no header files were being omitted, do you remember a specific reason?

@fabiopelosin
Member

Closing as fixed by 4d85f94

@fabiopelosin fabiopelosin added a commit that referenced this issue Aug 9, 2012
@fabiopelosin fabiopelosin Merge branch 'master' into pod_update
* master:
  [Git] Init submodules only after the checkout. #451
  [Subversion] Improved head support.
  [LocalPod] Completed fix for public headers handling. #449
  [LocalPod] Fix public headers handling. #449
0a244e6
@fabiopelosin
Member

CP 0.11.1 Is out and should fix this issues.

@fabiopelosin fabiopelosin added a commit that referenced this issue Oct 25, 2014
@fabiopelosin fabiopelosin Merge branch 'master' into pod_update
* master:
  [Git] Init submodules only after the checkout. #451
  [Subversion] Improved head support.
  [LocalPod] Completed fix for public headers handling. #449
  [LocalPod] Fix public headers handling. #449
85dc035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment