简体   繁体   English

Mavericks,RBENV,您的 Ruby 版本是 2.0.0,但您的 Gemfile 指定的是 2.1.1

[英]Mavericks, RBENV, Your Ruby version is 2.0.0, but your Gemfile specified 2.1.1

I've read and tried the suggestions in several , other , questions , like mine (all with accepted answers) as well as a few more hours of Google searching, but nothing worked.我已经阅读并尝试了几个其他问题中的建议, 例如我的(所有答案都已接受)以及几个小时的谷歌搜索,但没有任何效果。 That leads me to think my issue is something corrupt with a piece of Ruby/RBENV ecosystem on my computer or maybe a dreaded PATH issue.这让我认为我的问题是我的计算机上的一块 Ruby/RBENV 生态系统损坏了,或者可能是一个可怕的 PATH 问题。 I always have to run sudo to install any gems, which I've never had to do before, so that's puzzling too.我总是必须运行sudo来安装任何 gem,这是我以前从未做过的,所以这也令人费解。

Here are some outputs of files & commands I think are relevant.以下是我认为相关的文件和命令的一些输出。 If you need more information, please let me know:如果您需要更多信息,请告诉我:

.zshrc .zshrc

export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin" if which rbenv > /dev/null;
then eval "$(rbenv init - zsh)"; fi

ruby -v红宝石-v

ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]

rbenv local rbenv 本地

2.1.1

Gemfile (I've also blown out my gemfile.lock several times too) Gemfile(我也多次炸毁了我的 gemfile.lock)

source 'https://rubygems.org'

ruby '2.1.1'

gem 'rails', '4.1.4'
... [omitted for brevity]

.ruby-version .ruby 版本

2.1.1

echo $PATH回声 $PATH

/[user path]/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

I'd be grateful if anyone has any ideas about what I should try next, short of reformatting my computer.如果有人对我接下来应该尝试什么有任何想法,我将不胜感激,除了重新格式化我的电脑。

EDIT 1: Tried option B installing both of them from their git repos below as per Ben Kreeger.编辑 1:尝试了选项 B,按照 Ben Kreeger 从下面的 git repos 安装它们。 type rbenv correctly returned rbenv is a shell function and the original message kept appearing.正确返回的 rbenv type rbenv rbenv 是一个 shell 函数,原始消息不断出现。 I reinstalled Mavericks and my setup still isn't working.我重新安装了 Mavericks,但我的设置仍然无法正常工作。

EDIT 2: Any time I try to install a gem, I get a Gem::FilePermissionError saying I don't have access to the Ruby 2.0.0 folder (installed as system).编辑 2:每当我尝试安装 gem 时,我都会收到Gem::FilePermissionError说我无权访问 Ruby 2.0.0 文件夹(作为系统安装)。 Going to fiddle with RBENV some more...还要再摆弄一下RBENV...

EDIT 3: More debugging (everything below)编辑 3:更多调试(以下所有内容)

Kept erroring when installing Ruby versions with RBENV and found some people mentioning readline issues.使用 RBENV 安装 Ruby 版本时一直出错,发现有人提到readline问题。

Tried the following steps to fix readline: https://github.com/sstephenson/ruby-build/issues/550#issuecomment-40681557 , and got an error that my Xcode command line tool install was bad.尝试了以下步骤来修复 readline: https ://github.com/sstephenson/ruby-build/issues/550#issuecomment-40681557,并收到错误提示我的 Xcode 命令行工具安装错误。

Ran xcode-select --install to reinstall them.xcode-select --install重新安装它们。

Tried rbenv install 2.1.1 again, and got The Ruby openssl extension was not compiled. Missing the OpenSSL lib?再次尝试rbenv install 2.1.1 ,得到了The Ruby openssl extension was not compiled. Missing the OpenSSL lib? The Ruby openssl extension was not compiled. Missing the OpenSSL lib?

As per https://coderwall.com/p/n9bnug , I linked my OpenSSL extension with https://coderwall.com/p/n9bnug根据https://coderwall.com/p/n9bnug ,我将我的 OpenSSL 扩展与https://coderwall.com/p/n9bnug链接

Reset versions of Ruby: rbenv local 2.1.1 rbenv global 2.1.1 and rbenv rehash重置 Ruby 版本: rbenv local 2.1.1 rbenv global 2.1.1rbenv rehash

Everything seems to indicate bundler is trying to use my system Ruby install (2.0.0-p247) instead of what RBENV is specifying.一切似乎都表明捆绑器正在尝试使用我的system Ruby 安装 (2.0.0-p247) 而不是 RBENV 指定的内容。 Baffled where the missing link is.不知所措的环节在哪里。

WOW, JUST WOW. 哇,只是哇。

All I had to do was gem install bundler and then rbenv rehash . 我所要做的只是gem install bundler然后是rbenv rehash Everything worked. 一切正常。

The original error message pointed me to a problem with RBENV or my Ruby version when in reality it was just falling back on an old version of bundler. 原始的错误消息向我指出了RBENV或我的Ruby版本的问题,而实际上它只是落在旧版本的bundler上。

Why wouldn't I have received the more standard this needs bundler version [xxxx]... error instead of telling me my Ruby version is specified incorrectly? 为什么我不会收到更多标准this needs bundler version [xxxx]...错误而不是告诉我我的Ruby版本指定不正确?

If you're having to use sudo to install gems, then something's likely wrong with your rbenv installation. 如果你不得不使用sudo来安装gem,那么你的rbenv安装可能会出现问题。 I'm of the opinion that if you're on OS X and you have to run sudo to install gems or packages, you're doing it wrong (especially if you've got homebrew installed)! 我认为如果你在OS X上并且你必须运行sudo来安装gems或者包,那你就错了(特别是如果你已经安装了homebrew )! You've got two options — 你有两个选择 -

