Can't install new Homebrew formula - macos

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 days ago.
Improve this question
(Homebrew version 3.6.21)
I'm trying to create and install a new formula, but when I try to install it Homebrew first tries to fetch the formula from Github, which of course fails because it's only on my local machine at the moment.
I'm trying to roll back to an old version of some software, so the new formula is named name#x.y.z. I initially tried editing the existing formula with brew edit, but found that Homebrew kept using the URLs for the newer version, even though I'd edited the formula - probably because it was fetching the formula from Github and using that instead of using my edited version.
Steps to reproduce:
brew create --set-name <formula-name> <some-url>
Edit the formula
brew install -s <formula-name>
Result:
==> Fetching <formula-name>
curl: (22) The requested URL returned error: 404
Error: Failure while executing; `/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl \
--disable \
--cookie /dev/null \
--globoff \
--show-error \
--user-agent Homebrew/3.6.21-164-ge42cae1\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.2\)\ curl/7.86.0 \
--header Accept-Language:\ en \
--fail \
--progress-bar \
--retry 3 \
--location \
--remote-time \
--output /Users/alastaid/Library/Caches/Homebrew/Formula/<formula-name>.rb \
https://raw.githubusercontent.com/Homebrew/homebrew-core/9a6a815e5ea0169b46e10f411ac3237740a6bbdf/Formula/<formula-name>.rb`
exited with 22. Here's the output:
curl: (22) The requested URL returned error: 404
How can I force Homebrew to use my edited / created formula instead of downloading from GitHub?
And if I edit a formula in the future, how do I prevent Homebrew from trying to re-download the formula I'm trying to test and overwriting my changes?

I believe this problem is due to the documentation not having been updated yet for homebrew v4.0. I can reproduce the problem based on your instructions, and here is my brew --version:
brew --version
Homebrew 4.0.3
Homebrew/homebrew-core (git revision 63589f1a8e3; last commit 2023-02-16)
Homebrew/homebrew-cask (git revision ce33115a81; last commit 2023-02-16)
It looks like there is a PR to update the documentation for v4.0, which says the following:
As you are developing, you'll also need to set HOMEBREW_NO_INSTALL_FROM_API=1 before any install commands, to force brew to use the local repository instead of the API.
So instead of your previous brew install command, run this:
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula-name>
I tried this and it got me past the failing download. You will probably still need to edit your formula to make sure it works correctly.

Related

opam init failure upon attempted OCaml installation on MacOS 10.14.16

I am attempting to install OCaml via the OCaml opam package manager on MacOs. I have successfully installed opam via homebrew. Initiating the package manager with opam init yields the following error:
[ERROR] Could not update repository "default":
OpamDownload.Download_fail(_, "Curl failed: \"/usr/bin/curl
--write-out %{http_code}\\\\n --retry 3 --retry-delay 2
--user-agent opam/2.1.0 -L -o
/private/var/folders/c_/6splkz692w16x82lzgnsxgfr0000gn/T/opam-57814-6b2069/index.tar.gz.part
-- https://opam.ocaml.org/index.tar.gz\" exited with code 60")
[ERROR] Initial download of repository failed.
What can I do to facilitate successful connection to the repository and initialise opam?
This error message indicates that curl is unable to establish the authenticity of the peer, i.e., https://opam.ocaml.org
This could happen because the certificates on either side are outdated. We can easily check if opam.ocaml.org is up-to-date, using one of the available online SSL checkers, e.g., this one says that they are OK. So it looks like that the problem is on your side.
First of all, you should try using your operating system upgrading options to get everything up-to-date.
If it is not an option, then you can use the --insecure option that you can pass using the OPAMFETCH environment variables. Or you can download the corresponding certificates and store a path to them in the ~/.curlrc, look here for more information.
I had the same problem and solved it by first running brew install wget and then opam init, which suddenly worked.
I ran into the same issue and I found a workaround on the OCaml forum: here. (Credits to UnixJunkie)
You can run:
opam init github git+https://github.com/ocaml/opam-repository.git
This should avoid the certificate issues.
I tried to use ivg's solution but must have made a mistake in moving the .pem files, so I couldn't get that solution to work. The workaround was quick.
Update
The reason opam init failed for me was because curl was installed with snap on my system.
Try to run opam init -verbose and that could reveal more about why you ran into an error.
In my case I needed to install other things with opam and it kept failing every time. So snap uninstall curl and then sudo apt install curl fixed things. (Was only able to figure this out with help from my professor)
Install curl first.
On MacOS: brew install curl
On Debian/Ubuntu Linux (and derivations): sudo apt-get install curl

Why doesn't "brew cleanup" or "brew cleanup -n" show any output? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I would love to clean my device of any homebrew update or version copies and then I figured that the command used for that would be
brew cleanup
and if I wanted to check how much of storage it would clear, the command would be
brew cleanup -n
brew cleanup --dry-run
None of them seem to work for me, and I want to clear my computer of any extra useless copies of Homebrew.
Also, would it be possible that it is actually happening but it is not showing me any output?
Here is the output:
temp#Apples-MacBook-Pro ~ % brew cleanup -n
temp#Apples-MacBook-Pro ~ % brew cleanup
temp#Apples-MacBook-Pro ~ %
All I need is some output showing how much space can be cleared / is cleared when I run the command.
Would it be possible that since I installed home-brew just yesterday, there is nothing to delete and hence this output?
It's probably because there is nothing to clean up (especially if you've only had Homebrew for 1 day).
I am not sure what you mean by "I want to clear my computer of any extra useless copies of home-brew." because that's not what brew cleanup is for. It's for deleting old and unused files downloaded by Homebrew during brew install. It's not for clearing old versions of Homebrew (that is automatically done when you do brew update).
~$ brew cleanup --help
Usage: brew cleanup [options] [formula|cask]
Remove stale lock files and outdated downloads for all formulae and casks, and
remove old versions of installed formulae. If arguments are specified, only do
this for the given formulae and casks. Removes all downloads more than 120 days
old. This can be adjusted with HOMEBREW_CLEANUP_MAX_AGE_DAYS.
--prune Remove all cache files older than specified
days.
-n, --dry-run Show what would be removed, but do not
actually remove anything.
-s Scrub the cache, including downloads for
even the latest versions. Note downloads
for any installed formulae or casks will
still not be deleted. If you want to delete
those too: rm -rf "$(brew --cache)"
--prune-prefix Only prune the symlinks and directories
from the prefix and remove no other files.
Notice the part of "Removes all downloads more than 120 days
old.". If you haven't installed that many things with Homebrew and/or you have not been using it for a long time, then it's expected that there is nothing to clean up. Also, even with the -s option, Homebrew does not delete files for "any installed formulae or casks".
Try installing and uninstall something, then do brew cleanup:
~$ brew install grep amazon-ecs-cli iterm2
...
~$ brew cleanup -s -n
~$
~$ brew uninstall grep amazon-ecs-cli iterm2
Uninstalling /usr/local/Cellar/grep/3.6... (21 files, 964.6KB)
Uninstalling /usr/local/Cellar/amazon-ecs-cli/1.21.0... (7 files, 46.2MB)
==> Uninstalling Cask iterm2
==> Backing App 'iTerm.app' up to '/usr/local/Caskroom/iterm2/3.4.3/iTerm.app'.
==> Removing App '/Applications/iTerm.app'.
==> Purging files for version 3.4.3 of Cask iterm2
~$ brew cleanup -s -n
Would remove: /Users/me/Library/Caches/Homebrew/amazon-ecs-cli--1.21.0.catalina.bottle.tar.gz (14.8MB)
Would remove: /Users/me/Library/Caches/Homebrew/grep--3.6.catalina.bottle.tar.gz (330.8KB)
Would remove: /Users/me/Library/Caches/Homebrew/Cask/iterm2--3.4.3.zip (21.3MB)
==> This operation would free approximately 36.4MB of disk space.
Notice that doing brew cleanup while those formulae are installed, it does not show any output. Only when they are uninstalled does it become something to clean.
Or try passing in the --prune=1 option (remove all cache files older than 1 day) and the -s option (scrub the cache, even for latest versions). On my system where I've had Homebrew for years:
~$ brew cleanup --prune=1 -s -n
...
==> This operation would free approximately 1.1GB of disk space.

How can I use a list of packages to determine whether or not I need to do apt-get update on Ubuntu 20.10? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am writing a numerous shell scripts, which depends on specific packages.
For example one of my scripts depends on ca-certificates and wget. If I have not yet run apt-get -y update, then I get the following errors:
Package ca-certificates is not available, but is referred to by
another package. This may mean that the package is missing, has been
obsoleted, or is only available from another source.
E: Package 'ca-certificates' has no installation candidate
E: Unable to locate package wget
I want to avoid running apt-get -y update on every script. Basically, I want to create a shortcut function which will do the following two things:
Run apt-get -y update only when necessary.
Install only the packages which are not installed/latest.
Here is my current function so far:
function install-packages()
{
apt-get -y update
apt-get install -y --no-install-recommends $#
}
install-packages ca-certificates wget
To check if package is installed or not do something like
dpkg -l | grep vlc | awk '{print $2}'
and to check if the package is available with apt and for apt-get search for similar option. It exist but I do not remember anyway all new distro use apt
apt list --upgradable | awk '{print $1}'
compare each row(package name) from above output to the package you are targeting in your script.
Your try to run apt update only when necessary is challenging. One thing is to run apt update when apt generate error which will solve the problem like you mentioned but as apt could have reported error with other things too so this method is so uneffective.
If all you trying to do is to prevent repeated execution of same package everytime you can create a file tracking the last time your program did update by
apt update -y && echo date > ~/.track
and then do update only when that time is greater than a certain period like 1 week for debian stable.
Edit:
Some folks said you can do something like
if [ -z "$(find /var/cache/apt/pkgcache.bin -mmin -60)" ]; then
apt-get update
fi
where -mmin -60 check for apt package list cache for last 1 hour. Adjust that value and you are good to go unless user or something don't write that file manually. Things can go bad also when some disk freeing application removes cache.

OpenCV3 installation on Mac

I tried to install OpenCV3 for Mac with the following command in terminal:
brew install opencv3 --with-contrib -with-ffmpeg
It repeatedly gets stuck at this point:
cmake .. -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE
Can someone please tell me how to fix this?
You need to install Xcode command line tools first. Go to the AppStore and download and install Xcode from Apple for free.
Then run:
xcode-select --install
to get make,cmake, and all the command-line development tools.
Also, consider adding the QuickTime back-end, by additionally specifying --with-qt5, i.e.:
brew install opencv3 --with-contrib -with-ffmpeg --with-qt5
That gives you extra options to save the images you generate and display with the highgui module.
I also had the exact same issue. Someone else had also reported this problem on the brew github, but they could also not reproduce the issue. In my case though, it would go a step further and get stuck after calling make for hours:
cmake .. -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE
make
I went ahead and tracked the processes in the Activity Monitor on my Mac and found out that it kicks off a batch of clang processes in sequence on multiple threads. But I had several apps running that were robbing it of CPU and Memory resources. So I shut down Safari, Finder, IDEs (XCode, PyCharm) etc, and this time it did complete.
Solution: was to just let it run with as much CPU and memory overhead it needs. And with no other power-hungry apps running in the background, it finished in 25mins.
CMake Approach:
Your next best approach is to bypass using package manager, like brew, and follow the instructions given on PyImageSearch to build OpenCV manually using CMake:
Install dependencies like CMake, pkg-config (and possibly others...)
Clone OpenCV and OpenCV_Contrib git repos:
https://github.com/opencv/opencv
https://github.com/opencv/opencv_contrib
Checkout version [e.g. 3.2.0]
Make build directory inside opencv directory
Run CMake with the appropriate parameters for your system:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local/opencv3 \
-D PYTHON2_PACKAGES_PATH=/usr/local/lib/python2.7/site-packages \
-D PYTHON2_LIBRARY=/usr/local/opt/python/bin \
-D PYTHON2_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers \
-D BUILD_OPENCV_PYTHON2=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=/Users/Salman_Naqvi/Downloads/opencv_contrib/modules ..
Compile using: make -j4
Install it on MacOS: make install
--> It'll be installed in the directory specified by: CMAKE_INSTALL_PREFIX=/usr/local/opencv3

Location of GCC binary in installing VM tools [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am trying to install VM tools in Debian linux which is having trouble finding the gcc binaries. I am trying to install the binaries, as shown in selected answer on this page:
installing vmware tools: location of GCC binary?
However, in these commands:
sudo aptitude install gcc-4.7 make linux-headers-`uname -r` -y
sudo apt-get install build-essential
sudo apt-get install gcc-4.7 linux-headers-`uname -r`
the system is asking me to insert the Official amd64 binary in the CDROM and then press enter.
My debian in running on a VM over windows. Not sure where to get this thing and fix this problem. Please advise.
Debian uses apt to install packages. (apt-get or aptitude are front-ends to the apt systems).
whenever you ask the system to install a given package, it will first need the actual package files. now apt can fetch the requested packages from a number of different places, including read-only media (like CDROMs or DVDs) or the internet (via http or ftp).
these "places" can be configured in the /etc/apt/sources.list file.
if you have installed Debian from the set of CDROMs, then your sources.list will tell apt, that it can get package files from the cdrom-drive. obviously you need to have the correct CDROM inserted in your drive.
on a virtual machine, you will find that you can use ISO-images of the files and tell your virtualization software (vmware) to make a given ISO available to the client.
however, the usual way is to add an "internet ressource" to sources.list, so you don't need to juggle with CDROM (images) and you will always get any bugfixes. obviously your machine will need to be online for this to work.
add an official online debian repository to your sources. the following uses http://http.debian.net which should automatically use a mirror that is physically close to your machine:
echo "deb http://http.debian.net/debian $(lsb_release -c | awk '{print $2}') main" | sudo tee -a /etc/apt/sources.list
then update the cache
sudo aptitude update
and install the required package(s)
sudo aptitude install build-essential

Resources