博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何在Ubuntu上安装Rails并将Ruby更新到最新版本
阅读量:2520 次
发布时间:2019-05-11

本文共 3730 字,大约阅读时间需要 12 分钟。

A couple of months ago, when I learned Ruby-on-Rails for the first time, I had to work on a collaborative project with a coding partner. We kept running into issues, as he had a different version of Rails and Buby setup for the project. I couldn't wrap my head around how to install the versions the project needed.

几个月前,当我第一次学习Ruby-on-Rails时,我不得不与编码合作伙伴一起进行协作项目。 我们一直遇到问题,因为他为该项目设置了不同版本的Rails和Buby。 我无法确定如何安装项目所需的版本。

Here's the guide I wish I had. It also shows you how to switch the version of Ruby or Rails you're using, depending on the projects you're working on.

这是我希望得到的指南。 它还显示了如何根据您正在处理的项目来切换所使用的Ruby或Rails的版本。

First, let's get the latest version of Ruby installed. To do this, we need to install a package called RVM - Ruby version manager. This package lets us install ANY version of Ruby on our Ubuntu machine and allows us to switch between versions.

首先,让我们获取最新版本的Ruby。 为此,我们需要安装一个名为RVM的软件包-Ruby版本管理器。 该软件包使我们可以在Ubuntu计算机上安装Ruby的任何版本,并允许我们在版本之间进行切换。

All the code here will be run using the Ubuntu CLI/terminal.

此处的所有代码都将使用Ubuntu CLI /终端运行。

安装RVM (Installing RVM)

  1. First, we need to install a pre-requisite. Open up your Ubuntu terminal and type the command:

    首先,我们需要安装一个先决条件。 打开您的Ubuntu终端并输入命令:
sudo apt-get install software-properties-common

Next, we need to add the PPA (Personal Package archive). A PPA is how we get files distributed by developers that are yet to make it to the official Ubuntu package/app store.

接下来,我们需要添加PPA(个人软件包档案) 。 PPA是我们如何获取尚未发布到官方Ubuntu软件包/应用商店的开发人员分发的文件的方式。

It's also a way for developers to distribute the latest versions of their software while waiting for Ubuntu to test and publish that software in the official store.

这也是开发人员在等待Ubuntu在官方商店中测试和发布该软件的同时分发其软件的最新版本的一种方式。

sudo apt-add-repository -y ppa:rael-gc/rvm

The command above adds the PPA to the list of locations we can download packages from on our Ubuntu machine.

上面的命令将PPA添加到我们可以从Ubuntu机器上下载软件包的位置列表中。

Next, let's refresh our list of packages by running:

接下来,让我们通过运行刷新软件包列表:

sudo apt-get update

sudo apt-get update

Finally, let's install RVM itself.

最后,让我们安装RVM本身。

sudo apt-get install rvm

Now restart your terminal for your changes to take effect. Then, type rvm version and hit enter to check that rvm is installed. You should get a response like this:

现在,重新启动终端,以使更改生效。 然后,键入rvm version并按enter键以检查是否已安装rvm。 您应该得到这样的响应:

rvm 1.29.10 (manual) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin []

rvm 1.29.10 (manual) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [ ]

安装Ruby (Installing Ruby )

Now we can install the latest Ruby version which is 2.7.1. Run the command rvm install 2.7.1. Alternatively, you can run rvm install ruby which will install the latest stable version (this will install v2.7.0).To see what Ruby versions you have installed, run rvm ls. To switch between Ruby versions, run rvm use <version_number> (for example, rvm use 2.7.1).

现在,我们可以安装最新的Ruby版本2.7.1。 运行命令rvm install 2.7.1 。 或者,您可以运行rvm install ruby ,它将安装最新的稳定版本(这将安装v2.7.0)。要查看已安装的Ruby版本,请运行rvm ls 。 要在Ruby版本之间切换,请运行rvm use <version_number> (例如, rvm use 2.7.1 )。

安装Ruby-on-Rails (Installing Ruby-on-Rails)

The latest version of Rails is at 6.03. Rails is simply a Ruby gem, and with Ruby installed we can install Rails! Run gem install rails to install the latest version of Rails.Finally, to check that all went well, run rails -v. You should get Rails 6.0.3.2 back, as this is the latest version at the time of publishing this article. You can now start your first Rails project by typing rails new myapp.

Rails的最新版本是6.03。 Rails只是一个Ruby宝石,安装了Ruby之后,我们就可以安装Rails! 运行gem install rails安装最新版本的Rails。最后,检查是否一切正常,运行rails -v 。 您应该重新获得Rails 6.0.3.2 ,因为这是发布本文时的最新版本。 现在,您可以通过键入rails new myapp来启动第一个Rails项目。

Hey, you're now on Rails!

嘿,您现在在Rails上!

翻译自:

转载地址:http://vmgwd.baihongyu.com/

你可能感兴趣的文章
CDOJ_24 八球胜负
查看>>
Alpha 冲刺 (7/10)
查看>>
一款jQuery打造的具有多功能切换的幻灯片特效
查看>>
SNMP从入门到开发:进阶篇
查看>>
@ServletComponentScan ,@ComponentScan,@Configuration 解析
查看>>
unity3d 射弹基础案例代码分析
查看>>
thinksns 分页数据
查看>>
os模块
查看>>
LINQ to SQL vs. NHibernate
查看>>
基于Angular5和WebAPI的增删改查(一)
查看>>
windows 10 & Office 2016 安装
查看>>
最短路径(SP)问题相关算法与模板
查看>>
js算法之最常用的排序
查看>>
Python——交互式图形编程
查看>>
经典排序——希尔排序
查看>>
团队编程项目作业2-团队编程项目代码设计规范
查看>>
英特尔公司将停止910GL、915GL和915PL芯片组的生产
查看>>
Maven配置
查看>>
HttpServletRequest /HttpServletResponse
查看>>
SAM4E单片机之旅——24、使用DSP库求向量数量积
查看>>