熱門文章

2016年7月13日 星期三

[Ruby]Getting a “bad interpreter” error when using brew

http://stackoverflow.com/questions/8864668/getting-a-bad-interpreter-error-when-using-brew

原本都使用正常,但是在安裝 homebrew 之後造成錯誤




嘗試重新安裝 ruby

➜  ~ git:(master) brew install ruby
==> Installing dependencies for ruby: readline, libyaml, openssl
==> Installing ruby dependency: readline
==> Downloading https://homebrew.bintray.com/bottles/readline-6.3.8.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline-6.3.8.el_capitan.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.


Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/readline/lib
    CPPFLAGS: -I/usr/local/opt/readline/include

==> Summary
🍺  /usr/local/Cellar/readline/6.3.8: 46 files, 2.0M
==> Installing ruby dependency: libyaml
==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.1.6_1.el_capitan.bottle.tar.g
######################################################################## 100.0%
==> Pouring libyaml-0.1.6_1.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/libyaml/0.1.6_1: 8 files, 312.8K
==> Installing ruby dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2h_1.el_capitan.bottle.tar.
######################################################################## 100.0%
==> Pouring openssl-1.0.2h_1.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2h_1: 1,691 files, 12M
==> Installing ruby
==> Downloading https://homebrew.bintray.com/bottles/ruby-2.3.1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ruby-2.3.1.el_capitan.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/rake
Target /usr/local/bin/rake
already exists. You may want to remove it:
  rm '/usr/local/bin/rake'

To force the link and overwrite all conflicting files:
  brew link --overwrite ruby

To list all files that would be deleted:
  brew link --overwrite --dry-run ruby

Possible conflicting files are:
/usr/local/bin/rake
/usr/local/bin/rdoc
/usr/local/bin/ri
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/ruby
==> Summary
🍺  /usr/local/Cellar/ruby/2.3.1: 1,260 files, 19.0M
➜  ~ git:(master)  
➜  ~ git:(master)  
➜  ~ git:(master)  
➜  ~ git:(master)  
➜  ~ git:(master)  
➜  ~ git:(master)  
➜  ~ git:(master) rm '/usr/local/bin/rake'
➜  ~ git:(master)   brew link --overwrite ruby
Linking /usr/local/Cellar/ruby/2.3.1... 1225 symlinks created
➜  ~ git:(master) brew link --overwrite --dry-run ruby
Warning: Already linked: /usr/local/Cellar/ruby/2.3.1
To relink: brew unlink ruby && brew link ruby
➜  ~ git:(master) brew unlink ruby && brew link ruby
Unlinking /usr/local/Cellar/ruby/2.3.1... 1225 symlinks removed
Linking /usr/local/Cellar/ruby/2.3.1... 1225 symlinks created
➜  ~ git:(master) ruby



輸入ruby後 卡住.....

重試

Last login: Wed Jul 13 14:02:14 on ttys002
➜  ~ git:(master) which ruby
/usr/local/bin/ruby
➜  ~ git:(master) brew install rbenv ruby-build
==> Installing dependencies for rbenv: autoconf, pkg-config, ruby-build
==> Installing rbenv dependency: autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.el_capitan.bottle.4.tar.g
######################################################################## 100.0%
==> Pouring autoconf-2.69.el_capitan.bottle.4.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/autoconf
==> Summary
🍺  /usr/local/Cellar/autoconf/2.69: 70 files, 3.0M
==> Installing rbenv dependency: pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.1.el_capitan.bottle.tar
######################################################################## 100.0%
==> Pouring pkg-config-0.29.1.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/pkg-config/0.29.1: 10 files, 627.2K
==> Installing rbenv dependency: ruby-build
==> Downloading https://github.com/rbenv/ruby-build/archive/v20160602.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v20160602
######################################################################## 100.0%
==> ./install.sh
🍺  /usr/local/Cellar/ruby-build/20160602: 282 files, 155.5K, built in 7 seconds
==> Installing rbenv
==> Downloading https://homebrew.bintray.com/bottles/rbenv-1.0.0.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring rbenv-1.0.0.el_capitan.bottle.tar.gz
==> Caveats
Rbenv stores data under ~/.rbenv by default. If you absolutely need to
store everything under Homebrew's prefix, include this in your profile:
  export RBENV_ROOT=/usr/local/var/rbenv

To enable shims and autocompletion, run this and follow the instructions:
  rbenv init
==> Summary
🍺  /usr/local/Cellar/rbenv/1.0.0: 36 files, 61.9K

➜  ~ git:(master)  

➜  ~ git:(master) brew install ruby
Warning: ruby-2.3.1 already installed
➜  ~ git:(master) ruby -v

ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

可以看到ruby的版本

➜  ~ git:(master) rails -v
/usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'railties' (>= 0) among 11 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/QJpioneer/.gem/ruby/2.3.0:/usr/local/lib/ruby/gems/2.3.0:/usr/local/Cellar/ruby/2.3.1/lib/ruby/gems/2.3.0', execute `gem env` for more information
from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'

from /usr/local/bin/rails:22:in `<main>'

Rails 卻發生錯誤,嘗試重新安裝rails




➜  ~ git:(master) gem install nokogiri                               
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:

ERROR: Failed to build gem native extension.



After upgrading OS X from Mountain Lion to Maverick, encountered errors installing nokogiri. Resolved the error by reinstalling the command line tools.
  • brew doctor
  • xcode-select --install
執行以上兩個後,成功

➜  ~ git:(master) gem install nokogiri                                  
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.6.8

1 gem installed

➜  ~ git:(master) gem install rails                             
Fetching: loofah-2.0.3.gem (100%)

Successfully installed loofah-2.0.3
...
Successfully installed rails-5.0.0
26 gems installed
➜  ~ git:(master) rails -v
Rails 5.0.0







沒有留言:

張貼留言