Search
⌘K
    to navigateEnterto select Escto close

    Installing Ruby on Rails

    Installing Ruby on Rails on macOS

    Install rbenv. Using rbenv we can install a specific version of Ruby:

    1brew update
    2brew install rbenv

    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:

    1echo 'eval "$(rbenv init -)"' >> ~/.zshrc

    If you are using bash shell then execute the following command:

    1echo 'eval "$(rbenv init -)"' >> ~/.bashrc

    Now restart the terminal and run the following:

    1rbenv install 3.0.2
    2rbenv rehash
    

    Add ~/.rbenv/bin to your $PATH for accessing the rbenv command-line utility.

    If you are using bash shell then execute the following command:

    1echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

    If you are using zsh shell then use the following command:

    1echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc

    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 so:

    1rbenv global 3.0.2

    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:

    1rbenv version # version should be 3.0.2
    2ruby -v # version should be 3.0.2

    In M1 Mac, we need to install the shared mime info, if it doesn't already exist:

    1brew install shared-mime-info

    Now install Ruby on Rails gem:

    1gem install rails --no-document -v 6.1.4.1

    Flag --no-document disables document generation.

    Now install bundler which help us manage Ruby gems:

    1gem install bundler

    Installing Ruby on Rails in other operating systems

    At BigBinary we use Mac.

    Thus, we won't be documenting on how to install Ruby and Ruby on Rails on Windows/Linux.

    There are plenty of good materials on the internet and on YouTube about installing Ruby on Rails and setting up the work environment on Windows/Linux.

    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:

    1bundle update ffi sassc

    Rbenv Ruby build definitions not found error

    ruby-build is an rbenv plugin that provides the rbenv install command to compile and install different versions of Ruby on UNIX-like systems.

    Over the period of time, the ruby-build versions might get updated. In such cases, we'd have to manually fetch the latest versions by running the following command from anywhere in terminal:

    1git -C ~/.rbenv/plugins/ruby-build pull
    Previous
    Next