感谢 ruby-china,给我提供了一个这样好的交流机会。 我是第一次接触 code,想从 ruby 学起。按照 wiki 的指导,我想在我的 mac 系统下,配置好 Ruby 以及 Rails。但是出了问题,错误如下:
localhost:~kkkk$ rvm install 1.9.3 --with-redline-dir=$rvm_path/usr -bash: --version: command not found Installing Ruby from source to: /Users/kkkk/.rvm/rubies/ruby-1.9.3-p286, this may take a while depending on your cpu(s)... ruby-1.9.3-p286 - #downloading ruby-1.9.3-p286, this may take a while depending on your connection... ruby-1.9.3-p286 - #extracted to /Users/kkkk/.rvm/src/ruby-1.9.3-p286 (already extracted) ruby-1.9.3-p286 - #configuring ruby-1.9.3-p286 - #compiling Error running 'make', please read /Users/kkkk/.rvm/log/ruby-1.9.3-p286/make.log There has been an error while running make. Halting the installation. -bash: --version: command not found
这是怎么回事呢?我完全按照 wiki 操作的啊。
#1 楼 @sailtsao 谢谢回复啊,贴一个我的 make.log
[2012-10-20 00:58:53] make
CC = clang
LD = ld
LDSHARED = clang -dynamiclib
CFLAGS = -I/Users/kkkk/.rvm/usr/include -fno-common -pipe
XCFLAGS = -include ruby/config.h -include ruby/missing.h -fvisibility=hidden -DRUBY_EXPORT
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I. -I.ext/include/x86_64-darwin12.2.0 -I./include -I.
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace -install_name /Users/kkkk/.rvm/rubies/ruby-1.9.3-p286/lib/libruby.1.9.1.dylib -current_version 1.9.1 -compatibility_version 1.9.1 -Wl,-unexported_symbol,Init* -Wl,-unexported_symbol,threadptr -Wl,-u,_objc_msgSend
SOLIBS =
linking miniruby
rbconfig.rb updated
generating enc.mk
generating prelude.c
compiling prelude.c
linking static-library libruby.1.9.1-static.a
linking shared-library libruby.1.9.1.dylib
generating encdb.h
encdb.h unchanged
making enc
make[1]: Nothing to be done for enc'.
making srcs under enc
make[1]: Nothing to be done for
srcs'.
generating transdb.h
transdb.h unchanged
making trans
make[1]: Nothing to be done for `./enc/trans'.
making encs
configuring -test-/add_suffix
configuring -test-/array/resize
configuring -test-/bug-3571
configuring -test-/bug-3662
configuring -test-/funcall
configuring -test-/load/dot.dot
configuring -test-/old_thread_select
configuring -test-/st/numhash
configuring -test-/string
configuring -test-/wait_for_single_fd
configuring -test-/win32/dln
Failed to configure -test-/win32/dln. It will not be installed.
configuring -test-/win32/fd_setsize
Failed to configure -test-/win32/fd_setsize. It will not be installed.
configuring bigdecimal
configuring continuation
configuring coverage
configuring curses
configuring date
configuring dbm
configuring digest
configuring digest/bubblebabble
configuring digest/md5
configuring digest/rmd160
configuring digest/sha1
configuring digest/sha2
configuring dl
configuring dl/callback
configuring dl/win32
Failed to configure dl/win32. It will not be installed.
configuring etc
configuring fcntl
configuring fiber
configuring fiddle
configuring gdbm
Failed to configure gdbm. It will not be installed.
configuring iconv
configuring io/console
configuring io/nonblock
configuring io/wait
configuring json
configuring json/generator
configuring json/parser
configuring mathn/complex
configuring mathn/rational
configuring nkf
configuring objspace
configuring openssl
configuring pathname
configuring psych
configuring pty
configuring racc/cparse
configuring readline
configuring ripper
configuring sdbm
configuring socket
configuring stringio
configuring strscan
configuring syck
configuring syslog
configuring tk
check functions.........
check struct members..
check libraries....
Use ActiveTcl libraries (if available).
Search tclConfig.sh and tkConfig.sh....................................
Valid [tclConfig.sh, tkConfig.sh] are found in [["/System/Library/Frameworks/Tcl.framework", "/System/Library/Frameworks/Tk.framework"], ["/usr/lib", "/usr/lib"], ["/System/Library/Frameworks/Tcl.framework/Versions/Current", "/System/Library/Frameworks/Tk.framework/Versions/Current"], ["/System/Library/Frameworks/Tcl.framework/Versions/8.5", "/System/Library/Frameworks/Tk.framework/Versions/8.5"], ["/System/Library/Frameworks/Tcl.framework/Versions/8.4", "/System/Library/Frameworks/Tk.framework/Versions/8.4"]]
Use [tclConfig.sh, tkConfig.sh] == ["/System/Library/Frameworks/Tcl.framework/tclConfig.sh", "/System/Library/Frameworks/Tk.framework/tkConfig.sh"]
Use MacOS X Frameworks.
Find Tcl/Tk libraries. Make tcltklib.so which is required by Ruby/Tk.
configuring tk/tkutil
configuring win32ole
Failed to configure win32ole. It will not be installed.
configuring zlib
linking shared-object -test-/add_suffix/bug.bundle
installing default bug libraries
linking shared-object -test-/array/resize.bundle
installing default resize libraries
linking shared-object -test-/bug-3571/bug.bundle
installing default bug libraries
linking shared-object -test-/bug-3662/bug.bundle
installing default bug libraries
linking shared-object -test-/funcall/funcall.bundle
installing default funcall libraries
linking shared-object -test-/load/dot.dot/dot.dot.bundle
installing default dot.dot libraries
linking shared-object -test-/old_thread_select/old_thread_select.bundle
installing default old_thread_select libraries
linking shared-object -test-/st/numhash.bundle
installing default numhash libraries
linking shared-object -test-/string/string.bundle
installing default string libraries
linking shared-object -test-/wait_for_single_fd/wait_for_single_fd.bundle
installing default wait_for_single_fd libraries
make[2]: Nothing to be done for all'.
make[2]: Nothing to be done for
all'.
linking shared-object bigdecimal.bundle
installing default bigdecimal libraries
linking shared-object continuation.bundle
installing default continuation libraries
linking shared-object coverage.bundle
installing default coverage libraries
linking shared-object curses.bundle
installing default curses libraries
linking shared-object date_core.bundle
installing default date_core libraries
linking shared-object dbm.bundle
installing default dbm libraries
linking shared-object digest.bundle
installing digest libraries
installing default digest libraries
linking shared-object digest/bubblebabble.bundle
installing default bubblebabble libraries
linking shared-object digest/md5.bundle
installing default md5 libraries
linking shared-object digest/rmd160.bundle
installing default rmd160 libraries
linking shared-object digest/sha1.bundle
installing default sha1 libraries
linking shared-object digest/sha2.bundle
installing default sha2 libraries
linking shared-object dl.bundle
installing dl libraries
installing default dl libraries
linking shared-object dl/callback.bundle
installing default callback libraries
make[2]: Nothing to be done for all'.
linking shared-object etc.bundle
installing default etc libraries
linking shared-object fcntl.bundle
installing default fcntl libraries
linking shared-object fiber.bundle
installing default fiber libraries
linking shared-object fiddle.bundle
installing default fiddle libraries
make[2]: Nothing to be done for
all'.
linking shared-object iconv.bundle
installing default iconv libraries
linking shared-object io/console.bundle
installing default console libraries
linking shared-object io/nonblock.bundle
installing default nonblock libraries
linking shared-object io/wait.bundle
installing default wait libraries
installing default libraries
linking shared-object json/ext/generator.bundle
installing default generator libraries
linking shared-object json/ext/parser.bundle
installing default parser libraries
linking shared-object mathn/complex.bundle
installing default complex libraries
linking shared-object mathn/rational.bundle
installing default rational libraries
linking shared-object nkf.bundle
installing default nkf libraries
linking shared-object objspace.bundle
installing default objspace libraries
linking shared-object openssl.bundle
installing default openssl libraries
linking shared-object pathname.bundle
installing default pathname libraries
linking shared-object psych.bundle
installing default psych libraries
linking shared-object pty.bundle
installing default pty libraries
linking shared-object racc/cparse.bundle
installing default cparse libraries
compiling readline.c
readline.c:1499:9: error: use of undeclared identifier 'username_completion_function'; did you mean 'rl_username_completion_function'?
rl_username_completion_function);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rl_username_completion_function
readline.c:69:42: note: expanded from macro 'rl_username_completion_function'
^ /Users/kkkk/.rvm/usr/include/readline/readline.h:443:14: note: 'rl_username_completion_function' declared here extern char rl_username_completion_function PARAMS((const char *, int)); ^ 1 error generated. make[2]: ** [readline.o] Error 1 make[1]: *** [ext/readline/all] Error 2 make: *** [build-ext] Error 2
#2 楼 @ywjno 运行 rvm requirements 的提示是这样的:
Notes for Mac OS X 10.8.2, Xcode 4.4.1.
For JRuby: Install the JDK. See http://developer.apple.com/java/download/ # Current Java version "1.6.0_26" For IronRuby: Install Mono >= 2.6 For Ruby 1.9.3: Install libksba # If using Homebrew, 'brew install libksba'
To use an RVM installed Ruby as default, instead of the system ruby:
rvm install 1.8.7 # installs patch 357: closest supported version rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system.gems # migrate your gems rvm alias create default 1.8.7
And reopen your terminal windows.
Xcode and gcc:
Right now Ruby requires gcc to compile, but Xcode 4.2 and later no longer ship with gcc. Instead they ship with llvm-gcc (to which gcc is a symlink) and clang, neither of which are supported for building Ruby. Xcode 4.1 was the last version to ship gcc, which was /usr/bin/gcc-4.2.
Xcode 4.1 and earlier:
Xcode 4.2 and later (including Command Line Tools for Xcode):
Homebrew:
If you are using Homebrew, you can install the apple-gcc42 and required libraries from homebrew/dupes:
brew update brew tap homebrew/dupes brew install autoconf automake apple-gcc42 rvm pkg install openssl
Xcode 4.2+ install or/and Command Line Tools for Xcode is required to provide make and other tools.
osx-gcc-installer:
If you don't use Homebrew, you can download and install osx-gcc-installer: https://github.com/kennethreitz/osx-gcc-installer.
Warning: Installing osx-gcc-installer on top of a recent Xcode is known to cause problems, so you must uninstall Xcode before installing osx-gcc-installer. Afterwards you may install Xcode 4.2+ or Command Line Tools for Xcode if you desire.
** NOTE: Currently, Node.js is having issues building with osx-gcc-installer. The only fix is to install Xcode over osx-gcc-installer.
Xcode 装了吗,在 appstore 上是免费的,但是很大,我去年是参考这个帖子装的http://wp.xdite.net/?p=1795 当然后半部分安装 Ruby 的最好替换成 rvm