OS X Mavericks破坏了rbenv?

5

最近,我安装了OS X Mavericks操作系统,但它似乎破坏了我的开发环境。在运行“rails new first_app”命令后,我收到以下消息:

Your user account isn't allowed to install to the system Rubygems.
You can cancel this installation and run:

    bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to Rubygems using sudo.

Password: 
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.9.0)
Using atomic (1.1.15)
Using thread_safe (0.2.0)

Errno::EACCES: Permission denied - /Library/Ruby/Gems/2.0.0/build_info/tzinfo-0.3.39.info
An error occurred while installing tzinfo (0.3.39), and Bundler cannot continue.
Make sure that `gem install tzinfo -v '0.3.39'` succeeds before bundling.

我随后就按照要求完成了:

christohersmbp2:hartl christopherspears$ gem install tzinfo -v '0.3.39'
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

奇怪的是我确实安装了rbenv。事实上,在尝试调试此问题时,我升级了rbenv:
christohersmbp2:~ christopherspears$ brew update
Already up-to-date.
christohersmbp2:~ christopherspears$ brew upgrade rbenv ruby-build
Warning: A newer Command Line Tools release is available
Update them from Software Update in the App Store.
Error: rbenv-0.4.0 already installed
Error: ruby-build-20140225 already installed

然而,当我尝试从命令行调用rbenv时,我会收到这个错误消息:

christohersmbp2:hartl christopherspears$ rbenv
-bash: rbenv: command not found
christohersmbp2:~ christopherspears$ rbenv rehash
-bash: rbenv: command not found

我认为我已经正确设置了路径:

christohersmbp2:hartl christopherspears$ echo $PATH
/usr/local/share/python:/Users/christopherspears/.rbenv/bin:/Users/christopherspears/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

这是我在.bash_profile文件中的内容:

# rbenv stuff
export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

奇怪的是,我想我使用的是版本文件夹中的Ruby版本:

christohersmbp2:versions christopherspears$ pwd
/Users/christopherspears/.rbenv/versions
christohersmbp2:versions christopherspears$ ls
2.0.0-p247/
christohersmbp2:versions christopherspears$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]

任何提示吗?我似乎一切都做得正确。

更新:

我下载并安装了Xcode命令行工具,但好像没用:

christohersmbp2:~ christopherspears$ rbenv -bash: rbenv:未找到命令


你尝试过在升级到Mavericks后更新命令行工具吗?我知道我在升级到Mavericks后立即升级了我的命令行工具,但不记得是否必须这样做。 - craig.kaminsky
我以为我做了。好吧,我会更新命令行工具,看看会发生什么。 - Christopher Spears
2个回答

8

正如@Christoper Spears所说,卸载然后重新安装,或者更具体地说:

$ brew uninstall rbenv
$ brew install rbenv

(假设您首次使用brew安装它)。

2

哦...看来秘诀就是卸载然后重新安装rbenv。实际上,卸载并重新安装被OS X Mavericks破坏的开发工具似乎(几乎)总是解决方案。


在Yosemite中执行brew update rbenv后遇到了相同的问题,卸载并重新安装rbenv就像上面那样解决了它。 - handwovensole

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接