V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Ethan25
V2EX  ›  Ruby on Rails

mac os x 10.6.5 升级 ruby 1.9.2 的问题

  •  
  •   Ethan25 · 2011-01-05 09:54:11 +08:00 · 10269 次点击
    这是一个创建于 5101 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近我升级了到了雪豹系统 是全新安装的 然后重新配置下 ror 环境 我个人觉得macport 不好用 所以就没用它安装 ruby 用了homebrew 上次在10.5.8 输入下面这个命令就装好了 但是 10.6.5 不行 看起来貌似提示说 装好了 可以 ruby -v 一下还是1.8.7。

    $ brew install ruby
    24 条回复    1970-01-01 08:00:00 +08:00
    Ethan25
        1
    Ethan25  
    OP
       2011-01-05 09:55:28 +08:00
    ==> Downloading ftp://ftp.cwru.edu/pub/bash/readline-6.1.tar.gz
    File already downloaded and cached to /Users/ez6490/Library/Caches/Homebrew
    ==> Downloading patches
    ######################################################################## 100.0%
    ==> Patching
    patching file complete.c
    patching file patchlevel
    patching file readline.h
    patching file patchlevel
    ==> ./configure --prefix=/usr/local/Cellar/readline/6.1 --mandir=/usr/local/Cell
    ==> make install
    ==> Caveats
    This formula is keg-only, so it is not symlinked into Homebrew's prefix.
    The formula provides the following rationale:

    OS X provides the BSD Readline library. In order to prevent conflicts when
    programs look for libreadline we are defaulting this GNU Readline installation
    to keg-only.
    Ethan25
        2
    Ethan25  
    OP
       2011-01-05 09:56:05 +08:00
    Generally there are no consequences of this for you, however if you build
    your own software and it requires this formula, you may want to run this
    command to link it into the Homebrew prefix:
    $ brew link readline
    ==> Summary
    /usr/local/Cellar/readline/6.1: 32 files, 2.0M, built in 30 seconds
    ==> Downloading http://pyyaml.org/download/libyaml/yaml-0.1.3.tar.gz
    ######################################################################## 100.0%
    ==> ./configure --prefix=/usr/local/Cellar/libyaml/0.1.3
    ==> make install
    /usr/local/Cellar/libyaml/0.1.3: 5 files, 392K, built in 16 seconds
    ==> Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p136.tar.bz2
    ######################################################################## 100.0%
    ==> ./configure --prefix=/usr/local/Cellar/ruby/1.9.2-p136 --with-readline-dir=/
    ==> make
    ==> make install
    ==> Caveats
    Consider using RVM or Cinderella to manage Ruby environments:
    * RVM: http://rvm.beginrescueend.com/
    * Cinderella: http://www.atmos.org/cinderella/

    NOTE: By default, gem installed binaries will be placed into:
    /usr/local/Cellar/ruby/1.9.2-p136/bin

    You may want to add this to your PATH.
    ==> Summary
    /usr/local/Cellar/ruby/1.9.2-p136: 10570 files, 60M, built in 4.1 minutes

    $ ruby -v
    ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
    Ethan25
        3
    Ethan25  
    OP
       2011-01-05 09:57:33 +08:00
    后来我尝试了一下rvm 但是安装完 我就崩溃了 代码如下

    $ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    109 986 109 986 0 0 1626 0 --:--:-- --:--:-- --:--:-- 3851
    Cloning into rvm...
    remote: Counting objects: 16558, done.
    remote: Compressing objects: 100% (4467/4467), done.
    remote: Total 16558 (delta 11155), reused 15843 (delta 10649)
    Receiving objects: 100% (16558/16558), 2.94 MiB | 8 KiB/s, done.
    Resolving deltas: 100% (11155/11155), done.

    RVM: Shell scripts enabling management of multiple ruby environments.
    RTFM: http://rvm.beginrescueend.com/
    HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)

    Installing RVM to /Users/ez6490/.rvm/
    Correct permissions for base binaries in /Users/ez6490/.rvm/bin...
    Copying manpages into place.

    Notes for Darwin ( Mac OS X )
    For Snow Leopard be sure to have Xcode Tools Version 3.2.1 (1613) or later
    You should download the latest Xcode tools from developer.apple.com.
    (This is since the dvd install for Snow Leopard contained bugs).

    If you intend on installing MacRuby you must install LLVM first.
    If you intend on installing JRuby you must install the JDK.
    If you intend on installing IronRuby you must install Mono (version 2.6 or greater is recommended).

    To seamlessly abandon the Apple-installed system ruby (ruby 1.8.7 patchlevel 174 for Snow Leopard):

    rvm install 1.8.7 # installs patch 302: closest supported version
    rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system # migrate your gems
    rvm --default 1.8.7
    Ethan25
        4
    Ethan25  
    OP
       2011-01-05 09:58:21 +08:00
    You must now complete the install by loading RVM in new shells.

    1) Place the folowing line at the end of your shell's loading files
    (.bashrc or .bash_profile for bash and .zshrc for zsh),
    after all PATH/variable settings:

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

    You only need to add this line the first time you install rvm.

    2) Ensure that there is no 'return' from inside the ~/.bashrc file,
    otherwise rvm may be prevented from working properly.


    This means that if you see something like:

    '[ -z "$PS1" ] && return'

    then you change this line to:

    if [[ -n "$PS1" ]] ; then

    # ... original content that was below the '&& return' line ...

    fi # <= be sure to close the if at the end of the .bashrc.

    # This is a good place to source rvm v v v
    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

    EOF - This marks the end of the .bashrc file

    Be absolutely *sure* to REMOVE the '&& return'.

    If you wish to DRY up your config you can 'source ~/.bashrc' at the bottom of your .bash_profile.

    Placing all non-interactive (non login) items in the .bashrc,
    including the 'source' line above and any environment settings.

    3) CLOSE THIS SHELL and open a new one in order to use rvm.


    Installation of RVM to /Users/ez6490/.rvm/ is complete.
    Ethan25
        5
    Ethan25  
    OP
       2011-01-05 09:58:33 +08:00
    ez6490,

    Thank you very much for using RVM! I sincerely hope that RVM helps to
    make your work both easier and more enjoyable.

    If you have any questions, issues and/or ideas for improvement please
    join#rvm on irc.freenode.net and let me know, note you must register
    (http://bit.ly/5mGjlm) and identify (/msg nickserv <nick> <pass>) to
    talk, this prevents spambots from ruining our day.

    My irc nickname is 'wayneeseguin' and I hang out in #rvm typically

    ~09:00-17:00EDT and again from ~21:00EDT-~23:00EDT

    If I do not respond right away, please hang around after asking your
    question, I will respond as soon as I am back. It is best to talk in
    #rvm itself as then other users can help out should I be offline.

    Be sure to get head often as rvm development happens fast,
    you can do this by running 'rvm get head' followed by 'rvm reload'
    or opening a new shell

    w⦿‿⦿t

    ~ Wayne


    $ rvm notes
    -bash: rvm: command not found

    我刚刚开始接触编程 比较小白 所以希望大家多帮帮忙 在这里先多谢了 。
    lainuo
        6
    lainuo  
       2011-01-05 10:36:50 +08:00
    source一下, 或者新开一个shell看看.
    ashchan
        7
    ashchan  
       2011-01-05 11:17:30 +08:00
    rvm是全宇宙最方便的ruby安装工具。你确定装完后把这行加入了.bash_login (或.bash_profile,看你的shell原先用的是什么)了吗:

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

    加入后,source .bash_login或新开一个Terminal窗口。然后 rvm install 1.9.2
    huacnlee
        8
    huacnlee  
       2011-01-05 12:01:22 +08:00
    用 RVM 安装。非常方便
    Ethan25
        9
    Ethan25  
    OP
       2011-01-05 17:48:08 +08:00
    @lainuo source 是什么? 命令吗?还是?

    怎么打开shell 看呢?
    Ethan25
        10
    Ethan25  
    OP
       2011-01-05 18:14:29 +08:00
    @ashchan .bash_login 或.bash_profile,要怎么加入?

    怎么看 shell 原来用的什么
    Ethan25
        11
    Ethan25  
    OP
       2011-01-05 18:15:22 +08:00
    @huacnlee 能详细点 说明吗?
    roamlog
        12
    roamlog  
       2011-01-05 20:53:24 +08:00
    完全不懂命令行吗?
    Ethan25
        13
    Ethan25  
    OP
       2011-01-06 00:37:59 +08:00
    @roamlog ls cd 什么的基本的知道 其他的就不懂了
    huacnlee
        14
    huacnlee  
       2011-01-06 00:44:33 +08:00 via iPad
    @Ethan25 RVM官方有文档,注意安装完后红色的提示。也就是 @ashchan 哥说的那些
    Ethan25
        15
    Ethan25  
    OP
       2011-01-07 04:49:50 +08:00
    @huacnlee 不太懂怎么加[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"


    T T
    n2n3
        16
    n2n3  
       2011-01-07 07:39:20 +08:00
    You can download MacRuby 0.8 as a standalone binary installer.

    http://www.macruby.org/
    Ethan25
        17
    Ethan25  
    OP
       2011-01-08 16:42:53 +08:00
    @n2n3 macruby 和 ruby 不太一样吧
    chouti
        18
    chouti  
       2011-01-19 18:35:03 +08:00
    @Ethan25

    假设你用的是 .bash_profile

    那么在终端 sudo vim ~/.bash_profile

    打开文件之后,把 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 加入到文件的末尾

    按 Esc 键后输入 :wq 保存退出

    然后再输入 source ~/.bash_profile

    就可以了,再 rvm note 应该就没有问题了
    bwlinux
        19
    bwlinux  
       2011-01-25 10:49:04 +08:00
    如果不想升级ruby,只是想用ror 3。就是sudo gem update,就好了。
    如果要想ruby 1。9。2,这个需要折腾下。
    liluo
        20
    liluo  
       2011-08-26 17:14:31 +08:00
    NOTE: By default, gem installed binaries will be placed into:
    /usr/local/Cellar/ruby/1.9.2-p136/bin

    You may want to add this to your PATH.


    根据这些提示,把 /usr/local/Cellar/ruby/1.9.2-p136/bin 加入到PATH,比如:
    export PATH=/usr/local/Cellar/ruby/1.9.2-p136/bin
    izon90
        21
    izon90  
       2011-10-09 22:06:29 +08:00
    还是楼上的一行export PATH=/usr/local/Cellar/ruby/1.9.2-p136/bin解决问题了。
    roamlog
        22
    roamlog  
       2011-10-09 22:35:04 +08:00 via iPhone
    推荐用 rvm
    qiang1012
        24
    qiang1012  
       2012-02-18 12:50:30 +08:00
    rvm --default 1.9.2
    可以吗?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3671 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 00:52 · PVG 08:52 · LAX 16:52 · JFK 19:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.