{"id":8700,"date":"2015-01-06T22:08:44","date_gmt":"2015-01-06T22:08:44","guid":{"rendered":"https:\/\/wp.okra.host\/article\/changing-ruby-versions\/"},"modified":"2021-03-07T14:47:27","modified_gmt":"2021-03-07T13:47:27","slug":"changing-ruby-versions","status":"publish","type":"ht_kb","link":"https:\/\/kb.okra.host\/de\/article\/changing-ruby-versions\/","title":{"rendered":"Changing Ruby versions"},"content":{"rendered":"<h2 id=\"overview\" >Overview<\/h2>\n<p>Newer <a title=\"Determining platform version\" href=\"https:\/\/kb.okra.host\/platform\/determining-platform-version\/\">hosting platforms<\/a>, v6+, support multiple Ruby versions through <a href=\"http:\/\/www.rvm.io\">rvm<\/a>. This enables you to run multiple versions of Rack and Rails using any available Ruby interpreters. Currently, versions 1.8 to 2.2 are supported.<\/p>\n<p><strong>Important:<\/strong> Avoid using 1.8, except to shim an older application with an intent to upgrade. 1.8 is <a href=\"https:\/\/www.ruby-lang.org\/en\/news\/2011\/10\/06\/plans-for-1-8-7\/\">deprecated<\/a> and contains several unpatched security vulnerabilities as of June 2013.<\/p>\n<h2 id=\"switching-versions\" >Switching versions<\/h2>\n<p><span style=\"color: #0000ff\">Important:<\/span> all commands are done from the <a title=\"Accessing terminal\" href=\"https:\/\/kb.okra.host\/terminal\/accessing-terminal\/\">terminal<\/a>.<\/p>\n<h3 id=\"listing-available-versions\" >Listing available versions<\/h3>\n<p><code>rvm list<\/code> will list available versions. If a version that you need is missing, open a ticket and we&#8217;ll install it for you.<\/p>\n<pre data-language=\"shell\"><code>[myadmin]$ rvm list\r\nrvm rubies\r\n   ruby-1.8.7-head [ x86_64 ]\r\n   ruby-1.8.7-p374 [ x86_64 ]\r\n   ruby-1.9.3-p547 [ x86_64 ]\r\n * ruby-2.0.0-p481 [ x86_64 ]\r\n=&gt; ruby-2.1.2 [ x86_64 ]\r\n   ruby-head [ x86_64 ]\r\n# =&gt; - current\r\n# =* - current &amp;&amp; default\r\n# *  - default<\/code><\/pre>\n<p>Current (=&gt;) indicates the version that will be reported with\u00a0<code>ruby --version<\/code> and default (*) indicates the Ruby version in effect upon login <em>without<\/em> issuing <code>rvm use<\/code>.<\/p>\n<h3 id=\"setting-versions\" >Setting versions<\/h3>\n<p>To use a Ruby version for the life of the session, issue <code>rvm use ruby-ver<\/code>\u00a0where ruby-ver is the ruby version:<\/p>\n<pre data-language=\"shell\"><code>[myadmin]$ rvm use ruby-head\r\nruby-head - #gemset created \/home\/myadmin\/.rvm\/gems\/ruby-head\r\nruby-head - #importing gemsetfile \/.socket\/ruby\/gemsets\/default.gems evaluated to empty gem list\r\nruby-head - #generating default wrappers.............\r\nUsing \/home\/myadmin\/.rvm\/gems\/ruby-head<\/code><\/pre>\n<p>If Rubygems hasn&#8217;t been initialized yet for the given version, then gems will be populated. Use <code>rvm use --default ruby-ver<\/code> to set the default version for future logins.<\/p>\n<p>Note: <code>rvm list<\/code> will report a different default from current. Default, <em>in this context<\/em>, indicates server default and not the default set via <code>rvm use<\/code>.<\/p>\n<h3 id=\"setting-versions-as-default\" >Setting versions as default<\/h3>\n<p style=\"text-align: left\">A Ruby version can be configured as the default for a directory and its descendents by adding the Ruby version via <code>.ruby-version<\/code>. For example, to set Ruby 2.2.4 as the default interpreter under \/var\/www and its descendents, including \/var\/www\/myapp, \/var\/www\/domain2.com\/app1, and \/var\/www\/domain2.com\/app2, create a file named <code>\/var\/www\/.ruby-version<\/code> with &#8220;ruby-2.2.4&#8221;:<\/p>\n<pre style=\"text-align: left\" data-language=\"shell\"><code>echo \"ruby-2.2.4\" &gt; \/var\/www\/.ruby-version\r\nruby -v\r\n# Ruby version will be system default\r\ncd \/\r\n# Leave \/var\/www\r\ncd \/var\/www\r\n# Ruby version now queried from \/var\/www\/.ruby-version\r\nruby -v\r\n# Ruby version will output ruby 2.2.4p230<\/code><\/pre>\n<h2 id=\"see-also\" >See also<\/h2>\n<ul>\n<li>KB: <a href=\"https:\/\/kb.okra.host\/ruby\/setting-rails-passenger\/\">Setting up Rails with Passenger<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Overview Newer hosting platforms, v6+, support multiple Ruby versions through rvm. This enables you to run multiple versions of Rack and Rails using any available Ruby interpreters. Currently, versions 1.8 to 2.2 are supported. Important: Avoid using 1.8, except to shim an older application with an intent to upgrade. 1.8&#8230;<\/p>","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[66],"ht-kb-tag":[],"class_list":["post-8700","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-ruby"],"_links":{"self":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/comments?post=8700"}],"version-history":[{"count":1,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8700\/revisions"}],"predecessor-version":[{"id":8701,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8700\/revisions\/8701"}],"wp:attachment":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/media?parent=8700"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb-category?post=8700"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb-tag?post=8700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}