SourceKitten icon indicating copy to clipboard operation
SourceKitten copied to clipboard

Crash if there is no newline at the end of the file on Linux

Open msaehn opened this issue 7 years ago • 1 comments

Hi, We use sourceKitten in the following way: sourcekitten doc --spm-module <ourModule>" and everything is fine. But if there is a *.swift file without a newline at the end of the file we get the following error:

/usr/lib/ruby/2.3.0/json/common.rb:156:in `initialize': A JSON text must at least contain two octets! (JSON::ParserError)
	from /usr/lib/ruby/2.3.0/json/common.rb:156:in `new'
	from /usr/lib/ruby/2.3.0/json/common.rb:156:in `parse'
	from /var/lib/gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:794:in `parse'
	from /var/lib/gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:145:in `build_docs_for_sourcekitten_output'
	from /var/lib/gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:77:in `build'
	from /var/lib/gems/2.3.0/gems/jazzy-0.9.3/bin/jazzy:15:in `<top (required)>'
	from /usr/local/bin/jazzy:23:in `load'
	from /usr/local/bin/jazzy:23:in `<main>'

But only on linux (we use the container norionomura/jazzy:0.9.3_swift-4.1.2 to build it on linux) (This happens to us, because some developers in our team don't use Xcode, which adds always a newline at the end of the file)

msaehn avatar Sep 10 '18 15:09 msaehn

This may be a known issue SR-8378 of SourceKit that fixed on master branch on apple/swift and a duplicate of #543.

norio-nomura avatar Sep 10 '18 23:09 norio-nomura