设置环境,OSX rbenv和捆绑包之战 [英] Setting up env, OSX rbenv and bundle battle

查看:106
本文介绍了设置环境,OSX rbenv和捆绑包之战的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我刚从ubuntu切换到Mac,设置环境并不像承诺的那样容易.

这是我遵循的过程.

  1. 安装了xcode-然后进入偏好并下载了command line tools
  2. 然后通过运行gcc --version

    验证是否安装了正确的版本.

    i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
    Copyright (C) 2007 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

  3. 然后安装自制软件$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
  4. 跑了brew doctor,这就是我得到的

    Your system is ready to brew.

5.已安装git brew update + brew install git

6.通过ssh将我的电脑链接到我的git帐户

7.已安装Rbenv

$ brew update
$ brew install rbenv
$ brew install ruby-build

eval "$(rbenv init -)"添加到了我的.bash_profile文件中

  1. 运行rbenv install -list以查看我可以安装然后运行的所有版本

    $ rbenv install 1.9.3-p327
    $ rbenv global 1.9.3-p327
    

  2. (我应该重新整理rbenv但我忘了)然后我运行了gem install bundler

  3. 然后进入我的一个仓库中并运行bundle install,它因错误而崩溃

    Gem::InstallError: better_errors requires Ruby version >= 1.9.2.
    An error occurred while installing better_errors (0.7.0), and Bundler cannot continue.
    Make sure that `gem install better_errors -v '0.7.0'` succeeds before bundling.
    

运行ruby -v并发现它在1.8.7球"上-我惊呼

  1. 为了解决这个问题,我做了以下rbenv rehash

  2. ruby -v然后得到ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.3.0]然后高个子自己

  3. 然后尝试运行捆绑软件,出现相同的错误?

    $ which bundle
    /usr/bin/bundle
    
    $ which gem
    /Users/fortknokx/.rbenv/shims/gem
    

所以这就是我现在感到困惑的地方.正如我所说的,这是我使用Mac的第三天,我对了解$ PATH感到很陌生,我确信自己在某个地方犯了规.我愿意接受的任何建议.

ps,这就是我的.bash_profile中的内容

export PATH="/usr/local/bin:/usr/local/bin/sublime:~/bin:$PATH"
eval "$(rbenv init -)"

解决方案

问题似乎是您使用的是安装了系统ruby的捆绑程序,而不是使用rbenv ruby​​安装的.

运行ruby --version以确保您的rbenv红宝石处于活动状态,然后运行gem install bundler,然后运行rbenv rehash,然后尝试重新安装gems,看看是否可行.

So i have just swapped over to mac from ubuntu and setting up the env has not been as easy as promised.

this is the process i followed.

  1. installed xcode - then went into the prefrences and downloaded the command line tools
  2. then verified that the right version was installed, by running gcc --version

    i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
    Copyright (C) 2007 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

  3. then installed homebrew $ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
  4. ran brew doctor and this is what i get

    Your system is ready to brew.

5.installed git brew update + brew install git

6.linked my pc to my git account via ssh

7.installed Rbenv

$ brew update
$ brew install rbenv
$ brew install ruby-build

added eval "$(rbenv init -)" to my .bash_profile file

  1. ran rbenv install -list to see all the versions i could install and then ran

    $ rbenv install 1.9.3-p327
    $ rbenv global 1.9.3-p327
    

  2. (i should have rehashed rbenv but i forgot) i then ran gem install bundler

  3. then went into one of my repo's and ran bundle install which blew up with errors

    Gem::InstallError: better_errors requires Ruby version >= 1.9.2.
    An error occurred while installing better_errors (0.7.0), and Bundler cannot continue.
    Make sure that `gem install better_errors -v '0.7.0'` succeeds before bundling.
    

ran ruby -v and saw that it was on 1.8.7 "balls" - i exclaimed

  1. to remedy this i did the following rbenv rehash

  2. ruby -v and got ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.3.0] then high fived myself

  3. then tried to run bundle and the same error comes up ??

    $ which bundle
    /usr/bin/bundle
    
    $ which gem
    /Users/fortknokx/.rbenv/shims/gem
    

so this is now where i stand confused as heck. as i said this is my third day using mac and i am pretty new to understanding the $PATH i am sure that i made a foul up somewhere. any advice i am open to.

ps this is what i have in my .bash_profile

export PATH="/usr/local/bin:/usr/local/bin/sublime:~/bin:$PATH"
eval "$(rbenv init -)"

解决方案

The problem seems to be that you're using a system ruby installed bundler, and not one installed with your rbenv ruby.

Run ruby --version to make sure your rbenv ruby is active, then run gem install bundler followed by rbenv rehash and then try reinstalling your gems and see if that works.

这篇关于设置环境,OSX rbenv和捆绑包之战的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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