xcode-install icon indicating copy to clipboard operation
xcode-install copied to clipboard

xcversion install 9.4.1 fails with undefined method `length' for nil:NilClass (NoMethodError)

Open Nathan-Smith opened this issue 7 years ago • 11 comments

After running

xcversion install 9.4.1

and entering my login sometime during the download xcversion exited with:

100   311  100   311    0     0    409      0 --:--:-- --:--:-- --:--:--   411%
 %Traceback (most recent call last):6k      0  0:23:59  0:15:41  0:08:18 8076k%
	12: from /Users/****/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `<main>'
	11: from /Users/****/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `eval'
	10: from /Users/****/.rvm/gems/ruby-2.5.1/bin/xcversion:23:in `<main>'
	 9: from /Users/****/.rvm/gems/ruby-2.5.1/bin/xcversion:23:in `load'
	 8: from /Users/****/.rvm/gems/ruby-2.5.1/gems/xcode-install-2.4.0/bin/xcversion:12:in `<top (required)>'
	 7: from /Users/****/.rvm/gems/ruby-2.5.1/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
	 6: from /Users/****/.rvm/gems/ruby-2.5.1/gems/xcode-install-2.4.0/lib/xcode/install/install.rb:46:in `run'
	 5: from /Users/****/.rvm/gems/ruby-2.5.1/gems/xcode-install-2.4.0/lib/xcode/install.rb:276:in `install_version'
	 4: from /Users/****/.rvm/gems/ruby-2.5.1/gems/xcode-install-2.4.0/lib/xcode/install.rb:366:in `get_dmg'
	 3: from /Users/****/.rvm/gems/ruby-2.5.1/gems/xcode-install-2.4.0/lib/xcode/install.rb:140:in `download'
	 2: from /Users/****/.rvm/gems/ruby-2.5.1/gems/xcode-install-2.4.0/lib/xcode/install.rb:77:in `fetch'
	 1: from /Users/****/.rvm/gems/ruby-2.5.1/gems/xcode-install-2.4.0/lib/xcode/install.rb:77:in `times'
/Users/****/.rvm/gems/ruby-2.5.1/gems/xcode-install-2.4.0/lib/xcode/install.rb:98:in `block in fetch': undefined method `length' for nil:NilClass (NoMethodError)

Nathan-Smith avatar Jun 14 '18 12:06 Nathan-Smith

Can you try updating to the most recent release?

KrauseFx avatar Jun 14 '18 14:06 KrauseFx

@KrauseFx, I ran the command again after waiting an hour or so. Maybe this was curl encountering some network error and fetch inside install.rb couldn't handle that specific output in the progress_log_file unfortunately for debugging sake that file gets cleaned up.

Nathan-Smith avatar Jun 14 '18 23:06 Nathan-Smith

+1 -- using release 2.4.1

edwardvalentini avatar Jul 05 '18 20:07 edwardvalentini

Running: xcversion install "10 beta 6" Got:

/Users/jenkins/.gem/ruby/2.3.0/gems/xcode-install-2.4.4/lib/xcode/install.rb:98:in length' for nil:NilClass (NoMethodError)
	from /Users/jenkins/.gem/ruby/2.3.0/gems/xcode-install-2.4.4/lib/xcode/install.rb:77:in fetch'
	from /Users/jenkins/.gem/ruby/2.3.0/gems/xcode-install-2.4.4/lib/xcode/install.rb:140:in get_dmg'
	from /Users/jenkins/.gem/ruby/2.3.0/gems/xcode-install-2.4.4/lib/xcode/install.rb:276:in run'
	from /Users/jenkins/.gem/ruby/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in <top (required)>'
	from /Users/jenkins/.gem/ruby/2.3.0/bin/xcversion:22:in <main>'

Got this after 14 minutes of download.

taraspos avatar Aug 14 '18 12:08 taraspos

I'm trying to install it with Ansible on the remote machine (as async task https://docs.ansible.com/ansible/2.5/user_guide/playbooks_async.html) and it fails for the third time already... Same error all the time, mostly somewhere close ~30 minutes of download.

taraspos avatar Aug 14 '18 14:08 taraspos

I'm also seeing this on xcode-install (2.4.4), trying to install 10 beta 6.

jamezilla avatar Aug 15 '18 19:08 jamezilla

The issue is with the regex here: https://github.com/KrauseFx/xcode-install/blob/master/lib/xcode/install.rb#L97

matched = progress_content.match(/^\s*(\d+)/)

progress_content is something like

"######################################################################## 100.0%"

The regex does not match that because of the ^. If I remove the ^ then it works fine.

I'd open a PR for this, but I have no idea how this is working for anyone currently, so my guess is the value of progress_content somehow varies from user to user. We'd need to collect a little more data to come up with the right fix.

Maybe a better option would be to change the regex to anchor off the space and the percent:

matched = progress_content.match(/\s(\d+)(\.(\d+))?%/)

Rubular link for testing: http://rubular.com/r/zadCuMaiKg

It would be a bit more complicated to validate, though.

jamezilla avatar Aug 16 '18 19:08 jamezilla

It looks like lack of configurable curl retries could be the problem. Because internet connection is not super fast in my office and download of file 5GB file likely to crash during 2-4 hours of download.

I had to download xpi file via browser and do the install with xcversion

taraspos avatar Aug 17 '18 11:08 taraspos

I also get the same error for Xcode 10 with the version 2.4.4

mariohahn avatar Sep 18 '18 11:09 mariohahn

And also for Xcode 10.1 with the version 2.4.4

nicoaldegheri avatar Nov 07 '18 08:11 nicoaldegheri

At least one time you hit this case is if you have a custom ~/.curlrc file where you change the progress bar, I've fixed that here https://github.com/KrauseFx/xcode-install/pull/327

keith avatar Dec 18 '18 22:12 keith