<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>rbenv zsh Archives | Programming Zen</title>
	<atom:link href="https://programmingzen.com/tag/rbenv-zsh/feed/" rel="self" type="application/rss+xml" />
	<link>https://programmingzen.com/tag/rbenv-zsh/</link>
	<description>Meditations on programming, startups, and technology</description>
	<lastBuildDate>Thu, 12 Nov 2020 02:23:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">1397766</site>	<item>
		<title>Installing rbenv on Zsh (on MacOS)</title>
		<link>https://programmingzen.com/installing-rbenv-on-zsh-on-macos/</link>
					<comments>https://programmingzen.com/installing-rbenv-on-zsh-on-macos/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Fri, 06 Sep 2019 17:44:37 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[rbenv]]></category>
		<category><![CDATA[rbenv zsh]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby-build]]></category>
		<category><![CDATA[zsh]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2197</guid>

					<description><![CDATA[<p>Recently, I updated my Mac to the latest beta of macOS. It&#x2019;s not a polished product yet, but overall it&#x2019;s been a fairly enjoyable operating system. One of the changes that will impact you as a developer is that Apple switched the default shell from Bash to Zsh (Z shell). You can, of course, change it back to Bash, but I don&#x2019;t mind Zsh (or Fish) so I decided to keep it. I needed to install htmlbeautifier, a gem used by some prettifier extensions within Visual Studio Code. If you try it with the default system installation of Ruby, you&#x2019;ll </p>
<p>The post <a href="https://programmingzen.com/installing-rbenv-on-zsh-on-macos/">Installing rbenv on Zsh (on MacOS)</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Recently, I updated my Mac to the latest beta of macOS. It&#8217;s not a polished product yet, but overall it&#8217;s been a fairly enjoyable operating system.</p>



<p>One of the changes that will impact you as a developer is that Apple switched the default shell from Bash to Zsh (Z shell). You can, of course, change it back to Bash, but I don&#8217;t mind Zsh (or Fish) so I decided to keep it.</p>



<p>I needed to install <g class="gr_ gr_4 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="4" data-gr-id="4">htmlbeautifier</g>, a gem used by some prettifier extensions within Visual Studio Code. If you try it with the default system installation of Ruby, you&#8217;ll get a permission error:</p>



<pre class="wp-block-code"><code>$ gem install htmlbeautifier
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.</code></pre>



<p>At this point, you might be tempted to simply <code>sudo</code> it, but that&#8217;s not a smart approach. Instead, I like to have multiple versions through an environment management system such as <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://github.com/rbenv/rbenv" target="_blank">rbenv</a> or <a href="https://asdf-vm.com/#/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">asdf</a>.</p>



<p>For this particular machine, I picked rbenv. Unfortunately, following the usual setup instructions didn&#8217;t really work, so I&#8217;m sharing the setup that worked for me here.</p>



<p>I updated brew and used it to install <g class="gr_ gr_4 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" id="4" data-gr-id="4">rbenv</g> and ruby-build. The latter allows us to select a series of Ruby versions to chose from.</p>



<pre class="wp-block-code"><code>$ brew update &amp;&amp; brew install rbenv ruby-build</code></pre>



<p>To ensure that rbenv is correctly loaded when we start a new shell, I had to edit a couple of files. I added the following line to <code>.zshenv</code>:</p>



<pre class="wp-block-code"><code>export PATH="$HOME/.rbenv/bin:$PATH"</code></pre>



<p>This adds gem-specific binaries to the PATH so that they are accessible to the shell without fully qualifying them with their path.</p>



<p>Then I added the following lines to <code>.zshrc</code>:</p>



<pre class="wp-block-code"><code>source $HOME/.zshenv
eval "$(rbenv init - zsh)"</code></pre>



<p>This ensures that the previous file is sourced when a new session is started and that rbenv is initialized for Zsh.</p>



<p>At this point, you&#8217;ll want to source <code>.zshrc</code> (or simply restart the terminal of your choice like iTerm2, instead):</p>



<pre class="wp-block-code"><code>$ source ~/.zshrc</code></pre>



<p>With rbenv ready to go, I installed the latest version of Ruby and set it as my global default for this machine.</p>



<p>You can determine the latest stable version by running:</p>



<pre class="wp-block-code"><code>$ rbenv install -l</code></pre>



<p>Go ahead and run:</p>



<pre class="wp-block-code"><code>$ rbenv install 2.7.2
$ rbenv global 2.7.2</code></pre>



<p>After restarting the terminal again, do a quick sanity test to ensure that the right version of Ruby is being selected:</p>



<pre class="wp-block-code"><code>$ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) &#91;x86_64-darwin20]

$ ruby -e "puts (1..100).reduce(:+)"
5050</code></pre>



<p>Finally, you&#8217;ll be able to install htmlbeautifier, like I did:</p>



<pre class="wp-block-code"><code>$ gem install htmlbeautifier</code></pre>



<p>No need for <code>sudo</code>.</p>



<p>I hope this helps anyone who is trying to install rbenv on zsh. It did the trick for me.</p>
<p>The post <a href="https://programmingzen.com/installing-rbenv-on-zsh-on-macos/">Installing rbenv on Zsh (on MacOS)</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/installing-rbenv-on-zsh-on-macos/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2197</post-id>	</item>
	</channel>
</rss>
