您的位置:首页 > 编程语言 > Ruby

Windows8.1 64位 安装 Ruby Sass Compass

2015-03-16 14:11 597 查看
整理了Sass,compass 和 ruby 的介绍,以及在windows8.1 下安装会出现的一些问题,供自己参考,希望对其他人也有用。

什么是 CSS预处理器

我们知道CSS是为设计师准备的工具,没有变量,也没逻辑语句,仅有一行行单纯的描述,对于程序员来说是一堆非常麻烦的东西。"CSS预处理器"(css
preprocessor)的想法是以程序员的思考方式来编写样式,然后再编译成正常的CSS文件。而各种"CSS预处理器"之中,比较流行的有 Sass,Less, Stylus...其中又以Sass最为著名。

什么是 Compass
Compass于Sass有点像Javascript和jQuery的关系。它在Sass的基础上,封装了一系列有用的模块和模板,补充Sass的功能。由于是Sass本身只是一个编译器,所以 只有搭配Compass,它才能显出真正的威力。

安装ruby on windows

因为Sass 和 Compass都是用Ruby语言开发的开源编程工具,所以安装它之前,必须安装Ruby。

下载ruby on windows,http://rubyinstaller.org/downloads/ 在选择下载版本时,无论你是32位windows7还是64位windows7/8系统,千万不要选择64位。64位ruby
on windows 问题非常多,如果我们只是学习Ruby或用来入门Sass,就没有必要用64位,这里我选的是稳定版本2.15. http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.1.5.exe?direct
一路yes和next后,进入cmd窗口,在ruby2.1/bin下,键入ruby -v 查看是否安装好,

安装Sass
在ruby2.1/bin下键入
gem install sass
如果出现问题

ERROR:  While executing gem ... (Encoding::UndefinedConversionErro
    U+7CFB to CP850 in conversion from UTF-16LE to UTF-8 to CP850

找到文件 "C:\Ruby21-x64\lib\ruby\2.1.0\win32\registry.rb" (according to your real install
directory) 修改 LOCALE constant:
找到 这一行 "LOCALE = Encoding.find(Encoding.locale_charmap)" 
改成 "LOCALE = Encoding::UTF_8" 

再试一试
gem install sass

又一次出现问题
ERROR:  Could not find a valid gem 'sass' (>= 0), here is why:.....

因为https 的安全证书问题,这里我们为了快速完成安装,现绕开一些安全考虑,所以只要增加一个http的下载安装源。

gem source -a http://rubygems.org/[/code] 
再试一试
gem install sass

成功!!!

安装Compass
gem install compass

出现错误

$ gem install compass
ERROR:  Error installing compass:
The 'ffi' native gem requires installed build tools.


需要下载Development Kit, 去 http://rubyinstaller.org
根据 ruby 版本下载,解压到C磁盘后:

C:\RubyDevKit>devkitvars.bat
Adding the DevKit to PATH...

C:\RubyDevKit>ruby dk.rb init
[INFO] found RubyInstaller v2.1.5 at C:/Ruby193

Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.

C:\RubyDevKit>ruby dk.rb install
[INFO] Updating convenience notice gem override for 'C:/Ruby21'
[INFO] Installing 'C:/Ruby21/lib/ruby/site_ruby/devkit.rb'

$ gem install compass
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Fetching: rb-inotify-0.9.5.gem (100%)
Fetching: compass-1.0.1.gem (100%)
Compass is charityware. If you love it, please donate on our behalf at http:
//umdf.org/compass Thanks!
Successfully installed ffi-1.9.6
Successfully installed rb-inotify-0.9.5
Successfully installed compass-1.0.1
3 gems installed
Installing ri documentation for ffi-1.9.6...
Installing ri documentation for rb-inotify-0.9.5...
Installing ri documentation for compass-1.0.1...
Installing RDoc documentation for ffi-1.9.6...
Installing RDoc documentation for rb-inotify-0.9.5...
Installing RDoc documentation for compass-1.0.1...


成功!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  安装 Ruby Sass Compass