Homebrew Tutorial: Simplify Software Installation on Mac Using This Package Manager
20:01

Homebrew Tutorial: Simplify Software Installation on Mac Using This Package Manager

Corey Schafer 09.04.2019 224 569 просмотров 3 996 лайков

Machine-readable: Markdown · JSON API · Site index

Поделиться Telegram VK Бот
Транскрипт Скачать .md
Анализ с AI
Описание видео
In this video, we'll be learning how to use the Homebrew Package Manager on MacOS. Brew allows us to easily install command-line tools with a simple command. We can also install native applications for Mac using Brew Cask. I often use these commands in scripts to install a lot of new software quickly and easily on new machines. Let's get started... Homebrew Homepage - https://brew.sh/ Homebrew Formulas - https://formulae.brew.sh/formula/ Homebrew FAQ - https://docs.brew.sh/FAQ ✅ Support My Channel Through Patreon: https://www.patreon.com/coreyms ✅ Become a Channel Member: https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join ✅ One-Time Contribution Through PayPal: https://goo.gl/649HFY ✅ Cryptocurrency Donations: Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3 Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33 Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot ✅ Corey's Public Amazon Wishlist http://a.co/inIyro1 ✅ Equipment I Use and Books I Recommend: https://www.amazon.com/shop/coreyschafer ▶️ You Can Find Me On: My Website - http://coreyms.com/ My Second Channel - https://www.youtube.com/c/coreymschafer Facebook - https://www.facebook.com/CoreyMSchafer Twitter - https://twitter.com/CoreyMSchafer Instagram - https://www.instagram.com/coreymschafer/ #Homebrew #Brew #Mac

Оглавление (12 сегментов)

Intro

hey there how's it going everybody in this video we're going to be learning how to install and use Homebrew on the Mac operating system so Homebrew is a package manager for Mac so you can kind of think of it like apt or yum for Linux systems or if you're more familiar with python then you can think of this as being the PIP of the Mac operating system now this is going to allow us to install software using the command line in a nice and easy to use way and I use this all the time for installing software or setting up new machines I actually just got a new Macbook the other day and I'm going to release a video soon after this one showing how I use Homebrew to automate a large portion of the setup of a new development machine but in this video we're just going to learn the basics and how to use Homebrew in general so let's go ahead and get started so first of all before we can install Homebrew we need to have

Install Command Line Tools

some command line tools installed and we can install these easily through xcode so in an open Terminal you can install these by saying xcode Das select and then D- install now I'm going to get an error here because I already have these installed it says command line tools already installed uh so I've already done that but you might need to do that if you haven't yet but once we have those

Install Homebrew

installed we should be able to now install Homebrew so right now I don't have this installed if I try to run the Brew command I can see that I get an error and it says Brew command not found so to install home brew we can simply go to their website and I have that open here in my browser and right at the top of their homepage they have the installation command so I'm going to copy that and we can simply paste that into our terminal so it's this command here it's a uh Ruby command that's going to run this Ruby script to install so I'm going to open back up my terminal here and now I'm just going to paste in that command and it's going to run it automatically and now it's going to ask us to walk through this so I'm going to and we're also going to need to put in our password as well uh so I'm just going to let this install and I'm going to pick the video back up once this is complete okay so that installation completed uh we can see here that it says installation successful so if you didn't have any errors then Homebrew should have been installed correctly so we can test this simply by running Brew help and if that doesn't give us an error and it actually shows us some brew commands here then it means that installation was successful okay so now let's go over a few things and see how we can use home brew so first of all if you want to list all of the packages that you can install with home brew then we can simply say Brew search and we can see that there are a lot of packages listed here that we can install now if we want to see how many packages that is exactly then we could pipe that into the Linux word count command uh I'm not going to go into the details of Linux commands in this video or piping commands but if you wanted the total lines from that output you could simply say Brew search and pipe that into word count and then - L will count the number of lines so if I run that then that should display the number of packages that were displayed with that Brew Search Command now if we wanted to narrow down those results and we don't want to look through all 4700 of those then we could pass in a string to brew search as well so let's say that I wanted to install postgress and wanted to search for that package so to do that I could simply say Brew search postgress and when I run that it's going to go out and search those packages and we can see here that it returns a few results so most likely to install postgress I would use that formula of postgress SQL uh now we can see that there are two sections here one of these is called formula and the other here is Cask uh we're going to talk more about the differences between those in just a bit and see some examples of both but basically formula typically deal with commandline software and Cask is an extension of Homebrew that allows us to install Mac OS native applications like Google Chrome and stuff like that and we'll see more of that in just a bit so that's how we can search packages using Brew but you can also view this in the browser as well and I have this page pulled up here and I'll leave a link to these in the description section below as well uh so we can see uh in the browser here all of the packages available here as well along with a short description of each one and you can also search within here in the browser too so if I was to do something like postest then we can see that it pops up those same results and then you can get more detailed information about each package okay so now let's look at installing a package uh using Homebrew okay so one package

Install Packages

that I like to install with Homebrew is called tree it's a nice simple program that prints out tree directory structures in the command line so if I was to try to do this right now uh then we can see it says that the tree command is not found so this isn't installed so to install this with using Brew we can simply say Brew install tree and that's going to go out and install that package and once that's finished I'm going to uh let this download finish here and once that's finished we should be able to now use that tree command so right now I'm in my home folder so I don't want to run tree here since it would show the uh tree structure of my entire home folder but instead let me CD to my desktop and I'll look at the tree structure of one of my projects there so going to change directory into my desktop and here on my desktop I have my flask blog application uh from my flask Series so I'm going to run Tree on that so I'll say tree and that's called flask blog so I'm going to run that and we can see that it shows a nice directory structure of that project uh here within our command line so I really like that program it's a nice way to get an overview of a project or a directory so that tree command is working nicely now that we installed it using Homebrew so where does Homebrew actually install these packages now if I run the which command to see the path to tree if I say which tree then it looks like that this was installed in user local bin but that's actually just a symbolic link I can see that that's a symbolic link if I say ls- laa and now I'm going to uh just copy this line here and I'm going to uh list out uh that Direct there and we can see that this L here says that this is a link so this is the link here and then it's going to this location so this is up One Directory which would be user local and then it's in this seller directory and then it installs it in there so uh that is where home brew is installing these packages is within this user local seller directory now if we want to see more information about an installed package then we can do that by using the info command so let me clear my screen here I'm going to say Brew info of tree and that's going to give us a description and where and when it was installed and also some analytic data now if we look at the info for an uninstalled package then it will show us the dependencies and things like that so if I was to clear my screen here and say Brew info node and node is not currently installed then we can see here that it says not in installed and it also tells us what dependencies it needs and which ones we already have the red X here means that none of these uh dependencies are currently installed and if we did have one of those dependencies installed then it would instead be a green check mark okay so yeah that uh info command can give you some pretty useful information now to uninstall a package we can simply run the uninstall command so Brew uninstall tree and that will go out and uninstall that tree command that we just installed earlier now one really

Overwrite Tools

interesting thing with Homebrew is that we can use it to install ganu versions of certain tools that will overwrite Mac's BSD version of the same tool now I'm not going to go into a lot of details there but basically a lot of people like the Linux G new version of some tools a lot more than the default Mac BSD version so one of example of that would be the grep command so if I look at the version of the default grep command within Mac then we see that this says BSD grep so this is the BSD version of grep but if I look at the info for the grep package on home brew if I say Brew info grep then we can see that this says this is G grep so that's the Linux ganu version of grep so does that mean that if we install grep using brew that it will overwrite uh our Max default GP command well not really but we could do that if we wanted to if we look down here at the caveat section within this information then we can see that it says all commands have been installed with the prefix G if you need to use these commands with their normal names you can add the gnu bin directory to your path uh for your bash RC or in Max case sometimes your bashore profile so that means that the grep command is going to have a g prefix so it's going to be ggp so just to show you this let me actually install that so I'll say Brew install GP and it's going to go out and install this and I will let this finish and when that finishes it shows us here uh at the end that same caveat that it displayed in the info that this actually has a prefix of G and how we could set the path if we didn't want that prefix so now we have grep installed but that's going to have a prefix of G so if it's do gp-- version then we can see that is gnu GP but it did not overwrite my Mac version this is still BSD grep and again if you did want to replace the default version of grep instead of using uh grrep then you could do what they said and add that gnu bin directory to your path now personally I prefer the ganu version of tools in my day-to-day coding but I don't have them installed anymore now that I'm doing these tutorials I never want to have commands configured differently on my machine that might work in a certain way uh that don't work for someone else who's following along with a video uh so I would Rec recommend these types of tools uh even though I no longer use them myself because I'm doing these videos

Updating Packages

okay so now let's look at how you'd update packages so first of all to see what packages we currently have installed we can simply say Brew list and we can see there that we have two packages the other package here was just a dependency for grap so if we wanted to update our packages uh none of these will need updates since we just installed them but if we did want to update them uh it's a very similar process to something like apt on Linux so we would just simply say wh let me clear the screen here we could simply say Brew update and that will fetch the newest version of all of the packages and then if we wanted to view the outdated packages we could say Brew outdated and that would show us all of the packages that have an updated version available then to actually update those outdated packages then we would then say Brew upgrade and run that so anyone familiar with Linux uh that should be a familiar process because it's how it's done on there as well now by default Brew doesn't actually uninstall old versions of a package so over time you might accumulate old versions but to remove those you can simply run a command called Brew cleanup and that will go out and remove all of the older versions of those packages so that might be something that you want to put into a KRON job to run occasionally or something like that now if you ever run into any problems with home brew and need to check your system uh for potential problems then Brew also comes with a self diagnosis tool that does this for you and that is called Brew doctor so if we run Brew doctor then that's going to diagnose your system and could let you know of any issues that it finds and this might print out a lot of warnings here but if I scroll up here to the top you can see that we have a lot of warnings but if I scroll up to the top then we can see it says uh please note that these warning are just used to help Homebrew maintainers with debugging if you file an issue but if everything that you use Homebrew for is working fine then please don't worry or file an issue just ignore it so home brew is working fine for me I'm just going to uh ignore that output but if I did have any problems then that output there can help the maintainers uh possibly find what the issue is okay so

Installing Mac Applications

now let's look at what I think is one of the coolest things about Homebrew so far we've installed some command line tools but we can actually install mac applications as well and I usually use this when I want to write a script to easily set up a new machine and the way that we install this is with a home brew extension called cask and it's super easy to use so we just need to say Brew Cask install instead of just Brew install like we did before so for example let's say that we wanted to install Firefox we could just simply say Brew Cask install Firefox and if I run that then that's going to actually go out and install Firefox for us now this can take a second since it's installing a larger piece of software but I think it's a lot easier than going out to the Firefox website and going through their setup and then dragging and dropping the application to your applications folder and all of that this is just one easy step to install this um so I'm going to let this finish and then we'll pick up the video after this is done okay so we can see here that it says Firefox was successfully installed and it also moved that Firefox doapp into my applications folder now I uninstalled uh Firefox before this video began uh so if I run this then we can see that Firefox was actually reinstalled on my machine so that worked properly and sometimes when you're opening something for the first time you'll get this warning here I'm just going to go ahead and click open and this opened in the background here so we can see that installation worked and that uh Firefox is working for us so that's good and you can use

Searching for Packages

