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

Crash when :path is nil #3320

Closed
juanpaco opened this issue Mar 26, 2015 · 6 comments · Fixed by CocoaPods/Core#230
Closed

Crash when :path is nil #3320

juanpaco opened this issue Mar 26, 2015 · 6 comments · Fixed by CocoaPods/Core#230
Assignees
Labels
d1:easy An easy ticket that is a good start for first-time contributors s2:confirmed Issues that have been confirmed by a CocoaPods contributor t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome!

Comments

@juanpaco
Copy link

Hello. I'm new to cocoapods, so you have my apologies if this is a duplicate or if I'm going about this wrong.

In my project we have a number of pods specified. Sometimes we need to work on the pods themselves in the context of the larger app. I know this can be achieved by putting :path => '/path/to/pod' to get a local working copy of the pod. This has the drawback in that now I've modified the Podfile, and it's easy to forget to not check that back into source control.

I can use environment variables when I run pod install, and they get picked up inside of the Podfile just fine. The trouble is that I have to do a bunch of if/else logic, because if I have something like:

pod 'awesome_pod', '1.0.0', :path => ENV['AWESOME_POD_PATH']

and I haven't set AWESOME_POD_PATH when I run it, I get a crash during the pod install process.

I would expect it to just ignore :path being nil in this case, so that it would go to the normal installation location. Since it doesn't, I have to clutter my Podfile with a check to make sure I have the env variable, whose else clause has the pod declaration without the path key.

Does anyone else experience this problem? Should it ignore a nil path? I'm happy to submit a PR to make it work this way if this behavior is desired.

@segiddins
Copy link
Member

Can you please share the crash report?

@juanpaco
Copy link
Author

Absolutely.

Error

TypeError - no implicit conversion of nil into String
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/external_sources/abstract_external_source.rb:68:in `extname'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/external_sources/abstract_external_source.rb:68:in `normalized_podspec_path'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/external_sources/path_source.rb:45:in `podspec_path'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/external_sources/path_source.rb:14:in `block in fetch'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/user_interface.rb:70:in `titled_section'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/external_sources/path_source.rb:13:in `fetch'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:296:in `fetch_external_source'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:273:in `block (2 levels) in fetch_external_sources'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:272:in `each'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:272:in `block in fetch_external_sources'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/user_interface.rb:49:in `section'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:271:in `fetch_external_sources'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:57:in `analyze'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer.rb:184:in `analyze'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer.rb:106:in `block in resolve_dependencies'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/user_interface.rb:49:in `section'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer.rb:105:in `resolve_dependencies'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer.rb:90:in `install!'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/command/project.rb:71:in `run_install_with_update'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/command/project.rb:101:in `run'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/claide-0.7.0/lib/claide/command.rb:271:in `run'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/command.rb:45:in `run'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/bin/pod:43:in `<top (required)>'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/bin/pod:23:in `load'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/bin/pod:23:in `<main>'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/bin/ruby_executable_hooks:15:in `eval'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/bin/ruby_executable_hooks:15:in `<main>'

I can't post the whole Podfile, but here's the line that offends:

pod '<some pod>', :path => ENV['SOME_ENV_VAR']

When ENV['SOME_ENV_VAR'] is set, everything works just fine. As mentioned, I can work around this by putting a guard around the pod call, something like:

if ENV['SOME_ENV_VAR']
  pod '<some pod>', :path => ENV['SOME_ENV_VAR']
else
  pod '<some pod>'
end

But that clutters the file a great deal, and there are a lot of pods we could do this for. Basically, I think the if branch should work whether or not the environment variable is set. If I'm not off my rocker with that behavior, I'm happy to contribute to the project to make it work.

Thanks for CocoaPods!

@segiddins
Copy link
Member

I think we can safely compact that hash to remove empty entries, just needed to know where to look! Thanks for the bug report

-Samuel E. Giddins

On Mar 27, 2015, at 8:33 AM, Ethan Garofolo notifications@github.com wrote:

Absolutely.

Error

TypeError - no implicit conversion of nil into String
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/external_sources/abstract_external_source.rb:68:in extname' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/external_sources/abstract_external_source.rb:68:innormalized_podspec_path'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/external_sources/path_source.rb:45:in podspec_path' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/external_sources/path_source.rb:14:inblock in fetch'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/user_interface.rb:70:in titled_section' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/external_sources/path_source.rb:13:infetch'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:296:in fetch_external_source' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:273:inblock (2 levels) in fetch_external_sources'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:272:in each' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:272:inblock in fetch_external_sources'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/user_interface.rb:49:in section' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:271:infetch_external_sources'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer/analyzer.rb:57:in analyze' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer.rb:184:inanalyze'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer.rb:106:in block in resolve_dependencies' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/user_interface.rb:49:insection'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer.rb:105:in resolve_dependencies' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/installer.rb:90:ininstall!'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/command/project.rb:71:in run_install_with_update' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/command/project.rb:101:inrun'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/claide-0.7.0/lib/claide/command.rb:271:in run' /Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/lib/cocoapods/command.rb:45:inrun'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/gems/cocoapods-0.35.0/bin/pod:43:in <top (required)>' /Users/ethan/.rvm/gems/ruby-2.2.0@global/bin/pod:23:inload'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/bin/pod:23:in <main>' /Users/ethan/.rvm/gems/ruby-2.2.0@global/bin/ruby_executable_hooks:15:ineval'
/Users/ethan/.rvm/gems/ruby-2.2.0@global/bin/ruby_executable_hooks:15:in `

'
I can't post the whole Podfile, but here's the line that offends:

pod '', :path => ENV['SOME_ENV_VAR']

When ENV['SOME_ENV_VAR'] is set, everything works just fine. As mentioned, I can work around this by putting a guard around the pod call, something like:

if ENV['SOME_ENV_VAR']
pod '', :path => ENV['SOME_ENV_VAR']
else
pod ''
end
But that clutters the file a great deal, and there are a lot of pods we could do this for. Basically, I think the if branch should work whether or not the environment variable is set. If I'm not off my rocker with that behavior, I'm happy to contribute to the project to make it work.

Thanks for CocoaPods!


Reply to this email directly or view it on GitHub.

@juanpaco
Copy link
Author

You're very welcome. Thanks for the speedy response!

@segiddins segiddins self-assigned this Mar 27, 2015
@segiddins segiddins added t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome! d1:easy An easy ticket that is a good start for first-time contributors s2:confirmed Issues that have been confirmed by a CocoaPods contributor labels Mar 27, 2015
@segiddins
Copy link
Member

@juanpaco this was just fixed in CocoaPods/Core master.

@juanpaco
Copy link
Author

@segiddins Wow. Talk about fast turn around. Thanks a bunch! Y'all do great work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
d1:easy An easy ticket that is a good start for first-time contributors s2:confirmed Issues that have been confirmed by a CocoaPods contributor t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants