简体   繁体   English

Ruby安装

[英]Ruby Installation

Silly question. 愚蠢的问题。 I went to http://rubyinstaller.org/downloads/ and installed Ruby 1.9.2, but when I pull up command prompt and type ruby -v it's not recognized as a command. 我去了http://rubyinstaller.org/downloads/并安装了Ruby 1.9.2,但是当我拉出命令提示符并输入ruby -v它不被识别为命令。 Am I doing something wrong? 难道我做错了什么? I had version 1.8.6 installed, but I couldn't figure out how to upgrade my Ruby version so I uninstalled it and tried a fresh install. 我安装了1.8.6版,但我无法弄清楚如何升级我的Ruby版本,所以我卸载它并尝试全新安装。

Did you add your bin Directory to the PATH? 您是否已将bin目录添加到PATH?

Ok, when you install it, it will go in a directory: 好的,当你安装它时,它会进入一个目录:

ex: c:/program files/ruby1.9.x/ 例如:c:/ program files / ruby​​1.9.x /

inside you will have a /bin directory which contains all the command for the command line. 在你的内部将有一个/ bin目录,其中包含命令行的所有命令。

To be able to use ruby in the command line, you must add it to your $PATH variable in the OS environment. 为了能够在命令行中使用ruby,必须将其添加到OS环境中的$ PATH变量中。 ex: path=c:/program files/ruby1.9.x/bin;etc... 例如:path = c:/ program files / ruby​​1.9.x / bin; etc ...

You need to add Ruby to your path variable, regardless of your operating system. 无论您的操作系统如何,都需要将Ruby添加到路径变量中。

Say you're using Windows, and Ruby is installed in C:\\Program Files\\ruby1.9.2\\ You'll need to find out which folder the ruby executable is in ( ruby.exe ). 假设你正在使用Windows,并且Ruby安装在C:\\Program Files\\ruby1.9.2\\你需要找出ruby可执行文件所在的文件夹( ruby.exe )。 Sometimes it'll be in the main folder, but usually for open source packages it'll be in the subfolder bin . 有时它会在主文件夹中,但通常对于开源软件包,它将位于子文件夹bin To add ruby to your path, then, you'll need to use C:\\Program Files\\ruby1.9.1\\bin 要将ruby添加到路径中,您需要使用C:\\Program Files\\ruby1.9.1\\bin

You can do this on the command line like so: 您可以在命令行上执行此操作,如下所示:

path = %PATH%;C:\\Program Files\\ruby1.9.2\\bin

Note that %PATH% has a percent sign on either side, and that there's a semi-colon separating it from the new value. 请注意, %PATH%在任一侧都有一个百分号,并且有一个分号将它与新值分开。 You'll have to type it in each time you start a new command line window, but it might be a good idea to try this the first time, because any mistakes in typing it in won't be permanent. 你必须在每次启动一个新的命令行窗口时输入它,但是第一次尝试这个时可能是个好主意,因为输入它的任何错误都不是永久性的。

To change it permanently you can find it in Control Panel > System > Advanced System Settings . 要永久更改它,您可以在Control Panel > System > Advanced System Settings找到它。 Switch to the Advanced tab, then click Environment Variables... Find path under System Variables, and add ;C:\\Program Files\\ruby1.9.2\\bin to the end. 切换到“ Advanced选项卡,然后单击“ Environment Variables...在“系统变量”下查找path ,并添加;C:\\Program Files\\ruby1.9.2\\bin到最后。 Note that you still need a semi-colon to separate the new value from everything else, and that you don't need %PATH% this time (in face, the value you see is what %PATH% represents). 请注意,您仍然需要使用分号来将新值与其他所有值分开,并且这次不需要%PATH% (面对,您看到的值是%PATH%代表的值)。 Once you've done that, restart any command windows you had open, and you should be able to access things just fine! 一旦你完成了,重新启动你打开的任何命令窗口,你应该能够正常访问的东西!

These instructions will be different if you're using Linux or a Mac - try googling environment variables if you'd like to know more! 如果您使用的是Linux或Mac,这些说明会有所不同 - 如果您想了解更多信息,请尝试谷歌搜索环境变量!

Install RVM with RUBY 使用RUBY安装RVM

sudo apt-get install curl sudo apt-get install curl

after install install rvm also ruby 安装后安装rvm也是ruby

\\curl -sSL https://get.rvm.io | \\ curl -sSL https://get.rvm.io | bash -s stable --ruby bash -s stable --ruby

if you face issue with the above line (Failed to connect to get.rvm.io port 443: Network is unreachable) 如果您遇到上述行的问题(无法连接到get.rvm.io端口443:网络无法访问)

in browser go to https://get.rvm.io save the page in any location 在浏览器中转到https://get.rvm.io将页面保存在任何位置

make it executable file name rvm-installer 使其成为可执行文件名rvm-installer

chmod +x rvm-installer chmod + x rvm-installer

then do the following 然后执行以下操作

bash rvm-installer stable --ruby bash rvm-installer stable --ruby

source /home/username/.rvm/scripts/rvm 来源/home/username/.rvm/scripts/rvm

then check rvm list 然后检查rvm列表

note the version of ruby listing on terminal 注意终端上ruby列表的版本


if you failed to install due to the dependency 如果由于依赖性而无法安装

sudo apt-get update sudo apt-get update

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev

if the above steps not installed ruby latest version you can do it by rvm install ruby-2.1.1 如果上面的步骤没有安装ruby最新版本你可以通过rvm install ruby​​-2.1.1来实现

installation using rvm 使用rvm安装

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev

curl -L https://get.rvm.io | curl -L https://get.rvm.io | bash -s stable bash -s稳定

source ~/.rvm/scripts/rvm source~ / .rvm / scripts / rvm

echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc echo“source~ / .rvm / scripts / rvm”>>〜/ .bashrc

rvm install 2.1.1 rvm install 2.1.1

rvm use 2.1.1 --default ruby -v rvm使用2.1.1 - 默认ruby -v


**change terminal to login shell. **将终端更改为登录shell。 open a new terminal ** 开新终端**

then rvm use 2.1.1 => ( 2.1.1 version ) 然后rvm使用2.1.1 =>(2.1.1版本)

then its done! 它完成了!

pd@admin:~$ ruby -v pd @ admin:〜$ ruby -v

ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux] ruby 2.1.1p76(2014-02-24修订版45161)[x86_64-linux]

programmers keep on coding with ruby. 程序员继续使用ruby进行编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM