Quickstart
It started failing when I was doing npm install. The issue reported was regarding the xcode-select CLT. We usually avoid installing full xcode and install the CLT (Command Line Tools) using xcode-select -install command. Tried to run the command again but it did not work as CLT was already installed. I did struggle for sometime to fix the issue. Uninstalling Xcode Command Line Tools. To remove Xcode Command Line Tools (which is, by the way, different than the full Xcode IDE), you will need to go through two steps. Remove the files consisting the command line tools. Remove the receipts to prevent it from coming back again. The first step is easy enough.
- Install Xcode and the Xcode Command Line Tools
- Agree to Xcode license in Terminal:
sudo xcodebuild -license
- Install MacPorts for your version of the Mac operating system:
Installing MacPorts
MacPorts version 2.7.1 is available in various formats for download and installation (note, if you are upgrading to a new major release of macOS, see the migration info page):
- “pkg” installers for Big Sur, Catalina, and Mojave, for use with the macOS Installer. This is the simplest installation procedure that most users should follow after meeting the requirements listed below. Installers for legacy platforms High Sierra, Sierra, El Capitan, Yosemite, Mavericks, Mountain Lion, Lion, Snow Leopard, Leopard and Tiger are also available.
- In source form as either a tar.bz2 package or a tar.gz one for manual compilation, if you intend to customize your installation in any way.
- Git clone of the unpackaged sources, if you wish to follow MacPorts development.
- The selfupdate target of the port(1) command, for users who already have MacPorts installed and wish to upgrade to a newer release.
Checksums for our packaged downloads are contained in the corresponding checksums file.
The public key to verify the detached GPG signatures can be found under the attachments section on jmr's wiki page. (Direct Link).
Please note that in order to install and run MacPorts on macOS, your system must have installations of the following components:
Apple's Xcode Developer Tools (version 12.2 or later for Big Sur, 11.3 or later for Catalina, 10.0 or later for Mojave, 9.0 or later for High Sierra, 8.0 or later for Sierra, 7.0 or later for El Capitan, 6.1 or later for Yosemite, 5.0.1 or later for Mavericks, 4.4 or later for Mountain Lion, 4.1 or later for Lion, 3.2 or later for Snow Leopard, or 3.1 or later for Leopard), found at the Apple Developer site, on your Mac operating system installation CDs/DVD, or in the Mac App Store. Using the latest available version that will run on your OS is highly recommended, except for Snow Leopard where the last free version, 3.2.6, is recommended.
With Xcode 4 and later, users need to accept the Xcode EULA by either launching Xcode or running:
Apple's Command Line Developer Tools, which can be installed on recent OS versions by running this command in the Terminal:
Older versions are found at the Apple Developer site, or they can be installed from within Xcode back to version 4. Users of Xcode 3 or earlier can install them by ensuring that the appropriate option(s) are selected at the time of Xcode's install ('UNIX Development', 'System Tools', 'Command Line Tools', or 'Command Line Support').
- (Optional) The X11 windowing environment, for ports that depend on the functionality it provides to run. You have multiple choices for an X11 server:
- Install the xorg-server port from MacPorts (recommended).
- The XQuartz Project provides a complete X11 release for macOS including server and client libraries and applications.
- Apple's X11.app is provided by the “X11 User” package on older OS versions. It is always installed on Lion, and is an optional installation on your system CDs/DVD with previous OS versions.
macOS Package (.pkg) Installer
The easiest way to install MacPorts on a Mac is by downloading the pkg or dmg for Big Sur, Catalina, Mojave, High Sierra, Sierra, El Capitan, Yosemite, Mavericks, Mountain Lion, Lion, Snow Leopard, Leopard or Tiger and running the system's Installer by double-clicking on the pkg contained therein, following the on-screen instructions until completion.
This procedure will place a fully-functional and default MacPorts installation on your host system, ready for usage. If needed your shell configuration files will be adapted by the installer to include the necessary settings to run MacPorts and the programs it installs, but you may need to open a new shell for these changes to take effect.
The MacPorts “selfupdate” command will also be run for you by the installer to ensure you have our latest available release and the latest revisions to the “Portfiles” that contain the instructions employed in the building and installation of ports. After installation is done, it is recommended that you run this step manually on a regular basis to to keep your MacPorts system always current:
At this point you should be ready to enjoy MacPorts!
Type “man port” at the command line prompt and/or browse over to our Guide to find out more information about using MacPorts. Help is also available.
Source Installation
If on the other hand you decide to install MacPorts from source, there are still a couple of things you will need to do after downloading the tarball before you can start installing ports, namely compiling and installing MacPorts itself:
- “cd” into the directory where you downloaded the package and run “tar xjvf MacPorts-2.7.1.tar.bz2” or “tar xzvf MacPorts-2.7.1.tar.gz”, depending on whether you downloaded the bz2 tarball or the gz one, respectively.
- Build and install the recently unpacked sources:
- cd MacPorts-2.7.1
- ./configure && make && sudo make install
- cd ../
- rm -rf MacPorts-2.7.1*
These steps need to be perfomed from an administrator account, for which “sudo” will ask the password upon installation. This procedure will install a pristine MacPorts system and, if the optional steps are taken, remove the as of now unnecessary MacPorts-2.7.1 source directory and corresponding tarball.
To customize your installation you should read the output of “./configure --help | more” and pass the appropriate options for the settings you wish to tweak to the configuration script in the steps detailed above.
You will need to manually adapt your shell's environment to work with MacPorts and your chosen installation prefix (the value passed to configure's --prefix flag, defaulting to /opt/local):
- Add ${prefix}/bin and ${prefix}/sbin to the start of your PATH environment variable so that MacPorts-installed programs take precedence over system-provided programs of the same name.
- If a standard MANPATH environment variable already exists (that is, one that doesn't contain any empty components), add the ${prefix}/share/man path to it so that MacPorts-installed man pages are found by your shell.
- For Tiger and earlier only, add an appropriate X11 DISPLAY environment variable to run X11-dependent programs, as Leopard takes care of this requirement on its own.
Lastly, you need to synchronize your installation with the MacPorts rsync server:
Upon completion MacPorts will be ready to install ports!
It is recommended to run the above command on a regular basis to keep your installation current. Type “man port” at the command line prompt and/or browse over to our Guide to find out more information about using MacPorts. Help is also available.
Git Sources
If you are developer or a user with a taste for the bleeding edge and wish for the latest changes and feature additions, you may acquire the MacPorts sources through git. See the Guide section on installing from git.
Purpose-specific branches are also available at the https://github.com/macports/macports-base/branches url.
Alternatively, if you'd simply like to view the git repository without checking it out, you can do so via the GitHub web interface.
Selfupdate
If you already have MacPorts installed and have no restrictions to use the rsync networking protocol (tcp port 873 by default), the easiest way to upgrade to our latest available release, 2.7.1, is by using the selfupdate target of the port(1) command. This will both update your ports tree (by performing a sync operation) and rebuild your current installation if it's outdated, preserving your customizations, if any.
Other Platforms
Running on platforms other than macOS is not the main focus of The MacPorts Project, so remaining cross-platform is not an actively-pursued development goal. Nevertheless, it is not an actively-discouraged goal either and as a result some experimental support does exist for other POSIX-compliant platforms such as *BSD and GNU/Linux.
The full list of requirements to run MacPorts on these other platforms is as follows (we assume you have the basics such as GCC and X11):
- Tcl (8.4 or 8.5), with threads.
- mtree for directory hierarchy.
- rsync for syncing the ports.
- cURL for downloading distfiles.
- SQLite for the port registry.
- GNUstep (Base), for Foundation (optional, can be disabled via configure args).
- OpenSSL for signature verification, and optionally for checksums. libmd may be used instead for checksums.
Normally you must install from source or from an git checkout to run MacPorts on any of these platforms.
Help
Help on a wide variety of topics is also available in the project Guide and through our Trac portal should you run into any problems installing and/or using MacPorts. Of particular relevance are the installation & usage sections of the former and the FAQ section of the Wiki, where we keep track of questions frequently fielded on our mailing lists.
If any of these resources do not answer your questions or if you need any kind of extended support, there are many ways to contact us!
Introduction
This Readme is a step-by-step guide for how to set up your local environmenton a Mac. Please note that these instructions will not work for non-Macusers. If you're on a Windows 10 machine, see theWindows Subsystem for Linux setup instructions. If you're on an olderWindows machine, refer to the Setting up Linux Virtual Boxinstructions.
The following instructions are for macOS Catalina. If you are not on Catalinabut can upgrade, we recommend doing so after following the instructions below.Additional instructions are included in the steps below for non-Catalina users.
You can check your OS version by clicking the apple menu in the top left andclicking 'About This Mac'.
When to Move to a Local Environment
For online students, you should switch to a local environment after yourRuby CLI project, or sooner if recommended by an instructor.
For in-person students, you should move to a local environment at the end ofPrework, before you start on campus.
Step 0
First, if you've downloaded the Learn IDE, you will need to uninstall it. Fordetailed instructions on how to properly uninstall the IDE, please read thisHelp Center article.
Step By Step Instructions for Manual Installation
ALERT - For New M1 Mac Laptops ONLY
If you are using a Mac laptop with the new M1 chip (released in late 2020), there isan additional step required for some tools to install correctly. This step involvescreating a copy of your laptop's Terminal application and enabling it to work withtools that aren't yet compatible with the M1 chip. Check out this linkand follow the steps provided before continuing.
Install Xcode Command Line Tools
Open up your terminal. You can do this by going to Applications > Utilities >Terminal, or by using the quick launch (cmd
+ space
) and just start typing“Terminal”.
The first tools we're going to install are the Xcode command-line tools.Xcode is a suite of development tools from Apple, including tools forbuilding Mac and iPhone applications. For this course, we only need the Xcodecommand-line tools, as many other tools rely on them. Run the following toinstall them:
You will be prompted to install Xcode Command-Line Tools. Agree and allow theinstall to continue. You may need to provide your computer's password.
Important: If the Xcode Command-Line Tools aren't installed, you may encountererrors later on when working with gems like sqlite3
. To double check that everything is installed,rerun the xcode-select --install
command. If everything is installed, you should see this error:
If you receive this error, you are good to continue!
If you have recently updated your OS to Catalina 10.15.2 or are on BigSur, you may encounter some errorsrelated to XCode while installing Ruby and/or running Node. While working through this set up, follow anydebugging instructions provided, but if those do not work, check out the instructions here to make sure the Xcode Command-Line Tools are configured correctly on the new system
Install Homebrew
Homebrew is a package manager for the Mac. It allows us to install a numberof things we will need. To install Homebrew, run the following:
Note: this is all one line in the terminal (even if it is broken up intotwo lines here in your browser).
You can verify that Homebrew is successfully installed by running brew help
. Ifyour terminal outputs a list of brew
commands, you're all set.
Install Zsh
Zsh is the new standard shell for the macOS. To see if you're alreadyusing Zsh, run the following:
If the terminal outputs /bin/zsh
, Zsh is already installed. If something elsewas output (like /bin/bash
), run the following commands:
This will install Zsh and set it as the default shell.
Close your terminal and reopen. If you rerun echo $SHELL
, the terminal shouldoutput /bin/zsh
.
Install the GMP and GnuPG Packages
Before continuing further, we need to install some libraries that other toolsrely on, GMP and GnuPG:
Note: If you get this error: Warning: gnupg-1.4.19 already installed
,GnuPG is installed, but it may not be linked properly. To fix, run:
Install RVM
RVM is a tool that lets you run different versions of Ruby on your computer.If one project you're working on works with Ruby version 2.3.3 and another needs2.6.1, you can easily switch between the two versions when you switch betweenprojects.
The following command downloads encryption keys we need to install RVM:
Note: If that command does not work, or you receive an error stating keyserver receive failed: No route to host
, try running the following commands:
Once the encryption keys are downloaded, use the following command to download RVM:
When RVM is installed, run rvm reload
or close and reopen your terminal to make sure RVM is fullyloaded. Next, we will install the Ruby version we'll be using and set it as the default:
To check that everything worked, run rvm list
. You should see =* ruby-2.6.1
listed, indicating that 2.6.1
is installed and set as the default version forRuby. You can also run ruby -v
, which should show that Ruby 2.6.1
is thecurrent version of Ruby being used.
Before continuing, close and reopen your terminal and run rvm list
one moretime to make sure everything is working.
Note: If you see an error or warning when running rvm list
, we recommendfollowing the troubleshooting steps at the end of this lesson beforecontinuing.
Remember, if you're on a newer version of the macOS or on an M1 machine,you may need to do some additional set up for Xcode before RVM/Ruby will install correctly.Check out this resource for instructions
Install Some Ruby Gems
Ruby gems are pre-written, stand-alone, chunks of code that have been madeeasily accessible to you. We'll use a lot of them soon, but for now, we shouldget a few important ones.
- First, let's update our system gems by running
gem update --system
- Next, install the Learn gem. Do this by running
gem install learn-co
. Thisgem gives us access tolearn
andlearn submit
commands for labs. - Install the Bundler gem with
gem install bundler
. This gem takes care ofinstalling other gems you will need for projects. - Install Nokogiri with
gem install nokogiri
- Nokogiri is a gem to help parseHTML - useful when we want to scrape websites. If you encounter any errorswhile installing it, check out the Nokogiri support docsfor Mac OSX. - Install Pry with
gem install pry
. You may have already used Pry during thePrework while using the in-browser IDE. Installing Pry here will make it availablefor projects in your local environment. - Install Ruby on Rails with
gem install rails
- Rails is used forbuilding out full web applications. We will learn much more about Rails soon.
Before continuing, check to make sure the learn-co
gem was properly installed. Runlearn
in the terminal. If you're in your home directory (cd ~
), running learn
shouldproduce the following message:
If you receive an error message, try reinstalling with gem install learn-co
again, closeand reopen the terminal and try the learn
command a second time.
Install Git
Git generally comes pre-installed with most operating systems, but you can checkby running git version
in the terminal. If this gives you an error or does notcome back with a version number, you'll need to install Git. you can get itusing Homebrew:
Set Up the Learn gem
Now we need to set up the Learn gem. Type the following into your terminal:
This will prompt you to set up the Learn gem using a token provided onlearn.co
.
- If you have connected your Github account to your Learn account, navigate to
learn.co/your_github_username
. The OAuth token is at the bottom of the page. - If you have not connected your Github account: Go to your profile > LearnSettings > Public Profile. A URL should be listed under Username. Navigateto this URL and scroll to the bottom of the page. The OAuth token is at thebottom of the page.
Note: At the end of this lesson is additional troubleshooting information.If you receive an error when running learn whoami
, please try the stepslisted there.
Get a Text Editor
Get a Text Editor. We suggest Visual Studio Code; follow the link todownload the macOS version.
After downloading and unzipping, make sure to move the Visual Studio Code appfrom your Downloads folder to your Applications folder. Open Finder and navigateto Downloads (or wherever you save downloads). If you see Visual Studio Codethere, drag it over to Applications.
Once Visual Studio Code is in your Applications folder, launch the program andtype command(⌘) + shift(⇧) + p
, and your Command Palette will open. Inyour Command Palette, type >shell command
. Select 'Shell Command: Install'code' command in PATH'
Next, let's install Visual Studio Code as your default text editor in the.learn-config
file. First, open the config file for Learn in a text editor (let'sgive Visual Studio Code a try!). If you successfully installed Visual StudioCode and its shell commands, type code ~/.learn-config
in your terminal. Your.learn-config
file should open in VSCode!
If your .learn-config
is blank, or is missing, use the following template. Make yourchanges and save it in your root (~
) directory.
Change default editor from subl
(or atom
) to code
.
Note:Atom is also a popular editor option. If you would prefer touse Atom over VS Code, you can. Just make sure that the ~/.learn-config
filehas the correct editor. For VS Code, the file should include :editor: code
,but for Atom users, this line should read: :editor: atom
. If you have adifferent editor you prefer, you can set it as the default learn editorin this file.
In .learn-config
, you can also set the default location where Learn will saveall your labs. By default, the Learn directory is set to/Users/<your-computer-username>/Development/code
. However, some students havereported issues using Ruby Gems when working in this folder. To avoid thispotential problem, let's make a new folder and set it as the default location.instead of Development/code
, lets make a Flatiron/code
folder:
Then, in .learn-config
, change the Learn directory to/Users/<your-computer-username>/Flatiron/code
. If you want to store labssomewhere else, change this path to point to the desired location. Make sure thefolders you point to exist!
This location setting is only triggered when using the learn open
command toopen a lesson. Save and close the ~/.learn-config
file.
Optional VS Code Terminal Setup
If you would like to use the terminal built into VS Code, you may need to updatethe settings. If you intend to use your regular terminal, you do not need tocomplete this step.
To update VS Code's terminal settings, while in VS Code, presscommand(⌘) + shift(⇧) + p
and search for settings.json
.
In this file, you should see opening and closing curly braces {}
withoutanything inside them. Add the following in between the braces:
If there are already items inside the curly braces, instead of erasing them, youcan add a comma after the last item and paste in the above setting on a newline. The file should look like this:
Or something similar to this:
Install SQLite
You’ll be using a couple of different databases as you move through the webdevelopment track. The default database that Rails uses is SQLite.
To set up SQLite, run:
Install Postgres
We also frequently see that students want to deploy their apps to the freehosting service Heroku. To do this, though, you will need a differentrelational database management system, PostgreSQL.
To install Postgres, run the following commands:
Install Node
Later on in the program, we'll want to run JavaScript just like we run Ruby. Onthe command line, the program that runs JavaScript files (the 'JavaScriptRuntime') is called Node.
To manage different versions of Node installed on our computer, we can useJavaScript's equivalent of RVM - NVM. Let's get your Node Version Managerinstalled. Run the following in your terminal:
Make sure you do not use sudo
.
Next, run the following commands:
This sets NVM up to be accessible in your terminal whenever you open it. Thelast command refreshes your shell so you won’t have to quit the terminal andopen it again.
Finally, run the three following commands to install the latest version of Node:
After installing, you can verify everything is working by running nvm list
. IfNVM has installed correctly, this will output the existing versions of Node and indicate which version is currently set to default.
Dotfiles
Configuration files are often prefixed with the '.' character, hiding them fromnormal file explorer views - hence 'dotfiles'. Since the default configurationof many of the tools we use is somewhat plain, it's helpful to add someconfiguration on top.
These dotfiles set up a variety of convenient features to some of the mostcommon tools you'll use - Zsh and Git.
You'll first want to back up your dotfiles before overwriting them. Run thefollowing commands to do so:
Note: If when you’re trying to back up a file, you get the error No suchfile or directory
, don’t worry. This just means you didn’t have that file tostart with, so there is nothing to back up.
Global List of Files for Git to Ignore - ~/.gitignore
Catalina Install Xcode Command Line Tools Download
When code is sent from your local machine to GitHub, it is possible toaccidentally send files that aren't normally meant to be sent. To avoid this,many Git repositories contain a .gitignore
file, defining what files should beignored when code is being pushed to GitHub. We can also set a global .gitignore
file to use for all repositories.
GitHub maintains a list of files they recommend. These filenames anda few others can be added to your own global .gitignore
file by running:
Helpful Zsh Shortcuts - .zprofile
Your Zsh profile loads up every time you open a terminal window. Learn has a default.zprofile
that is designed to load up a bunch of shortcuts for you as well as makesure that RVM loads up every time you open the terminal. To use this profile, runthe following:
We recommend you take a look at this file and see if there are anyshortcuts of your own that you’d like to add!
Set up the Default Git Configuration File
In the next step, we'll configure Git, but before we do, we will set up a defaultconfiguration file called .gitconfig
. To get the default .gitconfig
file,run:
Note: After changing up the dotfiles, it is recommended you run:
This will attempt to clear any potential PATH related issues.
Configure Git
With Git installed, we now want to configure it using your own account.First, you need to let Git know who you are. You can do this by running:
Replace 'you@example.com'
with the email tied to your GitHub account and'Your name'
with your full name. Git will use this email and name as theauthor for all the changes you make.
IMPORTANT: While we're configuring GitHub, we should add a new SSH key.Setting this key up will keep you from having to provide your usernameand password whenever you use the terminal to interact with GitHub.
- First, check if you already have an SSH key by running
cat ~/.ssh/id_rsa.pub
. If the terminal prints out a long string ofcharacters starting withssh-rsa
, you've already got a key and can skipthe next bullet - If the last command does not print anything, run
ssh-keygen
to create anew SSH key. You should be prompted to select a location and passphrase foryour new key. Leave everything blank and press enter for the defaultlocation and no passphrase. If you’re asked if you want to overwrite, thenyou already have an SSH key, and you do not want to overwrite it.
Run cat ~/.ssh/id_rsa.pub
once more and copy the key that is printed out.Follow the instructions provided by GitHub and add this key to yourGitHub account
Install Chrome
Install Google Chrome and make Chrome your default browser.
Install Slack
Install Slack for Mac and enable desktop notifications for Slack. One weekbefore your start date, you will receive an invitation to join the FlatironSchool workspace, flatiron-school.slack.com
. You’ll also receive a welcomeemail with information about channels you should join.
Verify Installations
To verify that you've got everything installed, run the following command inyour terminal:
This script will verify that everything you need is installed. If all checks pass,you have completed the setup process and are ready to move on!
Troubleshooting
Below are some options to try for specific issues.
RVM Is Producing Errors or Warnings
Can't Install Xcode Command Line Tools Catalina
Close your terminal, reopen it, and try the
rvm list
command.If you see a warning regarding the
PATH
, try running the followingfirst:
Catalina Install Xcode Command Line Tools List
Close and reopen the terminal again, and rerun rvm list
.
If RVM is not found when you run
rvm list
, try reinstalling RVM:You may get an error regarding keys with furthercommands to try, including the following:
Try each of these, followed by the previous curl
command to install RVM.
- If RVM is found but continues to produce errors, try uninstalling with:
This will remove RVM entirely. Follow the instructions in Step 3 to reinstall RVM.
learn whoami
Command Not Found / learn
Produces oj.bundle
Error
Close your terminal window, reopen it, and try the
learn whoami
commandagain.Run the command
rvm list
. If RVM is not found, follow the steps in theprevious troubleshooting section on installing RVM. If you see a warningregardingPATH
, try running the following first:
Then reinstall the Learn gem and test it again with:
- If the
learn
command continues to fail, but RVM is working fine, tryreinstalling RVM by first using the following command:
Then rerunning the RVM install script:
Once RVM is installed, try reinstalling and testing the learn-co
gem.
- If you are still unable to run
learn whoami
, try the following:
Catalina Install Xcode Command Line Tools
This will clear out any gems that have already been installed. At the moment, you will only need the learn-co
and bundler
gems, so this reinstalls them.
Catalina Install Xcode Command Line Tools Free
learn
Commands Produce psych
Gem Errors
This error is typically due to issues in the ~/.learn-config
file.
Catalina Install Xcode Command Line Tools Windows 10
Run
code ~/.learn-config
. This file should only have three lines in it, similar to the example below:Check for any typos or extra content. Make sure the
:learn_directory
pathis valid and has your computer's username after/Users/
. You can confirm thisname by runningecho $HOME
.Save the
.learn-config
file and try runninglearn whoami
.