cast to install all kinds of different software Brew Cask also has a Search Command just like brew has so let's say that we wanted to install py charm so let's search for that so I'll say Brew search and I'll search for py charm and when we do that sometimes this takes a second to get results back so we can see that we got a few results but the first result here is probably the one that we want uh now if you're not sure if that's what you want then you can run brewcast info on that package and it'll show you more information about that so a lot of the Brew commands are the same with Brew Cask so Brew info and Brew Cask info now if you're still not sure then you can run Brew Cask home on a package and it will take you to the homepage of that software so that you're sure it's what you expected so for example if I was to run Brew Cask home on that pie charm package if I run this then it's going to open up the pie charm homepage for us here in the browser now like I said in the near future I'm going to release a video where I'll show you how I use scripts with Brew Cask to completely set up a new machine and install all kinds of different applications such as Google Chrome sublim teex uh the fonts that I like Spotify and a few others um okay so now let's look at a few other things that you can do with Homebrew so I'm going to close down my browser here and go back

Tap a Repository

to my terminal now sometimes with Homebrew you're going to want to install a package that is located in a different repository so far we've only installed software from the core home brew repository but we can add others so to do this we can simply tap a repository and then install the packages so all of these are kind of Homebrew terms you know uh tap things like that so for example to use the Heroku CLI on Mac it's easiest in my opinion to install this using Homebrew but first uh we have to tap their repository so right now if I was to say Brew search and I was to search for Heroku then once the search is complete we can see it says no formula or cast found for Heroku then it spits out a little bit more information here but the main thing is that it didn't find any formula or Cask for Heroku so in order to find that we first

Heroku Forge Brew

have to tap the repository so I'm going to say Brew tap and the name of the Heroku repository is Heroku Forge brew and just so you know I just found that repository name in the Heroku documentation I don't actually memorize stuff like that okay so once we have that repository tapped now let me do that same search so I'll say Brew search Heroku and now this should return uh the results from their repository so we can see here this is the repository name Heroku SL brew and these are the package names uh Heroku and Heroku node so if we wanted to install Heroku the Heroku CLI I could say Heroku or Brew install sorry Brew install Heroku and if I run that then that's going to go out and install that Heroku CLI for us okay so now that

Uninstalling Homebrew

Heroku installation completed so really that's all I wanted to show you as far as a broad overview to Homebrew I think that covers about 99% of what most people would use Homebrew for now if you no longer want Homebrew on your system then uninstalling it is pretty simple too they have a page on their website where they provide a script that does this for us and I have that open here in my browser so if I open my browser and go to their FAQ page uh I have this here at the top how do I uninstall Homebrew and it's this script here it's just another Ruby script just like they had a ruby script to install they also have one to uninstall so I can copy that and go back to my terminal and I can just paste that in and we can see here when we go to uninstall this it says are you sure you want to uninstall Homebrew this will remove your installed packages as well so I'm going to say yes now that's going to install all of the buw packages but I don't think that install uninstalls the Brew Cask packages so I think Firefox will remain uh but it will uninstall things like GP that we installed okay so that installation or uninstall was successful now if we type Brew again we can see that no longer exists and I'd say that ggp no longer works either so it

Conclusion

was uninstalled okay so I think that is going to do it for this video hope now you have a pretty good idea for how you can use Homebrew on the Mac and can see why this is so useful uh like I said I'll be doing a video in the near future where I set up a new development machine from scratch and I use my own custom scripts to go out and pull down a lot of software at once that might take hours to do manually without something like Homebrew so it not only adds a lot of nice functionality to our machines but it can also be a huge timesaver but if anyone has any questions about what we covered in this video then feel free to ask in the comment section below and I'll do my best to answer those and if you enjoy these tutorials and would like to support them then there are several ways you can do that the easiest way is to Simply like the video and give it a thumbs up and also it's a huge help to share these videos with anyone who you think would find them useful and if you have the means you can contribute through patreon and there's a link to that page in the description section below be sure to subscribe for future videos and thank you all for watching

Другие видео автора — Corey Schafer

Ctrl+V

Экстракт Знаний в Telegram

Экстракты и дистилляты из лучших YouTube-каналов — сразу после публикации.

Подписаться

Дайджест Экстрактов

Лучшие методички за неделю — каждый понедельник