从Intel版本MacBook Pro 2013迁移到MacBook Pro 2023(Apple M2 Pro)后HomeBrew报错"Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)"

通过 TimeMachineIntel 版本 MacBook Pro 2013 迁移到 MacBook Pro 2023(Apple M2 Pro)HomeBrew 报错,如下:

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
  https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
  brew bundle dump

该报错的原因是 HomeBrew 修改了 Apple ARM 版本的设备上的默认目录,默认目录从 /usr/local 调整到了 /opt/homebrew

由于大量的路径被硬编码到了代码中,结果就导致各种运行、安装异常。

我们能做的就是,重新在 /opt/homebrew目录下安装一遍。

# 导出环境配置,和已经通过brew安装的应用列表,为后续重新安装这些应用进行准备
$ brew bundle dump

# 执行完成后,当前目录下生成的 Brewfile 就是我们已经安装的应用列表,后续可以执行这个脚本进行恢复安装

# 卸载已经安装的 HomeBrew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

# 移除整个 /usr/local 目录,此处谨慎操作,只有确保没有与homebrew无关的应用没有安装到这个目录下才能执行删除操作
# sudo rm -rf /usr/local

# 重新安装 HomeBrew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# 把路径增加到环境变量中,比如 .bashrc

$ export PATH="/opt/homebrew/bin:$PATH"

# 重新配置HomeBrew 并安装之前的软件
$ brew bundle --file=Brewfile

参考链接


Error: Your CLT does not support macOS 11.0.

最近系统升级到macOS Big Sur(11.0.1)之后,系统报告如下错误:

$ brew upgrade

...........................................

==> Upgrading 5 outdated packages:
tomcat 9.0.39 -> 9.0.40
gradle 6.7 -> 6.7.1
opencv 4.5.0_3 -> 4.5.0_4
vtk 9.0.1_1 -> 9.0.1_2
imagemagick 7.0.10-38 -> 7.0.10-39
==> Upgrading tomcat 9.0.39 -> 9.0.40 
==> Downloading https://www.apache.org/dyn/closer.lua?path=tomcat/tomcat-9/v9.0.
==> Downloading from https://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.40/bi
######################################################################## 100.0%
Error: Your CLT does not support macOS 11.0.
It is either outdated or was modified.
Please update your CLT or delete it if no updates are available.
Error: An exception occurred within a child process:
  SystemExit: exit

解决方案如下:

$ sudo rm -rf /Library/Developer/CommandLineTools

$ sudo xcode-select --install

参考链接


fatal: could not read Username for 'https://github.com': terminal prompts disabled

最近更新`HomeBrew`的时候,一直报错,如下:

$ brew update
fatal: could not read Username for 'https://github.com': terminal prompts disabled

执行

$ git config --global --add url."git@github.com:".insteadOf "https://github.com/"

$ brew update
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!
homebrew/homebrew-science does not exist! Run `brew untap homebrew/homebrew-science` to remove it.
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions failed!
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services failed!

执行如下命令即可:

$ brew untap homebrew/homebrew-science

$ brew untap homebrew/homebrew-cask-versions

$ brew untap homebrew/homebrew-services

$ git config --global --remove-section url."git@github.com:"

参考链接


Git Error: Could could not read Username for 'https://github.com': terminal prompts disabled

macOS Catalina 10.15.2安装配置WordPress 5.3.2并建立PHP调试环境

macOS Catalina 10.15.2 自带的 Apache2PHP 在配置的时候,非常困难,而且不管如何配置,都没办法跟 MySQL 数据库连接,总之会出现各种问题,而且各种插件安装异常麻烦。

尝试过使用 brew 安装 MySQLXAMPP,但是也是都没办法成功配置。macOS系统更改了太多的东西,各种不方便啊。

最后还是使用 XAMPP-VM 或者干脆搭建一个 VirtualBox 虚拟机在 Linux 下进行开发吧。

下面,我们介绍一下使用 XAMPP-VM 进行开发的方法。

继续阅读macOS Catalina 10.15.2安装配置WordPress 5.3.2并建立PHP调试环境

macOS Mojave(10.14.4)系统Octave 5.1.0使用pause()函数无法响应按键事件

目前 ( 2019/04/24 ),在 `macOS Mojave` (`10.14.4`)系统上使用 `brew install octave` ,安装 `Octave 5.1.0` 之后,使用 `pause()` 函数无法在点击键盘之后继续执行,除了 `Ctrl + C` 之外任意键都不响应。正常情况下,点击任意按键之后,应该继续执行后续的代码。

