2013-01-15 166 views
0

當我嘗試創建新的Rails應用程序rails new app時,當嘗試安裝JSON寶石時,此進程停止。所以,我想單獨安裝,使用:Ruby on Rails:無法安裝JSON寶石

gem install json 

,但我得到了以下錯誤消息:

Building native extensions. This could take a while... 
ERROR: Error installing json: 
    ERROR: Failed to build gem native extension. 

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb 
creating Makefile 

make 
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I. -DJSON_GENERATOR -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -O3 -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -c generator.c 
Error: No developer directory found at /Developer. Run /usr/bin/xcode-select to update the developer directory path. 
make: *** [generator.o] Error 1 

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.7.6 for inspection. 
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.7.6/ext/json/ext/generator/gem_make.out 

你有什麼想法,這是什麼意思?我該如何解決它?

一些額外的信息:我使用的是MacOSX,Rails版本是3.2.11。 Ruby版本是1.8.7。

感謝您的幫助。

回答

1

不支持Ruby 1.8.X在Rails中下降嗎?我建議升級到1.9.3。對於您的寶石:如果本機擴展存在問題,請嘗試使用「`json-pure」gem代替,因爲它完全用ruby編寫,不需要本機擴展。

http://rubygems.org/gems/json_pure

+0

非常感謝久子,它最後的作品...(1)安裝RVM更新紅寶石(2)寶石更新軌道和捆綁,(3)更新軌道模塊創建一個新的Rails應用程序時。 – htaidirt

+0

究竟是什麼區別(除了代碼是C++還是Ruby)?爲什麼我們會選擇純粹的紅寶石原生? – ashes999

+1

我會說速度。如果你有一個使用JSON進行大量de/serialization的API,它可能很重要。手下來,像紅寶石一樣好,它不是建立在原始表現上。使用本地的東西可以幫助解決瓶頸問題。 – Hisako