Option A : Alter your .zshrc to be a little more friendly with your $PATH and your rbenv settings. 选项A:改变你的.zshrc是一个小更友好与您的$PATH和你rbenv设置。 Note here that /usr/local/bin is just being prepended to $PATH , which itself is going to set to a proper default by your system (Mavericks). 请注意, /usr/local/bin只是前缀为$PATH ,它本身将由您的系统(Mavericks)设置为正确的默认值。 Make those two lines you posted look like this: 让你发布的那两行看起来像这样:

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

Then ensure that you close any and all shells and open new ones to load the new settings. 然后确保关闭所有shell并打开新shell以加载新设置。 Then when you run echo $PATH it should look similar to... 然后,当你运行echo $PATH它看起来应该类似于......

[home path]/.rbenv/shims:[home path]/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Option B : Since I'm more familiar with installing rbenv via git, you may try nuking your homebrew-installed rbenv installation by brew remove rbenv , and follow the directions specified on rbenv's github page (and don't forget to install ruby-build as well ). 选项B :由于我更熟悉通过git安装rbenv,你可以尝试通过brew remove rbenv你自制的rbenv安装,并按照rbenv的github页面上指定的指示进行操作 (不要忘记安装ruby-build以及 )。 This includes removing any rbenv-specific lines in your .zshrc and setting them to what rbenv recommends . 这包括在你删除任何特定rbenv线.zshrc和设置他们推荐什么rbenv

You can always check the sanity of your rbenv installation by running type rbenv at a command prompt. 您始终可以通过在命令提示符下运行type rbenv来检查rbenv安装的type rbenv If all is well, you should at least be getting back "rbenv is a function" . 如果一切顺利,你至少应该回来"rbenv is a function"

I solved this by running first我通过运行解决了这个问题

rbenv shell --unset

Then I was able to set the version via然后我可以通过

rbenv local <ruby_version>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 rbenv您的Ruby版本是2.0.0,但您的Gemfile指定为2.1.2 - rbenv Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2 rbenv您的Ruby版本是2.0.0,但是您的Gemfile指定了2.1.2,但是唯一安装的版本是2.1.2 - rbenv Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2 but the only version installed is 2.1.2 Bundler :: RubyVersionMismatch:您的Ruby版本是1.9.3,但您的Gemfile指定为2.0.0 - Bundler::RubyVersionMismatch: Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0 如何修复“您的 Ruby 版本是 1.9.3,但您的 Gemfile 指定了 2.0.0” - How to fix "Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0" 您的Ruby版本是2.0.0,但是您的Gemfile指定了2.1.2,而没有更新 - Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2 without update Gemfile 修复rbenv和rails 5.2的“您的Ruby版本为2.4.4,但您的Gemfile指定了2.5.1”的错误 - Fixing 'Your Ruby version is 2.4.4, but your Gemfile specified 2.5.1' error with rbenv and rails 5.2 在RubyMine中:“您的Ruby版本是2.0.0,但是您的Gemfile指定了1.9.3(Bundler :: RubyVersionMismatch)” - In RubyMine: “Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3 (Bundler::RubyVersionMismatch)” 为什么会出现此错误您的Ruby版本是2.0.0,但是您的Gemfile指定了2.2.2 - Why do I get this error Your Ruby version is 2.0.0, but your Gemfile specified 2.2.2 Rails控制台内的Vim-您的Ruby版本是2.0.0,但是您的Gemfile指定了2.1.2 - Vim inside rails console - Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2 “您的Ruby版本是2.1.3,但是您的Gemfile指定了2.1.1”,即使我使用了rails new这样的简单命令,我也会收到此错误 - “Your Ruby version is 2.1.3, but your Gemfile specified 2.1.1” I receive this error even I use simple command like rails new
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM