Can anybody tell how to install gcc in m1 MacBook Air? - macos

there
Actually I've recently buy an MacBook Air, And I try to install gcc on my MacBook and I've already installed VS Code on it and after I installed home brew then when I typed brew install gcc...
Then it throw an error i.e. :
zsh: command not found: Brew
Can you help me ?

So your trying to install something that's based on a bash script? If so go into SysPref>User's, unlock, then right click on the Admin or Login goto advanced options and login shell. Or there's this chsh -s /bin/bash. That came from here

So actually you are getting the error "zsh: command not found: Brew"
So it is not the error of gcc it means brew is not installed on your system.
First you have to install that using this cmd:
[/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After that you can run brew install gcc which will work fine then!

Related

Impossible to install Homebrew on a Macbook M1 Pro

My company provided me with a new Macbook pro (14", 2021, Monterey 12.6) and this is my first macbook.
I am trying to install Flutter + Dart, but for that I require Homebrew.
I tried following the official guide to install Homebrew, but I am stuck at the is line:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
When attempting to execute the command, this is how my shell looks like:
there is no password prompt
nothing happens, it just stay that way indefinitely
the terminal window bar changed for "curl + zsh"
Why is it not working? Could it be a security restriction from my company?

Homebrew doesn't stay installed? M1 Macbook

I've upgraded to an M1 Macbook Pro and need to reinstall all of the goodies that I use regularly.
This includes Homebrew.
I have been to the official Homebrew site and done what they suggest:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
It then suggests to run
echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /Users/username/.bash_profile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/username/.bash_profile
eval "$(/opt/homebrew/bin/brew shellenv)"
To keep it within the path for future use - I would think this was the thing that keeps it being reusable when you restart/get a new Terminal
And this works great. I can then use brew install xxx after installation to install whatever packages I require.
The issue comes when I get a new Terminal or restart etc. I go to perform another brew install and I get the annoying
-bash: brew: command not found
Is there something that I've not done after the initial install that means my Mac doesn't remember it's installed brew?
I was running into the same issue as you. My issue was my terminal was set to bash instead of zsh by default. I had to run chsh -s /bin/zsh and followed the top answer on another post, which is similar if not identical to the steps you include in your question. I restarted my terminal and ran through brew help worked!

How to run the Homebrew installer under Rosetta 2 on M1 Macbook

I'm on the M1 MacBook.
This is the error when I try to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Homebrew is not (yet) supported on ARM processors!
Rerun the Homebrew installer under Rosetta 2.
If you really know what you are doing and are prepared for a very broken experience you can use another installation option for installing on ARM:
https://docs.brew.sh/Installation
So how do I "Rerun the Homebrew installer under Rosetta 2."?
Got an answer from a developer in the Homebrew github https://github.com/Homebrew/brew/issues/9173
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Use this to install packages:
arch -x86_64 brew install <package>
If you have not yet installed Rosetta 2 to emulate Intel CPUs on ARM Macs, you will get the error arch: posix_spawnp: /bin/bash: Bad CPU type in executable. Prompt a Rosetta 2 installation with:
softwareupdate --install-rosetta
I have two instances of brew installed, the Intel version that runs using Rosetta2 and which installs to /usr/local/bin and the Arm version that runs natively and installs to /opt/homebrew/bin. Now it is all working, I do not have to start iTerm using Rosetta.
I have these aliases to reach the two versions.
ibrew='arch -x86_64 /usr/local/bin/brew'
mbrew='arch -arm64e /opt/homebrew/bin/brew'
I have the native version in my path first:
path=( /opt/homebrew/bin /opt/homebrew/opt /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin )
Now I can try mbrew search and mbrew install. If they work, I am good to go with a native program. For example:
mbrew install ag
If brew fails I try building from source, with verbose output, e.g.
mbrew install -sv rust
Be warned, this takes a while and may still fail.
If it still fails, (and mbrew install -sv go results in a segmentation fault for me) I have two choices. Use ibrew search and ibrew install to get the Intel build instead, or examine the verbose output and look for problem dependencies. In some cases an install -s on the dependencies is enough to get the native brew to work.
I must stress that native brew always prints this warning
Warning: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it.
So proceed at your own discretion.
For completeness, and assuming you have iTerm2, Rosetta2 and the Xcode command line tools installed, I did this to install brew under Rosetta (with credit to all those who have posted on this page before me):
Copy the installed iTerm2.app application to iRosetta2.app
Press command+I to Get Info for iRosetta.app, click Open Using Rosetta2
Run iRosetta2 and use this command from https://brew.sh
Like so
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)
alias ibrew='arch -x86_64 /usr/local/bin/brew' # put this in ~/.zshrc
And I did this to install native brew, taken from other contributors to Stack Overflow and the Homebrew alternative installation site, using iTerm2 without Open Using Rosetta2
mkdir ~/homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
sudo mv ~/sudo mv homebrew /opt
mbrew='arch -arm64e /opt/homebrew/bin/brew' # for .zshrc
export PATH="/opt/homebrew/bin:/opt/homebrew/opt:$PATH" # also for .zshrc
Edit
Time has passed and I have changed the architecture to arm64e following Fernando García Redondo observation. Now the warning about Arm architecture not supported has gone and Rust and Go install without problems and without compiling from source. I assume the good people at Homebrew have been working hard over Christmas. Thanks!
Edit Feb 21
The Homebrew team have announced that they support Apple silicon. So I wondered if I could delete my aliases and just use brew to install for Apple silicon. The short answer is no! if you run brew from /usr/local without the arch -x86_64, it complains that /usr/local is reserved as the Intel default prefix and using /opt/homebrew is required. So I will retain my two aliases and try mbrew first and only use ibrew if the native brew fails.
Another option is by going into your applications in Finder, select Terminal and press ⌘+I and check the "Open using Rosetta" option.
Sorry if the formatting is off, first time posting a solution.
The easiest way to run Homebrew is with Rosetta 2.
1. Duplicate Your Favourite Terminal for Rosetta
Find your favourite terminal, right-click to duplicate it, and rename it for easier identification. In this example, I'm using the default Terminal app on Big Sur 11.2.1.
Right-click the Terminal Rosetta and go to Get Info to check the Open using Rosetta option.
2. Install Homebrew
Open the rosetta terminal and run the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Running this command will ask you for the password, and then it will provide you with the information of what all it will install and which new directories it will create.
3. Using Homebrew
Once HomeBrew is installed, you can start using it to install your required packages into the M1 Mac.
Run the following command to get brew help:
brew help
To install a package, you can run the following command:
brew install packagename
That’s all about installing and getting started with Homebrew on Apple M1 Macs.
EDIT: Thanks all! Upvote to help other devs! Homebrew 3.0.0 now officially supports Apple Silicon (https://brew.sh/2021/02/05/homebrew-3.0.0/)
After I installed Rosetta, I added an alias so I can use brew install <package> as I would normally.
alias brew='arch -x86_64 brew'
I agree with everyone else in that you need to add the arch -x86_64 in front of the original command so thought to include that alias to help anyone finding this thread in the future
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" worked on my new M1 Mac
Do below
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
alias brew='arch -x86_64 brew'
brew install azure-cli
now try az login. you are good to go
You can change the setting of Terminal to launch it using Rosetta.
Go to your Application/Utilities folder, right click on the Terminal App and check the tick box 'Open using Rosetta'
But to be honest, I have Homebrew installed without Rosetta. Just removed the x86 version yesterday and installed a fresh version without Rosetta.

Mac - Can't Install HomeBrew because Curl is Missing

I tried to install homebrew onto my mac, but I couldn't because curl wasn't found. I typed:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This returned this error:
-bash: curl: command not found
So, I tried to install curl but apparently to install curl, I need to use curl? This is what I found:
Run in Terminal app:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" <
/dev/null 2> /dev/null
Run:
brew install curl
Done! You can now use curl.
However, this uses curl to install curl, so it gives the same error message: -bash: curl: command not found
TL;DR, how do I install curl on mac without using curl
I solved the problem!
To use bash on mac:
Go to terminal ––> preferences
Click on Shells open with: and set it to Command (complete path)
Enter one of the following:
/bin/bash
/bin/csh
/bin/zsh
/bin/zsh-4.0.4 (Mac OS X 10.2.8 or earlier)
/bin/zsh-4.1.1 (Mac OS X 10.3 or later)
/bin/ksh (Mac OS X 10.4 or later)
/bin/ksh worked for me
Source
I thought I broke my curl symlink somehow too, and somewhere in there I ran into your same issue, where no command would work. Somewhere in this mess, I fixed it.
https://brew.sh/
The main website requires you to install wget, maybe it gets deleted when you uninstall homebrew.
Regardless I found a way to install it using Ubuntu commands.
https://xmrig.com/docs/miner/build/ubuntu
but ran into an issue where I had to download cmake from the developer website and add it to the path in it's menu options on Mac OS X 10.11 to compile and run my program as ./program instead of program, then I installed macports(opened a new terminal window), and installed hwloc with macports, to no avail, just getting totally different errors.
I've also tried to add curl as an alias of curl into the bash profile and it recognized the error after I used this;
https://github.com/Homebrew/homebrew-core/issues/5084
However, I forgot I have an identical computer that is working just fine, but when I run "which curl", in the working computer, I get /usr/bin/curl, instead of /usr/local/bin/curl, so I ran
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin/curl"
I'm still getting the error, so I used vim, to sudo edit the /etc/paths file by using
sudo vim /etc/paths
i for edit
esc to exit edit mode
:x to save
Restart Terminal
Still getting a 403 SNI Error cannot download Python 3.9
rm -rf /opt/local/bin/curl
rm -rf /usr/local/bin/curl
which curl finally returns the correct path, /usr/bin/curl
exit
Restart Terminal
Still same error so I removed /usr/bin/curl from /etc/paths, and export file. Also deleted the bash profile, as the working computer doesn't return one, and...still the same error, so I conclude that "curl is not in path" should be ignored.
I did get brew doctor to return with no errors.
brew upgrade curl
curl not installed
brew install curl
403 Error SNI is required.
brew upgrade openssl
openssl 1.1.1j already installed
In my case, I made a mistake while editing my $PATH.
I would recommend looking at all your ~/.bash_profile and ~/.zshrc.
Remove ALL code related to $PATH. Carefully add things back in.

Mac: How to fix sudo command failure?

I am writing script to run SU commands programmatically to do various operations. But, All the commands created through my program is not working. Then, i tried those commands in Terminal (Mac os x) by typing it, but it gives the following result,
sudo: apt-get: command not found
Could someone please advise me, why is this error coming up, how can i make these working?
Homebrew installs the stuff you need that Apple didn’t.
install ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
e.g :
$ brew install wget
There's also MacPorts, and fink -- I also have homebrew, but also keep the others around for when I encounter things that one system has that the other doesn't.
apt-get is unique to the Debian based operating systems. If you want a package manager for OSX, may I suggest homebrew
http://brew.sh

Resources