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

Warn more on unsupported configurations #5571

Merged
merged 6 commits into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Library/Homebrew/cmd/gist-logs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def create_issue(repo, title, body)
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
27 changes: 14 additions & 13 deletions Library/Homebrew/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def fatal_install_checks
].freeze
end

def supported_configuration_checks
[].freeze
end

def development_tools_checks
%w[
check_for_installed_developer_tools
Expand All @@ -97,11 +101,10 @@ def build_error_checks

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

Expand All @@ -118,10 +121,8 @@ def check_build_from_source
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

Expand Down Expand Up @@ -802,13 +803,13 @@ def check_for_tap_ruby_files_locations
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}.
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

Expand Down
7 changes: 7 additions & 0 deletions Library/Homebrew/extend/os/linux/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
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?
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/extend/os/linux/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def symlink_ld_so
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
Expand Down
54 changes: 10 additions & 44 deletions Library/Homebrew/extend/os/mac/diagnostic.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
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 development_tools_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_installed_developer_tools
check_xcode_license_approved
check_xcode_up_to_date
check_clt_up_to_date
check_for_other_package_managers
].freeze
end

Expand Down Expand Up @@ -136,21 +142,6 @@ def check_if_xcode_needs_clt_installed
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
Expand Down Expand Up @@ -200,19 +191,6 @@ def check_xcode_select_path
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.
Expand All @@ -236,18 +214,6 @@ def check_xquartz_up_to_date
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,
Expand Down
30 changes: 23 additions & 7 deletions Library/Homebrew/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ def check_cpu
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
Expand All @@ -28,28 +38,34 @@ def attempt_directory_creation
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
Expand Down
8 changes: 6 additions & 2 deletions Library/Homebrew/os.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ def self.linux?

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
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/os/linux/global.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/diagnostic_checks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
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
Expand Down
13 changes: 0 additions & 13 deletions Library/Homebrew/test/os/mac/diagnostic_spec.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -15,13 +9,6 @@
.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)
Expand Down
5 changes: 5 additions & 0 deletions Library/Homebrew/test/support/lib/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@

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
11 changes: 5 additions & 6 deletions Library/Homebrew/test/utils/analytics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
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

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/utils/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def clear_os_prefix_ci
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}" unless Homebrew.default_prefix?
ci = ", CI" if ENV["CI"]
"#{os}#{prefix}#{ci}"
end
Expand Down