<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Luiz Gadão</title>
    <description>The latest articles on DEV Community by Luiz Gadão (@luizgadao).</description>
    <link>https://dev.to/luizgadao</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1314462%2F6d14114d-4258-4f3f-bdde-2ff59acc06ab.jpeg</url>
      <title>DEV Community: Luiz Gadão</title>
      <link>https://dev.to/luizgadao</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/luizgadao"/>
    <language>en</language>
    <item>
      <title>Easy way to change Ruby version in Mac, M1, M2 and M3</title>
      <dc:creator>Luiz Gadão</dc:creator>
      <pubDate>Fri, 21 Jun 2024 15:26:20 +0000</pubDate>
      <link>https://dev.to/luizgadao/easy-way-to-change-ruby-version-in-mac-m1-m2-and-m3-16hl</link>
      <guid>https://dev.to/luizgadao/easy-way-to-change-ruby-version-in-mac-m1-m2-and-m3-16hl</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I had some problems updating and installing Ruby on my Mac, which made it difficult to configure essential tools like CocoaPods for my daily work. Here's a guide to help you change your Ruby version easily. &lt;strong&gt;&lt;em&gt;I spent 90 minutes figuring this out, but with this guide, you should be able to set up your environment in just 5 minutes&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Step 1: Install Homebrew
&lt;/h4&gt;

&lt;p&gt;If you don't have Homebrew installed on your Mac, paste this line into your terminal to install it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 2: Install rbenv
&lt;/h4&gt;

&lt;p&gt;rbenv is a simple tool to manage Ruby versions, similar to SDKMAN for Java. To install rbenv, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install rbenv ruby-build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 3: Initialize rbenv
&lt;/h4&gt;

&lt;p&gt;To start rbenv, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rbenv init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Maybe you need restart your sheel or open a new terminal window, but for me, it wasn't necessary.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 4: Check Your Current Ruby Version
&lt;/h4&gt;

&lt;p&gt;To check your current Ruby version, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ruby -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 5: Install a Newer Ruby Version
&lt;/h4&gt;

&lt;p&gt;To see the available Ruby versions, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rbenv install -l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3.1.6
3.2.4
3.3.3
jruby-9.4.7.0
mruby-3.3.0
picoruby-3.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To install and set up a newer version, for example, version 3.3.3, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rbenv install 3.3.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After donwloaded and intalled a ruby version, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rbenv global 3.3.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 6: Verify Your Ruby Version
&lt;/h4&gt;

&lt;p&gt;Now, check your Ruby version again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ruby -v           
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it still shows the old version, don't worry. Here's a tip:&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 7: Update Your .zprofile
&lt;/h4&gt;

&lt;p&gt;Open your &lt;strong&gt;.zprofile&lt;/strong&gt; file and add the following lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file. To apply the changes, either open a new terminal window or reload the profile with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source .zprofile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;/blockquote&gt;

&lt;p&gt;Check again your ruby version, just run the command bellow and you will see the current version of Ruby in your Mac.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ruby -v
ruby 3.3.3 (2024-06-12 revision f1c7b6f435) [arm64-darwin23]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your Mac is ready to install CocoaPods or any other tools you need for iOS development.&lt;br&gt;
🇧🇷🧑🏻‍💻&lt;/p&gt;

</description>
      <category>ios</category>
      <category>ruby</category>
      <category>kmp</category>
      <category>cocoapods</category>
    </item>
  </channel>
</rss>
