MacPorts如何安装软件包?如何激活通过MacPorts完成的Ruby安装? [英] How does MacPorts install packages? How can I activate a Ruby installation done via MacPorts?

查看:89
本文介绍了MacPorts如何安装软件包?如何激活通过MacPorts完成的Ruby安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用以下命令行在我的机器(PPC,Mac OSX 10.5.7)上安装ruby19

After trying to install ruby19 on my machine (PPC, Mac OSX 10.5.7) using the following commandline

sudo port install ruby19

红宝石的版本没有改变

ruby -v => ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]

我假设我在Mac上安装了两个版本,但是现在如何使用最新版本呢?

I assume that i have two versions of it installed on my mac, but how do i use the latest one now?

推荐答案

要使用特定的ruby版本,如果安装了两个版本,则可以指定到所需版本的绝对路径.例如. /your/path/to/ruby​​或者您可以在.profile中更改PATH设置

To use a specific ruby version if you have two versions installed you can either specify an absolute path to the one you want. E.g. /your/path/to/ruby Or you can change your PATH setting in your .profile

您可以键入

which ruby

查看当前使用的ruby可执行文件的路径.

to see the path to the ruby executable that is used at the moment.

使用

echo $PATH

您可以看到当前的PATH设置.您必须将新红宝石二进制文件的路径放在PATH的前面,这样才能在另一个红宝石二进制文件之前找到它.

You can see the current PATH setting. You have to prepend the path to your new ruby binary to the PATH so that it will be found before the other one.

正如ayaz已经提到的那样,您的macports内容的默认位置在/opt/local中.如果在路径前面添加/opt/local/bin,应该没问题. (确保更改后启动一个新的终端窗口-除非您再次明确地来源" .profile文件,否则它们不会在当前会话中被拾取)

As ayaz already mentions, the default location of your macports stuff is in /opt/local. If you add /opt/local/bin in front of your path it should be fine. (Make sure to start a new terminal window after the change - they will not be picked up in your current session unless you explicitely 'source' the .profile file again)

请注意:将/opt/local/bin放在路径之前,shell总是 优先于那里的二进制文件,而不是以后找到的二进制文件,如果您依赖于特定版本,这可能是个问题在/bin,/sbin或/usr/sbin中-根据您的情况,这意味着您不应该这样做(如果您的计算机正在处理敏感数据和/或在银行等),或者只需要记住它可以成为一个问题(如果您的计算机是普通的开发机器).

One note of caution: after prepending /opt/local/bin to your path the shell will always prefer binaries in there to binaries found later, this can be an issue if you depend on specific versions in /bin, /sbin or /usr/sbin -- depending on your situation this means that you should not do it (if your computer is processing sensitive data and/or in a bank or something) or just have to remember that it could be an issue (if your computer is a normal development machine).

请参见 http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/,如果您需要更多有关如何在osx上设置PATH的提示.

See http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/ if you need some more hints on how to set your PATH on osx.

这篇关于MacPorts如何安装软件包?如何激活通过MacPorts完成的Ruby安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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