升级El Capitan后如何更新Rails。

6

我刚刚把系统升级到了El Capitan,但是当我启动rails服务器时(在Yosemite上完全正常),出现了以下警告。

Ignoring bcrypt-3.1.10 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.10
Ignoring bcrypt-ruby-3.1.2 because its extensions are not built.  Try: gem pristine bcrypt-ruby --version 3.1.2
Ignoring bcrypt-ruby-3.0.1 because its extensions are not built.  Try: gem pristine bcrypt-ruby --version 3.0.1
Ignoring binding_of_caller-0.7.2 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.7.2
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.

当运行引用命令时,我会得到以下内容:
-bash: bundle: command not found
rails update
Ignoring json-1.8.1 because its extensions are not built.  Try: gem pristine json --version 1.8.1
Ignoring json-1.8.2 because its extensions are not built.  Try: gem pristine json --version 1.8.2
Ignoring json-1.8.3 because its extensions are not built.  Try: gem pristine json --version 1.8.3
Ignoring nokogiri-1.6.6.2 because its extensions are not built.  Try: gem pristine nokogiri --version 1.6.6.2
Ignoring atomic-1.1.14 because its extensions are not built.  Try: gem pristine atomic --version 1.1.14
Ignoring atomic-1.1.14 because its extensions are not built.  Try: gem pristine atomic --version 1.1.14
Ignoring bcrypt-ruby-3.0.1 because its extensions are not built.  Try: gem pristine bcrypt-ruby --version 3.0.1
Ignoring binding_of_caller-0.7.2 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.7.2
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
Could not find bcrypt-3.1.10 in any of the sources
Run `bundle install` to install missing gems.

我也尝试运行了以下命令:

sudo gem pristine --all
Restoring gems to pristine condition...
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0/gems/CFPropertyList-2.2.8/README

现在,它甚至找不到bundle安装路径。看起来更新真的把它搞砸了。


当我运行gem pristine --all时,我得到以下结果:

Restored bcrypt-ruby-3.1.5
Skipped bigdecimal-1.2.0, it is a default gem
Building native extensions.  This could take a while...
Restored binding_of_caller-0.7.2
Restored bootstrap-sass-3.3.5.1
Restored builder-3.2.2
Restored builder-3.1.4
Restored bundler-1.10.6
Restored bundler-1.9.6
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Ext::BuildError)
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r     ./siteconf20151001-3494-1jca623.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
make: *** No rule to make target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin15/ruby/config.h', needed by `breakpoint.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/byebug-6.0.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/byebug-6.0.2/gem_make.out

1
你运行了引用的命令吗? - Brad Werth
是的,请查看我的更新。 - user4932805
我认为这将解决问题,仍在更新中。如果成功,我会通知你,以便你可以将其发布为答案。 - user4932805
我和你有完全相同的问题,你解决了吗?@liroy - bntzio
是的。请查看我发布的答案(链接)。最终我重新安装了所有东西,包括Rails、Java等。 - user4932805
2个回答

5
解决方案在以下链接中:link

硬件

升级到El Capitan,使用Homebrew和Ruby。

...还有Xcode和Java等软件。

如果您尚未安装homebrew,请先安装它,这样您就不必处理SIP问题。在苹果菜单中安装所有可用的软件更新,包括El Capitan。

在安装和强制重启后,我的27英寸Thunderbolt显示器无法显示任何内容。拔掉插头再插上没有帮助。再重启一次就解决了。

软件

按照以下顺序进行...

Xcode

El Capitan的安装清除了我的Xcode安装,因此我不得不在App Store中搜索并重新安装。我现在相信我之前删除了Xcode并忘记了,因此需要重新安装。我在一台我很少使用的机器上进行了这个操作。

在Xcode安装完成后,打开iTerm(我用作Terminal.app替代品)或Terminal.app(如果您喜欢使用它)。

 xcode-select --install
xcode-select: note: install requested for command line developer tools

一个对话框弹出,我选择了“安装”,大约一分钟后完成了安装。

Java

接下来运行 Java,会弹出一个对话框,其中有一个“更多信息”的按钮,点击后会跳转到一个网站,在那里你可以接受许可并下载 Java 的 .dmg 文件。如果你打算运行基于命令行的 Java 工具,则需要 JDK 而不是 JRE。

Unable to find any JVMs matching version "1.7".
No Java runtime present, try --request to install.

∴ java

No Java runtime present, requesting install.

下载完成后,打开.dmg文件(例如对我来说是jdk-8u60-macosx-x64.dmg),安装完毕后重启iTerm。

∴ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

现在像RubyMine这样的应用程序应该能够工作了,至少可以启动。

Homebrew

医生通知我有几个警告,我按照指示进行了处理。

∴ brew doctor
∴ sudo chown -R $(whoami):admin /usr/local
∴ cd /usr/local/Library && git stash && git clean -d -f
∴ cd ~
∴ brew prune
∴ brew unlink qt5

然后我就能够更新Homebrew了。

∴ brew update

Qt5

我知道capybara-webkit gem需要qt5,而且我知道qt是homebrew / El Capitan问题追踪器中仍然存在的主要痛点之一,所以我决定先解决它。

∴ brew uninstall qt5
∴ brew install qt5
∴ brew linkapps qt5
∴ brew link --force qt5

需要加上最后一行才能使用qmake命令。可以通过which qmake命令检查是否安装了qmake。否则在后续安装Capybara时可能会出现以下错误:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/pboling/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20150930-48087-1vw6bye.rb extconf.rb
sh: qmake: command not found
*** extconf.rb failed ***

GPG

现在一些软件都开始使用GPG进行签名,比如RVM,所以请安装它。

∴ brew install gpg

RVM

我的Ruby能够工作,但我在安装一些本地宝石时遇到了麻烦,所以我决定重新编译一个针对所有新的homebrew和Xcode库的Ruby版本。

∴ rvm implode

由于权限问题,Implode未能删除主目录〜/ .rvm 。 我必须使用sudo命令将其删除。

∴ sudo rm -rf /Users/pboling/.rvm

按照这里的指示安装RVM,我安装了开发版本,期望它有更多的El Capitan修复程序:

∴ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
∴ \curl -sSL https://get.rvm.io | bash

我目前主要开发的应用程序使用的是Ruby 2.1.2,所以我首先安装了它,然后进入项目目录创建gemset并进行bundle操作。

∴ rvm install 2.1.2
∴ cd ~/project
∴ gem install bundler -v 1.9.7
∴ bundle install

我选择使用Bundler 1.9.7版本,因为Heroku目前使用的就是这个版本,我希望与之保持同步。1.10*版本的变化导致Gemfile.lock文件在我的多源gem库和私有gem服务器等情况下与部署服务器上的1.9.7不兼容。

Postgres

我还趁机升级到最新版本的Postgres.app。你也可以通过brew install postgres来安装PostgreSQL。我选择Postgres.app是因为它直接受到Heroku支持,并且我认为这里存在某种平衡的优势。


2
你应该尝试使用RVM或RBENV或者其他时下流行的工具。这些工具可以让你轻松地在每个项目中管理Ruby解释器和Gemsets。我仍然使用RVM并且很满意。 https://rvm.io/rvm/install

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