{"componentChunkName":"component---src-templates-post-template-js","path":"/ruby-o-windows-2","webpackCompilationHash":"9f9b08718447f3d4e396","result":{"data":{"markdownRemark":{"id":"25ba6c78-6367-5f82-8e5f-5e6817983145","html":"<p>A few days ago I wrote about how to get started on ruby using just windows (no WSL2). And so far it was a good experience, but with a few gotchas when I tried to get a client project working on the env.</p>\n<h2 id=\"no-rvm-or-rbenv\"><a href=\"#no-rvm-or-rbenv\" aria-label=\"no rvm or rbenv permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>No RVM or rbenv</h2>\n<p>Those tools are specific for linux/macos, but don’t worry, the solution provided for windows works excellent: <a href=\"https://bitbucket.org/jonforums/uru/src/master/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Let me introduce you to URU</a></p>\n<p>If you installed ruby following <a href=\"https://blog2me.netlify.app/ror-on-windows\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">my last post</a>, you only need to add it bin path to uru.</p>\n<p>To install uru you can just download the binary and add it to a folder that is already in your PATH env (so you can start using the cli in your terminal), or <a href=\"https://bitbucket.org/jonforums/uru/wiki/Scoop\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">install it through scoop</a>: </p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">scoop install https://bitbucket.org/jonforums/uru/downloads/uru.json</code></pre></div>\n<p>Then you can add your existent ruby version to it with this command:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">uru admin add C:\\Ruby24-x64\\bin</code></pre></div>\n<p>Then to install other ruby versions just download the installer from <a href=\"https://rubyinstaller.org/downloads/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://rubyinstaller.org/downloads/</a>, while installing make sure that you don’t overwrite any other stuff and that it just installs in a different folder. After you are done just run <code class=\"language-text\">uru admin add &lt;the_other_ruby_version_bin_path&gt;</code></p>\n<p>If you want to save disk space by re-using the devkit through different ruby versions, <a href=\"https://github.com/oneclick/rubyinstaller2/wiki/FAQ#user-content-shared-devkit\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">follow this guide</a>. After that just install ruby versions without the devkit, they will fallback automatically to use it from the shared parent folder.</p>\n<p>You can check your available ruby versions with <code class=\"language-text\">uru ls</code> and change to a different one using the names listed from that command, like this:</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">$ uru <span class=\"token function\">ls</span>\n    224p230     <span class=\"token builtin class-name\">:</span> ruby <span class=\"token number\">2.2</span>.4p230 <span class=\"token punctuation\">(</span><span class=\"token number\">2015</span>-12-16 revision <span class=\"token number\">53155</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">[</span>x64-mingw32<span class=\"token punctuation\">]</span>\n    2410p364    <span class=\"token builtin class-name\">:</span> ruby <span class=\"token number\">2.4</span>.10p364 <span class=\"token punctuation\">(</span><span class=\"token number\">2020</span>-03-31 revision <span class=\"token number\">67879</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">[</span>x64-mingw32<span class=\"token punctuation\">]</span>\n    266p146     <span class=\"token builtin class-name\">:</span> ruby <span class=\"token number\">2.6</span>.6p146 <span class=\"token punctuation\">(</span><span class=\"token number\">2020</span>-03-31 revision <span class=\"token number\">67876</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">[</span>x64-mingw32<span class=\"token punctuation\">]</span>\n\n$ uru 2410p364\n---<span class=\"token operator\">></span> Now using ruby <span class=\"token number\">2.4</span>.10p364 tagged as <span class=\"token variable\"><span class=\"token variable\">`</span>2410p364<span class=\"token variable\">`</span></span>\n\n$ ruby --version\nruby <span class=\"token number\">2.4</span>.10p364 <span class=\"token punctuation\">(</span><span class=\"token number\">2020</span>-03-31 revision <span class=\"token number\">67879</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">[</span>x64-mingw32<span class=\"token punctuation\">]</span></code></pre></div>\n<p>Gemsets will be scoped to those ruby versions. You can manage different gemsets for that ruby version using <code class=\"language-text\">uru admin gemset init your_gemset_name</code> in your specific project folder.</p>\n<h2 id=\"openssl-rubygems-and-bundler\"><a href=\"#openssl-rubygems-and-bundler\" aria-label=\"openssl rubygems and bundler permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>OpenSSL, rubygems and bundler</h2>\n<p>This seems to be a popular one, and a easy one to fix tho. In my project I have something like this in my gemfile:</p>\n<div class=\"gatsby-highlight\" data-language=\"ruby\"><pre class=\"language-ruby\"><code class=\"language-ruby\">git_source<span class=\"token punctuation\">(</span><span class=\"token symbol\">:github</span><span class=\"token punctuation\">)</span> <span class=\"token keyword\">do</span> <span class=\"token operator\">|</span>repo_name<span class=\"token operator\">|</span>\n  repo_name <span class=\"token operator\">=</span> <span class=\"token string\">\"<span class=\"token interpolation\"><span class=\"token delimiter tag\">#{</span>repo_name<span class=\"token delimiter tag\">}</span></span>/<span class=\"token interpolation\"><span class=\"token delimiter tag\">#{</span>repo_name<span class=\"token delimiter tag\">}</span></span>\"</span> <span class=\"token keyword\">unless</span> repo_name<span class=\"token punctuation\">.</span>include<span class=\"token operator\">?</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"/\"</span><span class=\"token punctuation\">)</span>\n  <span class=\"token string\">\"https://github.com/<span class=\"token interpolation\"><span class=\"token delimiter tag\">#{</span>repo_name<span class=\"token delimiter tag\">}</span></span>.git\"</span>\n<span class=\"token keyword\">end</span>\n\ngem <span class=\"token string\">'some_gems_from_github'</span><span class=\"token punctuation\">,</span> github<span class=\"token punctuation\">:</span> <span class=\"token string\">'/usr/repo'</span><span class=\"token punctuation\">,</span> branch<span class=\"token punctuation\">:</span> <span class=\"token string\">'master'</span>\n\nsource <span class=\"token string\">'https://rails-assets.org'</span> <span class=\"token keyword\">do</span>\n  gem <span class=\"token string\">'rails-assets-tether'</span><span class=\"token punctuation\">,</span> <span class=\"token string\">'>= 1.3.3'</span>\n<span class=\"token keyword\">end</span></code></pre></div>\n<p>The issue here, at least in fresh installations, will be related to https and openssl.\nIt will complain about the certificates while trying to fetch from these sources.</p>\n<p>I highly suggest to use <a href=\"https://chocolatey.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Chocolatey</a> and <a href=\"https://scoop.sh/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Scoop</a> to install this kind of stuff. In this case, we need OpenSSL: <code class=\"language-text\">choco install openssl</code></p>\n<p>If the error persists even after installing openssl (and restarting your terminal) you can try with regular http sources, or go with a better long term solution: fix your certificates.</p>\n<p>In unix systems we usually have rvm or rbenv, and at least with rvm you have a script ready that fixes the rubygems certificates for you if the problem arises. In windows you will need to do that manually, but there is a really good step by step guide: </p>\n<p><a href=\"https://bundler.io/v2.0/guides/rubygems_tls_ssl_troubleshooting_guide.html#automated-ssl-check\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://bundler.io/v2.0/guides/rubygems_tls_ssl_troubleshooting_guide.html#automated-ssl-check</a></p>\n<p>The step that actually did the trick for me is to download the cacert.pem file in my ruby directory, and set a SSL<em>CERT</em>FILE env variable with the path to it.</p>\n<h2 id=\"puma\"><a href=\"#puma\" aria-label=\"puma permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Puma</h2>\n<p>So we had multiple workers and daemonized setup for development in this project, and neither of those options are available for windows.</p>\n<p>This step is simple, just change your puma config to run normally with 1 worker for windows. Rubygems actually has a helper to check for windows os locally with <code class=\"language-text\">Gem.win_platform?</code>, so you can have a different puma setup for windows.</p>\n<h2 id=\"activeadmin-and-method-calls-without-parenthesis\"><a href=\"#activeadmin-and-method-calls-without-parenthesis\" aria-label=\"activeadmin and method calls without parenthesis permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ActiveAdmin and method calls without parenthesis</h2>\n<p>Is a common practice in ActiveAdmin to write stuff like this:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">#syntax error on windows, unexpected &#39;{&#39;\nscope :completed { |scope| scope.where(completed: true) }</code></pre></div>\n<p>And I still can’t figure out if the error belongs to the version of ruby that I’m using on this windows machine or to something else related with ActiveAdmin dsl… but it expects to have the explicit parenthesis on that scope method call, like this:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">#This works fine on windows\nscope(:completed) { |scope| scope.where(completed: true) }</code></pre></div>\n<h2 id=\"linux-paths\"><a href=\"#linux-paths\" aria-label=\"linux paths permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Linux paths</h2>\n<p>This last one is obvious, but if you have a gem that requires something from linux systems (like custom loggers and stuff like that), they won’t work. You can bypass them using again the <code class=\"language-text\">Gem.win_platform?</code> helper in their initializers or even in the Gemfile:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">gem &#39;i_use_linux_paths&#39; unless Gem.win_platform?</code></pre></div>\n<h2 id=\"final-thoughts\"><a href=\"#final-thoughts\" aria-label=\"final thoughts permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Final thoughts</h2>\n<p>Like I said in the first post, this is not intended to replace your unix development environment, and it shouldn’t since your code is 99% sure going to run in some kind of linux distro when you deploy it to production.</p>\n<p>Still, is really handy to be able to do some quick maintenance work without having to jump into my macbook for it. The problems that I listed here were specific to this project, which only knew unix until this week (and its 3 years old). I expect to find different issues in different projects, and I plan to document them here if they pop up in the future.</p>\n<p>Lastly, if you start a fresh new app in windows </p>","fields":{"slug":"ruby-o-windows-2","tagSlugs":["/tag/ruby-on-windows/","/tag/openssl/","/tag/rubygems/","/tag/bundler/"]},"frontmatter":{"date":"2020-05-10T23:22:47.912Z","description":"A collection of \"gotchas\" after a week of playing with ruby on windows instead of my regular macOS env","tags":["ruby on windows","openssl","rubygems","bundler"],"title":"Ruby on windows, a week later","socialImage":null}}},"pageContext":{"isCreatedByStatefulCreatePages":false,"slug":"ruby-o-windows-2"}}}