这个是目前使用 `brew` 安装的 `Octave 5.1.0` 在编译的时候,关联的库是 `glibc 2.28` 之后的版本。这个版本上 `glibc 2.28` 的某些行为发生变动。具体的讨论信息,参考 bug #55029: pause() with no arguments does not return like kbhit() with glibc 2.28 上的讨论。本质就是 `glibc 2.28` 之后的版本要求应用程序在接收信息结束( `EOF` )之后,主动调用 `clearerr (stdin);` ,否则会收不到后续的按键通知。这个 `BUG` 在 `Octave 5.2` 版本被修复,但是这个版本何时发布,暂时不定。

目前的修复方式为要求 `brew` 从最新版本的代码编译安装,而不是安装已发布版本,如下:

$ brew uninstall --ignore-dependencies octave

# 安装编译依赖
$ brew install texinfo

$ wget https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/octave.rb

$ sed -i "" "s/\"--enable-shared\"/\"--enable-shared\",\"--disable-docs\"/g" octave.rb

$ brew install --build-from-source --HEAD -v octave.rb

修改下载的编译配置文件,并且关闭文档编译( 目前文档编译会失败),也就是增加  `--disable-docs` 这个编译参数。

调整之后的编译脚本如下:

class Octave < Formula
  desc "High-level interpreted language for numerical computing"
  homepage "https://www.gnu.org/software/octave/index.html"
  url "https://ftp.gnu.org/gnu/octave/octave-5.1.0.tar.xz"
  mirror "https://ftpmirror.gnu.org/octave/octave-5.1.0.tar.xz"
  sha256 "87b4df6dfa28b1f8028f69659f7a1cabd50adfb81e1e02212ff22c863a29454e"
  revision 2

  bottle do
    sha256 "6bb8497839d6f7872efcd6acad0216f443420e097a9b7fad44835823e1c0e735" => :mojave
    sha256 "d1de53a30f002d8b7ec3a6065994c46d8cbd4830aa7e199f572baff48723c6e6" => :high_sierra
    sha256 "7a648cff129ec85a5ee9417a0339a3b804756f7958585b707c015d322d220b15" => :sierra
  end

  head do
    url "https://hg.savannah.gnu.org/hgweb/octave", :branch => "default", :using => :hg

    depends_on "autoconf" => :build
    depends_on "automake" => :build
    depends_on "bison" => :build
    depends_on "icoutils" => :build
    depends_on "librsvg" => :build
  end

  # Complete list of dependencies at https://wiki.octave.org/Building
  depends_on "gnu-sed" => :build # https://lists.gnu.org/archive/html/octave-maintainers/2016-09/msg00193.html
  depends_on :java => ["1.6+", :build]
  depends_on "pkg-config" => :build
  depends_on "arpack"
  depends_on "epstool"
  depends_on "fftw"
  depends_on "fig2dev"
  depends_on "fltk"
  depends_on "fontconfig"
  depends_on "freetype"
  depends_on "gcc" # for gfortran
  depends_on "ghostscript"
  depends_on "gl2ps"
  depends_on "glpk"
  depends_on "gnuplot"
  depends_on "graphicsmagick"
  depends_on "hdf5"
  depends_on "libsndfile"
  depends_on "libtool"
  depends_on "pcre"
  depends_on "portaudio"
  depends_on "pstoedit"
  depends_on "qhull"
  depends_on "qrupdate"
  depends_on "qt"
  depends_on "readline"
  depends_on "suite-sparse"
  depends_on "sundials"
  depends_on "texinfo"
  depends_on "veclibfort"

  # Dependencies use Fortran, leading to spurious messages about GCC
  cxxstdlib_check :skip

  def install
    # Default configuration passes all linker flags to mkoctfile, to be
    # inserted into every oct/mex build. This is unnecessary and can cause
    # cause linking problems.
    inreplace "src/mkoctfile.in.cc",
              /%OCTAVE_CONF_OCT(AVE)?_LINK_(DEPS|OPTS)%/,
              '""'

    # Qt 5.12 compatibility
    # https://savannah.gnu.org/bugs/?55187
    ENV["QCOLLECTIONGENERATOR"] = "qhelpgenerator"
    # These "shouldn't" be necessary, but the build breaks without them.
    # https://savannah.gnu.org/bugs/?55883
    ENV["QT_CPPFLAGS"]="-I#{Formula["qt"].opt_include}"
    ENV.append "CPPFLAGS", "-I#{Formula["qt"].opt_include}"
    ENV["QT_LDFLAGS"]="-F#{Formula["qt"].opt_lib}"
    ENV.append "LDFLAGS", "-F#{Formula["qt"].opt_lib}"

    system "./bootstrap" if build.head?
    system "./configure", "--prefix=#{prefix}",
                          "--disable-dependency-tracking",
                          "--disable-silent-rules",
                          "--enable-link-all-dependencies",
                          "--enable-shared","--disable-docs",
                          "--disable-static",
                          "--with-hdf5-includedir=#{Formula["hdf5"].opt_include}",
                          "--with-hdf5-libdir=#{Formula["hdf5"].opt_lib}",
                          "--with-x=no",
                          "--with-blas=-L#{Formula["veclibfort"].opt_lib} -lvecLibFort",
                          "--with-portaudio",
                          "--with-sndfile"
    system "make", "all"

    # Avoid revision bumps whenever fftw's or gcc's Cellar paths change
    inreplace "src/mkoctfile.cc" do |s|
      s.gsub! Formula["fftw"].prefix.realpath, Formula["fftw"].opt_prefix
      s.gsub! Formula["gcc"].prefix.realpath, Formula["gcc"].opt_prefix
    end

    # Make sure that Octave uses the modern texinfo at run time
    rcfile = buildpath/"scripts/startup/site-rcfile"
    rcfile.append_lines "makeinfo_program(\"#{Formula["texinfo"].opt_bin}/makeinfo\");"

    system "make", "install"
  end

  test do
    system bin/"octave", "--eval", "(22/7 - pi)/pi"
    # This is supposed to crash octave if there is a problem with veclibfort
    system bin/"octave", "--eval", "single ([1+i 2+i 3+i]) * single ([ 4+i ; 5+i ; 6+i])"
  end
end

参考链接


brew报告错误“fatal: unable to access 'https://aomedia.googlesource.com/aom.git/': Failed to connect to aomedia.googlesource.com port 443: Operation timed out”

最近在使用 `brew` 升级应用的时候,报告如下错误:

$ brew upgrade
Warning: You are using macOS 10.11.
We (and Apple) do not provide support for this old version.
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 old version.

==> Upgrading 7 outdated packages:
doxygen 1.8.14 -> 1.8.15, ffmpeg 4.0.2 -> 4.1.3, ilmbase 2.2.1 -> 2.3.0, libpng 1.6.36 -> 1.6.37, lz4 1.8.3 -> 1.9.0, opencv 3.4.2 -> 4.1.0_1, openexr 2.2.0_1 -> 2.3.0
==> Upgrading libpng 
==> Downloading https://downloads.sourceforge.net/libpng/libpng-1.6.37.tar.xz
==> Downloading from https://jaist.dl.sourceforge.net/project/libpng/libpng16/1.
######################################################################## 100.0%
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/libpng/1.6.37
==> make
==> make test
==> make install
?  /usr/local/Cellar/libpng/1.6.37: 27 files, 1.2MB, built in 3 minutes 59 seconds
Removing: /usr/local/Cellar/libpng/1.6.36... (28 files, 1.2MB)
Removing: /Users/xxxx/Library/Caches/Homebrew/libpng--1.6.36.tar.xz... (0B)
==> Upgrading ffmpeg 
==> Installing dependencies for ffmpeg: aom, frei0r, libtasn1, nettle, libffi, p11-kit, libevent, unbound, gnutls, fribidi, ninja, meson, glib, pixman, cairo, gobject-introspection, graphite2, harfbuzz, libass, libbluray, libsoxr, opencore-amr, doxygen, little-cms2, openjpeg, rtmpdump, flac, libsndfile, libsamplerate, rubberband, speex, autoconf-archive, giflib, webp, leptonica, tesseract and x265
==> Installing ffmpeg dependency: aom
==> Cloning https://aomedia.googlesource.com/aom.git
Cloning into '/Users/xxxx/Library/Caches/Homebrew/aom--git'...
fatal: unable to access 'https://aomedia.googlesource.com/aom.git/': Failed to connect to aomedia.googlesource.com port 443: Operation timed out
Error: An exception occurred within a child process:
  DownloadError: Failed to download resource "aom"
Failure while executing; `git clone --branch v1.0.0 https://aomedia.googlesource.com/aom.git /Users/xxxx/Library/Caches/Homebrew/aom--git` exited with 128. Here's the output:
Cloning into '/Users/xxxx/Library/Caches/Homebrew/aom--git'...
fatal: unable to access 'https://aomedia.googlesource.com/aom.git/': Failed to connect to aomedia.googlesource.com port 443: Operation timed out

