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

no implicit conversion of nil into String (TypeError) #341

Closed
ghost opened this issue Sep 26, 2017 · 13 comments
Closed

no implicit conversion of nil into String (TypeError) #341

ghost opened this issue Sep 26, 2017 · 13 comments

Comments

@ghost
Copy link

ghost commented Sep 26, 2017

I'm getting the following error when I try and run slather:

/Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/slather-2.4.3/lib/slather/project.rb:182:in `initialize': no implicit conversion of nil into String (TypeError)
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/slather-2.4.3/lib/slather/project.rb:182:in `new'
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/slather-2.4.3/lib/slather/project.rb:182:in `profdata_coverage_dir'
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/slather-2.4.3/lib/slather/project.rb:424:in `find_binary_files'
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/slather-2.4.3/lib/slather/project.rb:367:in `configure_binary_file'
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/slather-2.4.3/lib/slather/project.rb:251:in `configure'
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/slather-2.4.3/lib/slather/command/coverage_command.rb:54:in `execute'
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb:11:in `execute'
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/clamp-0.6.5/lib/clamp/command.rb:132:in `run'
	from /Users/lyptt/.rubies/2.4.1/lib/ruby/gems/2.4.0/gems/slather-2.4.3/bin/slather:17:in `<top (required)>'
	from /Users/lyptt/.rubies/2.4.1/bin/slather:22:in `load'
	from /Users/lyptt/.rubies/2.4.1/bin/slather:22:in `<main>'

Here's my .slather.yml:

# .slather.yml
coverage_service: cobertura_xml
xcodeproj: project.xcodeproj
scheme: app
configuration: debug
source_directory: src
output_directory: coverage
# ignore:
# - a/b/c.swift
@abhilashdonepudi
Copy link

Getting the same issue. Any insight to fix this issue? I am using ruby 2.2.5.

@ksuther
Copy link
Contributor

ksuther commented Oct 10, 2017

This will happen if slather can't find any Coverage.profdata files.

If you look at profdata_coverage_dir in project.rb you can see the paths that slather is searching for and follow along using the build directory that you've specified.

For Xcode 7/8 it's looking for a CodeCoverage directory, for Xcode 9 it's looking for a ProfileData/ directory.

@abhilashdonepudi
Copy link

Thanks. I was able to resolve this. I am using Xcode 8.3 but it is pointing to Xcode 9 build tools. Once I change that in preference section, it started working.

@MacGritsch
Copy link

Hi all,

it seems I have the same problem!
Everything works fine if I run the command from Terminal.app (with config file and also with parameters).
But when I run it as a test-post-script in Xcode it does not run.
For testing purposes I am exporting same pairs as in my term session (so that the script finds slather).
But I still get the following error:

Slathering...
/Users/myusername/.gem/gems/slather-2.4.3/lib/slather/project.rb:182:in initialize': no implicit conversion of nil into String (TypeError) from /Users/myusername/.gem/gems/slather-2.4.3/lib/slather/project.rb:182:in new'
from /Users/myusername/.gem/gems/slather-2.4.3/lib/slather/project.rb:182:in profdata_coverage_dir' from /Users/myusername/.gem/gems/slather-2.4.3/lib/slather/project.rb:191:in profdata_file'
from /Users/myusername/.gem/gems/slather-2.4.3/lib/slather/project.rb:263:in configure' from /Users/myusername/.gem/gems/slather-2.4.3/lib/slather/command/coverage_command.rb:54:in execute'
from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in run' from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb:11:in execute'
from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in run' from /Library/Ruby/Gems/2.0.0/gems/clamp-0.6.5/lib/clamp/command.rb:132:in run'
from /Users/myusername/.gem/gems/slather-2.4.3/bin/slather:17:in <top (required)>' from /Users/myusername/.gem/bin/slather:23:in load'
from /Users/myusername/.gem/bin/slather:23:in `

'

Thank you very much!

@MacGritsch
Copy link

O man... I found the reason: Xcode does not create the Coverage.profdata until the post-action-script is done. (puke).

But I think slather should throw a correct error message...

thank you!

@MacGritsch
Copy link

MacGritsch commented Oct 31, 2017

As a solution I run the slather-command in background (appending &). But maybe we need to wait a second till the coverage-file is created. Would it make sense to add something like my patch below? (maybe dependent on a parameter):

diff --git a/lib/slather/project.rb b/lib/slather/project.rb
index 11c2c5d..7eec3a4 100755
--- a/lib/slather/project.rb
+++ b/lib/slather/project.rb
@@ -175,7 +175,16 @@ module Slather
         if coverage_files.count == 0
           # Look up one directory
           # The ProfileData directory is next to Intermediates.noindex (in previous versions of Xcode the coverage was inside Intermediates)
-          coverage_files = Dir[File.join(build_directory, "../**/ProfileData/*/Coverage.profdata")]
+          
+		  for i in 0..10
+			  coverage_files = Dir[File.join(build_directory, "../**/ProfileData/*/Coverage.profdata")]
+			  if coverage_files.count > 0 then
+				  break
+			  end
+			  
+			  sleep(0.1)
+		  end
+		  
         end
 
         if coverage_files != nil

@milos1290
Copy link

I'm having the same issue on Jenkins. Running it locally everything works fine. Any solution ?

@mikelupo
Copy link

mikelupo commented Nov 1, 2017 via email

@benmarten
Copy link

@milos1290 this happens when the binary_file is invalid. Once you actually open Xcode and manually run the tests on jenkins slave, the expected build files appear under /DerivedData and the error is gone.
This is only workaround though. Ideally we point it to the correct binary location in the first place.

@vbabenkoru
Copy link

Are there no solutions for this?

phimage added a commit to phimage/slather that referenced this issue Apr 10, 2018
@soprof
Copy link

soprof commented Apr 18, 2018

Make sure to set "--workspace" if you're using the workspace,
e.g.

slather coverage -s --scheme docdoc --workspace docdoc.xcworkspace docdoc.xcodeproj

ksuther added a commit that referenced this issue Nov 13, 2018
Show "No coverage directory found." instead of "implicit conversion nil into String" #341
@gabrielsscavalcante
Copy link

I'm still having this problem. Solutions for this?

@ksuther
Copy link
Contributor

ksuther commented Mar 14, 2019

This error has been clarified to show that slather can't find a coverage directory in 2.4.7.

@ksuther ksuther closed this as completed Mar 14, 2019
fetzig added a commit to getsentry/sentry-cocoa that referenced this issue Nov 14, 2019
had troulbes similar to this SlatherOrg/slather#341

short look around revealed there is a `slather` fastlane action. replaced it with the custom `sh` action (which is called bevor test manages to export the needed coverage data for slather) and tweaked settings to work conveniently in dev environment.
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

9 participants