diff --git a/Library/Homebrew/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/artifact/abstract_uninstall.rb index 32bce9edad..2c8489828c 100644 --- a/Library/Homebrew/cask/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/artifact/abstract_uninstall.rb @@ -106,7 +106,7 @@ module Cask +"/Library/LaunchAgents/#{service}.plist", +"/Library/LaunchDaemons/#{service}.plist", ] - paths.each { |elt| elt.prepend(ENV["HOME"]).freeze } unless with_sudo + paths.each { |elt| elt.prepend(Dir.home).freeze } unless with_sudo paths = paths.map { |elt| Pathname(elt) }.select(&:exist?) paths.each do |path| command.run!("/bin/rm", args: ["-f", "--", path], sudo: with_sudo) diff --git a/Library/Homebrew/cask/artifact/relocated.rb b/Library/Homebrew/cask/artifact/relocated.rb index 17f2eceff4..612a0c7420 100644 --- a/Library/Homebrew/cask/artifact/relocated.rb +++ b/Library/Homebrew/cask/artifact/relocated.rb @@ -96,7 +96,7 @@ module Cask end def printable_target - target.to_s.sub(/^#{ENV['HOME']}(#{File::SEPARATOR}|$)/, "~/") + target.to_s.sub(/^#{Dir.home}(#{File::SEPARATOR}|$)/, "~/") end end end diff --git a/Library/Homebrew/cask/cask.rb b/Library/Homebrew/cask/cask.rb index 85a59c0582..fd23cafada 100644 --- a/Library/Homebrew/cask/cask.rb +++ b/Library/Homebrew/cask/cask.rb @@ -241,7 +241,7 @@ module Cask def to_h_string_gsubs(string) string.to_s - .gsub(ENV["HOME"], "$HOME") + .gsub(Dir.home, "$HOME") .gsub(HOMEBREW_PREFIX, "$(brew --prefix)") end diff --git a/Library/Homebrew/cask/config.rb b/Library/Homebrew/cask/config.rb index 9083ddbcd4..c99ac319da 100644 --- a/Library/Homebrew/cask/config.rb +++ b/Library/Homebrew/cask/config.rb @@ -190,7 +190,7 @@ module Cask key = "language" value = T.cast(explicit.fetch(:languages, []), T::Array[String]).join(",") end - "#{key}: \"#{value.to_s.sub(/^#{ENV['HOME']}/, "~")}\"" + "#{key}: \"#{value.to_s.sub(/^#{Dir.home}/, "~")}\"" end.join(", ") end diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index dedbc71e85..ef97876392 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -70,7 +70,7 @@ module Homebrew end def user_tilde(path) - path.gsub(ENV["HOME"], "~") + path.gsub(Dir.home, "~") end sig { returns(String) } @@ -766,7 +766,7 @@ module Homebrew end def check_for_pydistutils_cfg_in_home - return unless File.exist? "#{ENV["HOME"]}/.pydistutils.cfg" + return unless File.exist? "#{Dir.home}/.pydistutils.cfg" <<~EOS A '.pydistutils.cfg' file was found in $HOME, which may cause Python diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index ee2cae9dd0..30872d1fd0 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2433,7 +2433,7 @@ class Formula GOCACHE: "#{HOMEBREW_CACHE}/go_cache", GOPATH: "#{HOMEBREW_CACHE}/go_mod_cache", CARGO_HOME: "#{HOMEBREW_CACHE}/cargo_cache", - CURL_HOME: ENV["CURL_HOME"] || ENV["HOME"], + CURL_HOME: ENV.fetch("CURL_HOME") { Dir.home }, } end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index d2357b2fa5..ccaf1f23e8 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -904,7 +904,7 @@ class FormulaInstaller sandbox = Sandbox.new formula.logs.mkpath sandbox.record_log(formula.logs/"build.sandbox.log") - sandbox.allow_write_path(ENV["HOME"]) if interactive? + sandbox.allow_write_path(Dir.home) if interactive? sandbox.allow_write_temp_and_cache sandbox.allow_write_log(formula) sandbox.allow_cvs diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-user-relative.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-user-relative.rb index 1908663b4c..a1f97c3108 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-user-relative.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-user-relative.rb @@ -8,9 +8,9 @@ cask "with-uninstall-script-user-relative" do app "MyFancyApp/MyFancyApp.app", target: "~/MyFancyApp.app" postflight do - File.write "#{ENV["HOME"]}/MyFancyApp.app/uninstall.sh", <<~SH + File.write "#{Dir.home}/MyFancyApp.app/uninstall.sh", <<~SH #!/bin/sh - /bin/rm -r "#{ENV["HOME"]}/MyFancyApp.app" + /bin/rm -r "#{Dir.home}/MyFancyApp.app" SH end diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index eac31a7a5c..126a11544c 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -291,7 +291,7 @@ module Kernel ENV["HOMEBREW_DEBUG_INSTALL"] = f.full_name end - if ENV["SHELL"].include?("zsh") && (home = ENV["HOME"])&.start_with?(HOMEBREW_TEMP.resolved_path.to_s) + if ENV["SHELL"].include?("zsh") && (home = Dir.home).start_with?(HOMEBREW_TEMP.resolved_path.to_s) FileUtils.mkdir_p home FileUtils.touch "#{home}/.zshrc" end diff --git a/Library/Homebrew/utils/shell.rb b/Library/Homebrew/utils/shell.rb index 5547e00b05..b6663255db 100644 --- a/Library/Homebrew/utils/shell.rb +++ b/Library/Homebrew/utils/shell.rb @@ -49,7 +49,7 @@ module Utils def profile case preferred when :bash - bash_profile = "#{ENV["HOME"]}/.bash_profile" + bash_profile = "#{Dir.home}/.bash_profile" return bash_profile if File.exist? bash_profile when :zsh return "#{ENV["ZDOTDIR"]}/.zshrc" if ENV["ZDOTDIR"].present?