如何在Windows上将Ruby添加到PATH变量中? [英] How do I add Ruby to the PATH variable on Windows?

查看:204
本文介绍了如何在Windows上将Ruby添加到PATH变量中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Ruby,但是我仍然需要将它添加到PATH变量中。我在线上发现了如何使用命令行手动添加它:

 设置PATH = C:\Ruby200-x64\\ \\ bin;%PATH%

但在我尝试之前,我想确定它不会覆盖PATH变量中的当前内容。 (我没有这个东西的经验,所以我不知道该怎么做)。



提前感谢你的帮助!

解决方案

首先,请注意,这个问题不是真的关于Ruby,而是关于如何在Windows中设置路径(如果要添加可执行文件,它的工作方式相同)不同于Ruby)



其次,您不会覆盖PATH环境变量,因为您将现有内容添加到您正在设置的新对象中:

 设置PATH = C:\Ruby200-x64\bin;%PATH%
/ pre>

%PATH%是PATH变量的当前内容。



考虑使用

 设置PATH =%PATH%; C:\Ruby200-x64\ bin 

相反,这将使您的操作系统在搜索ruby bin文件夹之前搜索原始路径。也许它在现代电脑上几乎没有区别,但是我的旧DOS天声称第二个解决方案更好。



第三和最后一点,在Windows中,您可以设置环境变量在控制面板/系统属性
如何到达取决于您的操作系统的版本,但如果您搜索环境变量和系统变量,您应该到那里。


I have Ruby installed, but I still need to add it to the PATH variable. I found something online for how to manually add it using the command line:

set PATH=C:\Ruby200-x64\bin;%PATH%

But before I try it, I want to be sure it's not going to overwrite what's currently in the PATH variable. (I have no experience with this stuff so I don't know what to expect).

Thanks in advance for your help!

解决方案

first, notice that this question is not really about Ruby, rather about how to set a path in windows (it work the same way if you want to add an executable different from Ruby)

second, you are not overwriting the PATH environment variable because you add the existing content of the same to the new one you are setting in:

set PATH=C:\Ruby200-x64\bin;%PATH%

the %PATH% is the current content of the PATH variable.

Consider using

 set PATH=%PATH%;C:\Ruby200-x64\bin

instead, this will make your OS search the original path before searching the ruby bin folder. Maybe it makes few difference on modern computers, but my old DOS days claim the second solution is better.

third and last point, in Windows you can set environment variables in control panel / system properties How to get there depends on the version of your OS, but if you search for the ambient variables and system variables you should get there.

这篇关于如何在Windows上将Ruby添加到PATH变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