Brew: Homebrew/config.rb crashes when no HOMEBREW_LOGS or HOMEBREW_TEMP (1.9)

Created on 9 Jan 2019  路  9Comments  路  Source: Homebrew/brew

  • [x] are reporting a bug others will be able to reproduce and not asking a question. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh
  • [x] ran a brew command and reproduced the problem with multiple formulae? If it's a problem with a single, official formula (not cask) please file this issue at Homebrew/homebrew-core: https://github.com/Homebrew/homebrew-core/issues/new/choose. If it's a brew cask problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • [x] ran brew update and can still reproduce the problem?
  • [x] ran brew doctor, fixed all issues and can still reproduce the problem?
  • [x] ran brew config and brew doctor and included their output with your issue?

What you were trying to do (and why)

Running a CircleCI tests for https://github.com/fastlane/fastlane/ that uses homebrew. The crash was happening during a homebrew update (to 1.9 I'm assuming).

I was told to create an issue by @MikeMcQuaid when commenting on https://github.com/Homebrew/brew/pull/5451#issuecomment-452716973

What happened (include command output)


Command output 1

Error: File exists - /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/homebrew-cask
/usr/local/Homebrew/Library/Homebrew/config.rb:39:in initialize': no implicit conversion of nil into String (TypeError) from /usr/local/Homebrew/Library/Homebrew/config.rb:39:innew'
from /usr/local/Homebrew/Library/Homebrew/config.rb:39:in <top (required)>' from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/local/Homebrew/Library/Homebrew/global.rb:25:in from /usr/local/Homebrew/Library/Homebrew/brew.rb:13:in require_relative' from /usr/local/Homebrew/Library/Homebrew/brew.rb:13:in

'



Command output 1

Error: File exists - /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/homebrew-cask
/usr/local/Homebrew/Library/Homebrew/config.rb:39:in initialize': no implicit conversion of nil into String (TypeError) from /usr/local/Homebrew/Library/Homebrew/config.rb:39:innew'
from /usr/local/Homebrew/Library/Homebrew/config.rb:39:in <top (required)>' from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/local/Homebrew/Library/Homebrew/global.rb:25:in from /usr/local/Homebrew/Library/Homebrew/brew.rb:13:in require_relative' from /usr/local/Homebrew/Library/Homebrew/brew.rb:13:in

'



Command output - brew config

bash-3.2$ brew config
HOMEBREW_VERSION: 1.9.0
ORIGIN: https://github.com/Homebrew/brew
HEAD: 04b020d09078d9c3067fe8e561cf1b4a23fbee35
Last commit: 6 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 53fc2f730f3d75df74111ec29d6af0d2e2de5102
Core tap last commit: 58 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_LOGS: /Users/distiller/Library/Logs/Homebrew
CPU: quad-core 64-bit ivybridge
Homebrew Ruby: 2.3.7 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/bin/ruby
Clang: 9.0 build 900
Git: 2.13.5 => /Applications/Xcode-9.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_144
macOS: 10.12.6-x86_64
CLT: 9.0.0.0.1.1504363082
Xcode: 9.0 => /Applications/Xcode-9.app/Contents/Developer



Command output - brew doctor

bash-3.2$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: A newer Command Line Tools release is available.
Update them from Software Update in the App Store.
Warning: An outdated version (2.13.5) of Git was detected in your PATH.
Git 2.14.3 or newer is required for Homebrew.
Please upgrade:
brew install git
Warning: Your Xcode (9.0) is outdated.
Please update to Xcode 9.2 (or delete it).
Xcode can be updated from the App Store.


What you expected to happen

I did not expect errors to be thrown like this when when environment variables were not found 馃槉 I expected either a nice error message to be shown informing me I now need to specify these environment variables or run brew doctor which could fix this.

Step-by-step reproduction instructions (by running brew commands)

I don't really know if I have step-by-step instructions for this. I was updating from an old version of homebrew (that had a fallback for HOMEBREW_LOGS and HOMEBREW_TEMP) to 1.9 which does not.

