From 699d543ecddeb399c3d1640bad692e48c66be6ad Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 21 Jan 2019 12:37:42 +0000 Subject: [PATCH 1/6] Use Homebrew.default_prefix? in more places. --- Library/Homebrew/diagnostic.rb | 2 +- Library/Homebrew/utils/analytics.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 5555a3ca71..c42bf31623 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -802,7 +802,7 @@ module Homebrew end def check_homebrew_prefix - return if HOMEBREW_PREFIX.to_s == Homebrew::DEFAULT_PREFIX + return if Homebrew.default_prefix? <<~EOS Your Homebrew's prefix is not #{Homebrew::DEFAULT_PREFIX}. diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 30b7c606b8..7283b5aece 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -16,7 +16,7 @@ module Utils def os_prefix_ci @os_prefix_ci ||= begin os = OS_VERSION - prefix = ", #{custom_prefix_label}" if HOMEBREW_PREFIX.to_s != Homebrew::DEFAULT_PREFIX + prefix = ", #{custom_prefix_label}" if Homebrew.default_prefix? ci = ", CI" if ENV["CI"] "#{os}#{prefix}#{ci}" end From c3a46bc57046a11e3f95dffc11ac57842c887f38 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 21 Jan 2019 12:38:28 +0000 Subject: [PATCH 2/6] os/mac/diagnostic: remove some old/unneeded checks. --- Library/Homebrew/extend/os/mac/diagnostic.rb | 41 ------------------- .../Homebrew/test/os/mac/diagnostic_spec.rb | 13 ------ 2 files changed, 54 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 0ab30c6563..d433127500 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -11,7 +11,6 @@ module Homebrew check_xcode_license_approved check_xcode_up_to_date check_clt_up_to_date - check_for_other_package_managers ].freeze end @@ -136,21 +135,6 @@ module Homebrew EOS end - def check_for_other_package_managers - ponk = MacOS.macports_or_fink - return if ponk.empty? - - <<~EOS - You have MacPorts or Fink installed: - #{ponk.join(", ")} - - This can cause trouble. You don't have to uninstall them, but you may want to - temporarily move them out of the way, e.g. - - sudo mv /opt/local ~/macports - EOS - end - def check_ruby_version ruby_version = "2.3.7" return if RUBY_VERSION == ruby_version @@ -200,19 +184,6 @@ module Homebrew EOS end - def check_for_bad_curl - return unless MacOS.version <= "10.8" - return if Formula["curl"].installed? - - <<~EOS - The system curl on 10.8 and below is often incapable of supporting - modern secure connections & will fail on fetching formulae. - - We recommend you: - brew install curl - EOS - end - def check_xcode_license_approved # If the user installs Xcode-only, they have to approve the # license or no "xc*" tool will work. @@ -236,18 +207,6 @@ module Homebrew EOS end - def check_for_beta_xquartz - return unless MacOS::XQuartz.version.to_s.include?("beta") - - <<~EOS - The following beta release of XQuartz is installed: #{MacOS::XQuartz.version} - - XQuartz beta releases include address sanitization, and do not work with - all software; notably, wine will not work with beta releases of XQuartz. - We recommend only installing stable releases of XQuartz. - EOS - end - def check_filesystem_case_sensitive dirs_to_check = [ HOMEBREW_PREFIX, diff --git a/Library/Homebrew/test/os/mac/diagnostic_spec.rb b/Library/Homebrew/test/os/mac/diagnostic_spec.rb index b4a7ecc1bd..91a94eb892 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_spec.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_spec.rb @@ -1,12 +1,6 @@ require "diagnostic" describe Homebrew::Diagnostic::Checks do - specify "#check_for_other_package_managers" do - allow(MacOS).to receive(:macports_or_fink).and_return(["fink"]) - expect(subject.check_for_other_package_managers) - .to match("You have MacPorts or Fink installed:") - end - specify "#check_for_unsupported_macos" do ENV.delete("HOMEBREW_DEVELOPER") allow(OS::Mac).to receive(:prerelease?).and_return(true) @@ -15,13 +9,6 @@ describe Homebrew::Diagnostic::Checks do .to match("We do not provide support for this pre-release version.") end - specify "#check_for_beta_xquartz" do - allow(MacOS::XQuartz).to receive(:version).and_return("2.7.10_beta2") - - expect(subject.check_for_beta_xquartz) - .to match("The following beta release of XQuartz is installed: 2.7.10_beta2") - end - specify "#check_if_xcode_needs_clt_installed" do allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.11")) allow(MacOS::Xcode).to receive(:installed?).and_return(true) From 8258ecc3cae14b8f5f9a180fab118510f91cf5c7 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 21 Jan 2019 12:39:08 +0000 Subject: [PATCH 3/6] =?UTF-8?q?os:=20no=20=E2=80=9CREAD=20THIS=E2=80=9D=20?= =?UTF-8?q?in=20unsupported=20configurations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/os.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/os.rb b/Library/Homebrew/os.rb index 24796f0a1e..7daa73051f 100644 --- a/Library/Homebrew/os.rb +++ b/Library/Homebrew/os.rb @@ -15,8 +15,12 @@ module OS if OS.mac? require "os/mac" - # Don't tell people to report issues on unsupported versions of macOS. - if !OS::Mac.prerelease? && !OS::Mac.outdated_release? + # Don't tell people to report issues on unsupported configurations. + if !OS::Mac.prerelease? && + !OS::Mac.outdated_release? && + !ENV["HOMEBREW_BUILD_FROM_SOURCE"] && + ARGV.none? { |v| v.start_with?("--cc=") } && + ENV["HOMEBREW_PREFIX"] == "/usr/local" ISSUES_URL = "https://docs.brew.sh/Troubleshooting".freeze end PATH_OPEN = "/usr/bin/open".freeze From 3a0e0dca36aad66f61a082812c0b7b41e0737ffc Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 21 Jan 2019 12:39:44 +0000 Subject: [PATCH 4/6] Output more warnings on unsupported configurations --- Library/Homebrew/diagnostic.rb | 25 ++++++++-------- .../Homebrew/extend/os/linux/diagnostic.rb | 7 +++++ Library/Homebrew/extend/os/linux/install.rb | 4 +-- Library/Homebrew/extend/os/mac/diagnostic.rb | 13 ++++++-- Library/Homebrew/install.rb | 30 ++++++++++++++----- 5 files changed, 55 insertions(+), 24 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index c42bf31623..6d4db3f638 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -79,6 +79,10 @@ module Homebrew ].freeze end + def supported_configuration_checks + [].freeze + end + def development_tools_checks %w[ check_for_installed_developer_tools @@ -97,11 +101,10 @@ module Homebrew def please_create_pull_requests(what = "unsupported configuration") <<~EOS - You may encounter build failures and other breakages. - Please create pull requests instead of asking for help on - Homebrew's GitHub, Discourse, Twitter or IRC. You are - responsible for resolving any issues you experience, as - you are running this #{what}. + You will encounter build failures with some formulae. + Please create pull requests instead of asking for help on Homebrew's GitHub, + Discourse, Twitter or IRC. You are responsible for resolving any issues you + experience, as you are running this #{what}. EOS end @@ -118,10 +121,8 @@ module Homebrew return unless ENV["HOMEBREW_BUILD_FROM_SOURCE"] <<~EOS - You have HOMEBREW_BUILD_FROM_SOURCE set. This environment variable is - intended for use by Homebrew developers. If you are encountering errors, - please try unsetting this. Please do not file issues if you encounter - errors when using this environment variable. + You have HOMEBREW_BUILD_FROM_SOURCE set. + #{please_create_pull_requests} EOS end @@ -806,9 +807,9 @@ module Homebrew <<~EOS Your Homebrew's prefix is not #{Homebrew::DEFAULT_PREFIX}. - You can install Homebrew anywhere you want but some bottles (binary packages) - can only be used with a standard prefix and some formulae (packages) - may not build correctly with a non-standard prefix. + Some of Homebrew's bottles (binary packages) can only be used with the default + prefix (#{Homebrew::DEFAULT_PREFIX}). + #{please_create_pull_requests} EOS end diff --git a/Library/Homebrew/extend/os/linux/diagnostic.rb b/Library/Homebrew/extend/os/linux/diagnostic.rb index 1a89f9d956..061fe64bfb 100644 --- a/Library/Homebrew/extend/os/linux/diagnostic.rb +++ b/Library/Homebrew/extend/os/linux/diagnostic.rb @@ -7,6 +7,13 @@ require "os/linux/kernel" module Homebrew module Diagnostic class Checks + def supported_configuration_checks + %w[ + check_glibc_minimum_version + check_kernel_minimum_version + ].freeze + end + def check_tmpdir_sticky_bit message = generic_check_tmpdir_sticky_bit return if message.nil? diff --git a/Library/Homebrew/extend/os/linux/install.rb b/Library/Homebrew/extend/os/linux/install.rb index 91f043ac25..84b96ac060 100644 --- a/Library/Homebrew/extend/os/linux/install.rb +++ b/Library/Homebrew/extend/os/linux/install.rb @@ -26,8 +26,8 @@ module Homebrew FileUtils.ln_sf ld_so, brew_ld_so end - def perform_preinstall_checks - generic_perform_preinstall_checks + def perform_preinstall_checks(all_fatal: false) + generic_perform_preinstall_checks(all_fatal: all_fatal) symlink_ld_so end end diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index d433127500..6bbd51e551 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -1,12 +1,19 @@ module Homebrew module Diagnostic class Checks - undef development_tools_checks, fatal_development_tools_checks, - build_error_checks + undef supported_configuration_checks, development_tools_checks, + fatal_development_tools_checks, build_error_checks + + def supported_configuration_checks + %w[ + check_build_from_source + check_homebrew_prefix + check_for_unsupported_macos + ].freeze + end def development_tools_checks %w[ - check_for_unsupported_macos check_for_installed_developer_tools check_xcode_license_approved check_xcode_up_to_date diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 7b7fb88042..e5bd6e8459 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -17,6 +17,16 @@ module Homebrew end end + def check_cc_argv + return unless ARGV.cc + + @checks ||= Diagnostic::Checks.new + opoo <<~EOS + You passed `--cc=#{ARGV.cc}`. + #{@checks.please_create_pull_requests} + EOS + end + def attempt_directory_creation Keg::MUST_EXIST_DIRECTORIES.each do |dir| begin @@ -28,28 +38,34 @@ module Homebrew end def perform_development_tools_checks - fatal_checks(:fatal_development_tools_checks) + diagnostic_checks(:fatal_development_tools_checks) end - def perform_preinstall_checks + def perform_preinstall_checks(all_fatal: false) check_cpu attempt_directory_creation - fatal_checks(:fatal_install_checks) + check_cc_argv + diagnostic_checks(:supported_configuration_checks, fatal: all_fatal) + diagnostic_checks(:fatal_install_checks) end alias generic_perform_preinstall_checks perform_preinstall_checks module_function :generic_perform_preinstall_checks - def fatal_checks(type) + def diagnostic_checks(type, fatal: true) @checks ||= Diagnostic::Checks.new failed = false @checks.public_send(type).each do |check| out = @checks.public_send(check) next if out.nil? - failed ||= true - ofail out + if fatal + failed ||= true + ofail out + else + opoo out + end end - exit 1 if failed + exit 1 if failed && fatal end end end From 4ff0ecd44352d9297e510506d58b85dea8e5fc80 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 21 Jan 2019 12:39:54 +0000 Subject: [PATCH 5/6] =?UTF-8?q?gist-logs:=20don=E2=80=99t=20upload=20on=20?= =?UTF-8?q?unsupported=20configurations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/cmd/gist-logs.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb index 975acbd65d..a3f259d44c 100644 --- a/Library/Homebrew/cmd/gist-logs.rb +++ b/Library/Homebrew/cmd/gist-logs.rb @@ -134,6 +134,7 @@ module Homebrew def gist_logs raise FormulaUnspecifiedError if ARGV.resolved_formulae.length != 1 + Install.perform_preinstall_checks(all_fatal: true) gistify_logs(ARGV.resolved_formulae.first) end end From 234e4aec96297145e1760bc3d8ff6cc9f6f64713 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 21 Jan 2019 14:33:56 +0000 Subject: [PATCH 6/6] Improve use of default_prefix? in tests. --- Library/Homebrew/os/linux/global.rb | 2 +- Library/Homebrew/test/diagnostic_checks_spec.rb | 2 +- Library/Homebrew/test/support/lib/config.rb | 5 +++++ Library/Homebrew/test/utils/analytics_spec.rb | 11 +++++------ Library/Homebrew/utils/analytics.rb | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/os/linux/global.rb b/Library/Homebrew/os/linux/global.rb index 67d80e4560..39114fab57 100644 --- a/Library/Homebrew/os/linux/global.rb +++ b/Library/Homebrew/os/linux/global.rb @@ -1,5 +1,5 @@ module Homebrew - DEFAULT_PREFIX = if ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] + DEFAULT_PREFIX ||= if ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] "/usr/local".freeze else "/home/linuxbrew/.linuxbrew".freeze diff --git a/Library/Homebrew/test/diagnostic_checks_spec.rb b/Library/Homebrew/test/diagnostic_checks_spec.rb index 74f0b57ab0..06be59c5c4 100644 --- a/Library/Homebrew/test/diagnostic_checks_spec.rb +++ b/Library/Homebrew/test/diagnostic_checks_spec.rb @@ -164,7 +164,7 @@ describe Homebrew::Diagnostic::Checks do end specify "#check_homebrew_prefix" do - # the integration tests are run in a special prefix + allow(Homebrew).to receive(:default_prefix?).and_return(false) expect(subject.check_homebrew_prefix) .to match("Your Homebrew's prefix is not #{Homebrew::DEFAULT_PREFIX}") end diff --git a/Library/Homebrew/test/support/lib/config.rb b/Library/Homebrew/test/support/lib/config.rb index a5ad271801..6d6de3368e 100644 --- a/Library/Homebrew/test/support/lib/config.rb +++ b/Library/Homebrew/test/support/lib/config.rb @@ -41,3 +41,8 @@ PATCH_B_SHA256 = "57958271bb802a59452d0816e0670d16c8b70bdf6530bcf6f78726489ad89b TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze + +# For testing's sake always assume the default prefix +module Homebrew + DEFAULT_PREFIX = HOMEBREW_PREFIX.to_s.freeze +end diff --git a/Library/Homebrew/test/utils/analytics_spec.rb b/Library/Homebrew/test/utils/analytics_spec.rb index 3ec68224b4..29bdd04387 100644 --- a/Library/Homebrew/test/utils/analytics_spec.rb +++ b/Library/Homebrew/test/utils/analytics_spec.rb @@ -9,19 +9,18 @@ describe Utils::Analytics do end it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is a custom prefix" do - stub_const("HOMEBREW_PREFIX", "blah") + allow(Homebrew).to receive(:default_prefix?).and_return(false) expect(described_class.os_prefix_ci).to include("#{OS_VERSION}, #{described_class.custom_prefix_label}") end + it "does not include prefix when HOMEBREW_PREFIX is the default prefix" do + expect(described_class.os_prefix_ci).not_to include(described_class.custom_prefix_label) + end + it "includes CI when ENV['CI'] is set" do ENV["CI"] = "true" expect(described_class.os_prefix_ci).to include("CI") end - - it "does not include prefix when HOMEBREW_PREFIX is the default prefix" do - stub_const("HOMEBREW_PREFIX", Homebrew::DEFAULT_PREFIX) - expect(described_class.os_prefix_ci).not_to include(described_class.custom_prefix_label) - end end end diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 7283b5aece..31174451e1 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -16,7 +16,7 @@ module Utils def os_prefix_ci @os_prefix_ci ||= begin os = OS_VERSION - prefix = ", #{custom_prefix_label}" if Homebrew.default_prefix? + prefix = ", #{custom_prefix_label}" unless Homebrew.default_prefix? ci = ", CI" if ENV["CI"] "#{os}#{prefix}#{ci}" end