1

我在我的网络服务器上使用 SASS 和 Compass。编辑我的 config.rb 文件并运行“指南针手表”后,它会引发以下错误。在编辑文件之前它没有抛出错误。这里可能出了什么问题?这可能是我的编辑器(尾声)保存文件的方式吗?还是发生了其他事情?

syntax error, unexpected tSTRING_BEG, expecting $end
@import "compass"

配置文件

# Require any additional compass plugins here.

# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
@import "compass"

# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed

# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true

# To disable debugging comments that display the original location of your selectors. Uncomment:
# line_comments = false


# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
4

1 回答 1

3

Coda 很可能正在更改文件的格式,我的赌注是 EOL(行尾)字符。我的 config.rb 具有 UNIX 换行符并可以按应有的方式进行编译(Windows 换行符也可以)。如果我将其更改为 Mac 换行符,我会收到此错误(与您的错误非常接近):

$ compass watch
SyntaxError on line ["24"] of /usr/local/lib/ruby/gems/1.9.1/gems/compass-0.12.2/lib/compass/configuration/serialization.rb: /path/to/config.rb:1: syntax error, unexpected tIDENTIFIER, expecting $end
# Require any addit...

我的编辑器(Notepad++)说文件被编码为 ANSI。将其更改为我的编辑器支持的其他一些编码会产生如下错误:

$ compass watch
SyntaxError on line ["24"] of /usr/local/lib/ruby/gems/1.9.1/gems/compass-0.12.2/lib/compass/configuration/serialization.rb: /path/to/config.rb:1: invalid multibyte char (US-ASCII)
Run with --trace to see the full backtrace
于 2012-12-21T15:33:18.303 回答