众所周知的原因,很早之前,就已经不能访问 `Google` 的服务器了,因此这个错误是正常现象。

解决方法如下:

$ wget https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/aom.rb

# 用本站提供的一份代码拷贝来替代原来的地址
$ sed -i "" "s/https:\/\/aomedia\.googlesource\.com\/aom\.git/https:\/\/www.mobibrw.com\/wp-content\/uploads\/2019\/04\/aom.zip/g" aom.rb

$ brew uninstall --ignore-dependencies aom

$ brew install --build-from-source aom.rb --env=std

参考链接


OS X EI Capitan(10.11.6)执行brew upgrade cmake 升级到cmake-3.14.2/cmake-3.17.3报告错误“make: *** [all] Error 2”

$ brew upgrade cmake
Updating Homebrew...
Warning: You are using macOS 10.11.
We (and Apple) do not provide support for this old version.
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 old version.

==> Upgrading 1 outdated package:
cmake 3.12.0 -> 3.14.2
==> Upgrading cmake 
==> Downloading https://github.com/Kitware/CMake/releases/download/v3.14.2/cmake
Already downloaded: /Users/xxxx/Library/Caches/Homebrew/downloads/348cde1c4453dba1e5e72e9bb6ae7cd45fffb907d265cd06efd513841eda8541--cmake-3.14.2.tar.gz
==> ./bootstrap --prefix=/usr/local/Cellar/cmake/3.14.2 --no-system-libs --paral
==> make
Last 15 lines from /Users/xxxx/Library/Logs/Homebrew/cmake/02.make:
[ 23%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/frm_req_name.c.o
[ 23%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/frm_scale.c.o
[ 24%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/frm_sub.c.o
[ 24%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/frm_user.c.o
[ 24%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/frm_win.c.o
[ 24%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_alnum.c.o
[ 24%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_alpha.c.o
[ 24%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_enum.c.o
[ 24%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_int.c.o
[ 25%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_ipv4.c.o
[ 25%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_num.c.o
[ 25%] Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_regex.c.o
[ 25%] Linking C static library libcmForm.a
[ 25%] Built target cmForm
make: *** [all] Error 2

Do not report this issue to Homebrew/brew or Homebrew/core!


Error: You are using macOS 10.11.
We (and Apple) do not provide support for this old version.
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 old version.

查看日志`/Users/xxxx/Library/Logs/Homebrew/cmake/02.make`,内容如下:

继续阅读OS X EI Capitan(10.11.6)执行brew upgrade cmake 升级到cmake-3.14.2/cmake-3.17.3报告错误“make: *** [all] Error 2”

macOS High Sierra(10.13.6)解决"Error: Running Homebrew as root is extremely dangerous and no longer supported."

macOS High Sierra(10.13.6)版本上,使用Homebrew安装python2的时候出现如下问题:

$ brew install python2
Warning: python@2 2.7.15_1 is already installed, it's just not linked
You can use `brew link python@2` to link this version.

$ brew link python@2
Linking /usr/local/Cellar/python@2/2.7.15_1... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

$ sudo brew link python@2
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

网上的解决方法是把整个/usr/local的所有者修改为当前用户,但是新版本的macOS High Sierra(10.13.6)已经不支持这样操作了,如下:

$ sudo chown -R `whoami` /usr/local
chown: /usr/local: Operation not permitted

那么解决方法如下:

$ sudo chown -R `whoami` /usr/local/Homebrew/

$ sudo chown -R $(whoami) $(brew --prefix)/*

$ sudo mkdir /usr/local/Frameworks

$ sudo chown -R `whoami` /usr/local/Frameworks/

完成上面的操作后,我们可以看到已经能成功操作了:

$ brew link python@2
Linking /usr/local/Cellar/python@2/2.7.15_1... 5 symlinks created

#如果曾经安装过pip可能导致pip被链接到系统的python版本,可是系统目录上各种无权限,因此我们移除已经安装的pip,重新链接pip到brew安装的python

$ sudo rm -rf /usr/local/bin/pip

$ brew reinstall python2

参考链接


macOS High Sierra下使用brew安装支持x265的ffmpeg以及转码

使用

$ brew install ffmpeg

安装ffmpeg默认是不支持x265

使用

$ brew reinstall ffmpeg --with-x265

重新安装即可。

一般直接的H265数据流(比如从摄像头抓取的H265裸数据流保存的文件),是没办法在MacOS上直接播放的,必须进行转码。简单的转码命令如下:

$ ffmpeg -i input.h265 -c:v libx265 output.mp4

参考链接