I ran brew config after I was able to SSH into the box and it appears that there is an environment variable for HOMEBREW_LOGS but it was still crashing on https://github.com/Homebrew/brew/blame/master/Library/Homebrew/config.rb#L39.

Workaround

To work around this I manually added the following environment variables into my CircleCI project and things works:

HOMEBREW_LOGS=~/homebrew-logs
HOMEBREW_TEMP=~/homebrew-temp
outdated

Most helpful comment

I've opened a PR for this in https://github.com/Homebrew/brew/pull/5517. Until that is merged and hits a stable tag I recommend adding a manual brew update call as this is a bug in the auto-updater that cannot be fixed, only worked around. I also recommend you ask your CI provider to update their old (ancient in Circle CI's case) version of Homebrew which will save everyone some time on their builds.

Why were the fallback measures removed from the config file in the first place?

Because this issue wasn't reproduced before today and we don't want to keep that code around forever?

All 9 comments

Command output - brew config
Command output - brew doctor

Thanks for the report @joshdholtz. Can I get the output of these from _before_ the brew update was run?

@MikeMcQuaid I can try 馃 I had to rerun the job in order to get SSH access to the box so I will see if I can add those to my CircleCI config file to output.

@joshdholtz Yeh, I recommend adding them as the first lines in your CircleCI config file before it runs any other brew commands.

@MikeMcQuaid Below is the output:

brew config

HOMEBREW_VERSION: 1.3.4
ORIGIN: https://github.com/Homebrew/brew
HEAD: ac8b58537fe3dd71098a43afcc6a1785dcde1d39
Last commit: 1 year, 3 months ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 7f4e4ca73af3fbea82d80fd5426d6302e74f6684
Core tap last commit: 1 year, 3 months ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: quad-core 64-bit ivybridge
Homebrew Ruby: 2.3.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: 9.0 build 900
Git: 2.13.5 => /Applications/Xcode-9.app/Contents/Developer/usr/bin/git
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /Users/distiller/.rubies/ruby-2.3.5/bin/ruby
Java: 1.8.0_144
macOS: 10.12.6-x86_64
Xcode: 9.0 => /Applications/Xcode-9.app/Contents/Developer
CLT: 9.0.0.0.1.1504363082
X11: N/A

brew doctor

Your system is ready to brew.

@joshdholtz Can you confirm what the commands run that produced the Command output 1 entries above?

@MikeMcQuaid Oops sorry! I believe it was brew install shellcheck - https://github.com/fastlane/fastlane/blob/master/.circleci/config.yml#L27

I think I ran into the same issue just now after trying brew install mysql-utilities. It auto-updated homebrew and then output:

/usr/local/Homebrew/Library/Homebrew/config.rb:39:in `initialize': no implicit conversion of nil into String (TypeError)
    from /usr/local/Homebrew/Library/Homebrew/config.rb:39:in `new'
    from /usr/local/Homebrew/Library/Homebrew/config.rb:39:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/Homebrew/Library/Homebrew/global.rb:25:in `<top (required)>'
    from /usr/local/Homebrew/Library/Homebrew/brew.rb:13:in `require_relative'
    from /usr/local/Homebrew/Library/Homebrew/brew.rb:13:in `<main>'

I ran brew config and tried to install again, and all was fine.

I identified the issue this morning as well running build on our CI server. The workaround resolved the issue. Why were the fallback measures removed from the config file in the first place? 馃

I've opened a PR for this in https://github.com/Homebrew/brew/pull/5517. Until that is merged and hits a stable tag I recommend adding a manual brew update call as this is a bug in the auto-updater that cannot be fixed, only worked around. I also recommend you ask your CI provider to update their old (ancient in Circle CI's case) version of Homebrew which will save everyone some time on their builds.

Why were the fallback measures removed from the config file in the first place?

Because this issue wasn't reproduced before today and we don't want to keep that code around forever?

Was this page helpful?
0 / 5 - 0 ratings