Before moving ahead with this section make sure that you are using the Intel
build of brew. For that, you can to refer to
Uninstall arm64 brew
section of the book. Also make sure you had installed Xcode command line tools
as we had mentioned in previous chapter.
Install system packages
Ruby needs certain system packages like Openssl for it to be compiled properly.
Thus install the following packages from the Rosetta enabled terminal:
Install rbenv
Install rbenv. Using rbenv we can install a
specific version of Ruby:
If you don't know which shell you are using then
refer to this answer.
If you are using zsh shell then use the following command:
If you are using bash shell then execute the following command:
Now restart the terminal and run the following:
Add ~/.rbenv/bin
to your $PATH
for accessing the rbenv
command-line
utility.
If you are using bash shell then execute the following command:
If you are using zsh shell then use the following command:
Restart the terminal and rbenv
should be available as a command.
It's often seen that folks have a Ruby version conflicts in their system. It's
mostly because Ruby gets installed by default on the system level. But
system-level ruby
command has different permissions and paths, compared to the
ruby
command installed via rbenv
.
Thus let's set the global version of the ruby
command to be a rbenv
specific
version, like this:
Now that we have set the global Ruby version to be an rbenv
specific version,
let's verify the same, by running the following commands:
In M1 Mac, we need to install the shared mime info, if it doesn't already exist:
Installing Ruby on Rails on macOS
Now install Ruby on Rails gem:
Flag --no-document
disables document generation.
Now install bundler which help us manage Ruby gems:
Installing Ruby on Rails in other operating systems
At BigBinary we use Mac.
Thus, we have covered installation and setup for Mac within this course.
For instructions on installing Ruby on Rails and setting up the work environment on Windows, check out this link. For Linux, you can find many good resources on the internet and YouTube.
TypeError for Rails project in M1 Mac
If you ever receive the TypeError: Unable to resolve type 'size_t'
error while
working on a Rails project in M1 Mac, then run the following command to fix it:
Rbenv Ruby build definitions not found error
Rbenv Ruby build definitions not found
error is thrown if ruby-build
is not
installed. ruby-build
is an rbenv
plugin that provides the rbenv install
command to compile and install different versions of Ruby on UNIX-like systems.
You can check if ruby-build
is installed system-wide under homebrew using
which
command like this:
If ruby-build
already installed, then the following installed path should show
up in the terminal:
Otherwise you will receive the following error:
If ruby-build
is not installed, then you should install it like this: