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

incompatible character encodings: UTF-8 and ASCII-8BIT when exec pod search #5338

Closed
Whirlwind opened this issue May 16, 2016 · 10 comments
Closed
Labels
s1:awaiting input Waiting for input from the original author

Comments

@Whirlwind
Copy link
Contributor

Cocoapods 1.0.0, I run the command pod search xxx, I got a error:

➜  pod search TBCalendar
bundler: failed to load command: pod (/Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/bin/pod)
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-1.0.0/lib/cocoapods/user_interface/error_report.rb:13:in `report'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-1.0.0/lib/cocoapods/command.rb:64:in `report_error'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/claide-1.0.0/lib/claide/command.rb:396:in `handle_exception'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/claide-1.0.0/lib/claide/command.rb:337:in `rescue in run'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/claide-1.0.0/lib/claide/command.rb:325:in `run'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-1.0.0/lib/cocoapods/command.rb:50:in `run'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-1.0.0/bin/pod:55:in `<top (required)>'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/bin/pod:22:in `load'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/bin/pod:22:in `<top (required)>'

I check the code, and comment the rescue, I get the error:

➜  pod search TBCalendar
JSON::ParserError: 757: unexpected token at '()":["※ikemen"],"※":["※ikemen"],"{$0.text":["※ikemen"],"\"Name\"}":["※ikemen"],"🔒":["🔒"],"auth.":["🔒"],"🕕":["🕕"],"Büglingc":["🕕"]}}'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `parse'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `parse'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-core-1.0.0/lib/cocoapods-core/source/manager.rb:251:in `stored_search_index'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-core-1.0.0/lib/cocoapods-core/source/manager.rb:187:in `updated_search_index'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-core-1.0.0/lib/cocoapods-core/source/manager.rb:118:in `search_by_name'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-search-1.0.0/lib/cocoapods-search/command/search.rb:87:in `local_search'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-search-1.0.0/lib/cocoapods-search/command/search.rb:63:in `run'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/claide-1.0.0/lib/claide/command.rb:334:in `run'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-1.0.0/lib/cocoapods/command.rb:50:in `run'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/gems/cocoapods-1.0.0/bin/pod:55:in `<top (required)>'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/bin/pod:22:in `load'
  /Users/whirlwind/.tbenv/1.0.0/vendor/bundle/ruby/2.1.0/bin/pod:22:in `<top (required)>'

How to do about it?

@segiddins
Copy link
Member

@manuyavuz looks like we might need to be more careful about string encoding in the cocoapods-search plugin.

@Whirlwind
Copy link
Contributor Author

I think that it is cocoapods-core when store index.

@manuyavuz
Copy link
Member

@Whirlwind could you share the contents of ~/Library/Caches/CocoaPods/search_index.json file?

I've tried the same scenario but did not experience that kind of an error. I need to look into the contents of the json file.

@manuyavuz manuyavuz added the s1:awaiting input Waiting for input from the original author label May 20, 2016
@Whirlwind
Copy link
Contributor Author

@manuyavuz
Copy link
Member

manuyavuz commented May 23, 2016

Interesting, you seem to have 3 spec repos with exact contents with the following names:

  • master
  • test-mirror
  • alibaba-inc-specs-mirror

Are these really forks of master repo? If so, why do you need such a usage?

Other than that, the error seems to be caused from a weird copy paste behavior at the tail of the file:

"UILabel()":["※ikemen"],"※":["※ikemen"],"{$0.text":["※ikemen"],"\"Name\"}":["※ikemen"],"🔒":["🔒"],"auth.":["🔒"],"🕕":["🕕"],"Büglingc":["🕕"]}}()":["※ikemen"],"※":["※ikemen"],"{$0.text":["※ikemen"],"\"Name\"}":["※ikemen"],"🔒":["🔒"],"auth.":["🔒"],"🕕":["🕕"],"Büglingc":["🕕"]}}

Following part is repeated which causes invalid JSON:

()":["※ikemen"],"※":["※ikemen"],"{$0.text":["※ikemen"],"\"Name\"}":["※ikemen"],"🔒":["🔒"],"auth.":["🔒"],"🕕":["🕕"],"Büglingc":["🕕"]}}

Is there any chance where you accidentally manually copy/pasted the set of characters above? I see no way to programmatically generate such a JSON file with current code.

Also, could you try again by first deleting ~/Library/Caches/CocoaPods/search_index.json file then running pod search xxx command again, and waiting until it finishes it's job?

@Whirlwind
Copy link
Contributor Author

It works after I delete the json and run the pod search xx !

I think it is because that last time I interrupt the build process over Control + C, then the CP build the json two times.

@manuyavuz
Copy link
Member

Can you send the output of pod repo here? I'll check if there is any anomaly in generated json file.

You don't need to send URLs, only names will suffice.

@manuyavuz
Copy link
Member

manuyavuz commented Jun 13, 2016

Closing for now because I can't reproduce this weird case myself, and your problem was solved.

@Cooooooker
Copy link

nice, I solve the problem, thx

@yangzq007
Copy link

yangzq007 commented May 26, 2017

delete the file ~/Library/Caches/CocoaPods/search_index.json works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s1:awaiting input Waiting for input from the original author
Projects
None yet
Development

No branches or pull requests

5 participants