9

Ruby 由 rbenv 安装。

$ ruby -v  
ruby 1.9.3p327 (2012-11-10 revision 37606) [i686-linux]

$ which ruby  
/home/user/.rbenv/shims/ruby

$ which sass  
/home/user/.rbenv/shims/sass

$ gem list
*** LOCAL GEMS ***

bigdecimal (1.1.0) 
bundler (1.2.4)
io-console (0.3)
json (1.5.4)
minitest (2.5.1)
rake (0.9.2.2)
rdoc (3.9.4)
sass (3.2.5)

这是我的 config.yml:

# Assetic Configuration
assetic:
    // ...

    ruby: /home/user/.rbenv/shims/ruby

    filters:
        cssrewrite: ~
        sass:
            bin: /home/user/.rbenv/shims/sass

        // ...

这是我得到的错误:

[message] An error occurred while running:
'/home/user/.rbenv/shims/ruby' '/home/user/.rbenv/shims/sass' '--load-path' '/path/to/symfony2/src/My/AnyBundle/Resources/public/css' '--cache-location' '/tmp' '/tmp/assetic_sassYbl6MI'

Error Output:
ruby: no Ruby script found in input (LoadError)

我的其他设置中的错误:

配置.yml:

# Assetic Configuration
assetic:
    // ...

    ruby: /home/user/.rbenv/shims/ruby

    filters:
        cssrewrite: ~
        sass: ~

        // ...

这是我得到的错误:

Error Output:
ruby: No such file or directory -- /usr/bin/sass (LoadError)

萨斯不起作用。引用 gem 有问题吗?

4

2 回答 2

7

克隆 rails repo 后出现此错误:

$ rails server
c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe: no Ruby script found in input (LoadError)

问题出在bin/rails和中bin/rake。顶线是#!/usr/bin/env,但应该是#!/usr/bin/env ruby

于 2013-08-17T05:28:04.220 回答
1

Sf 2.1.7, rvm installed, installed compass,sass as gem, 特别基于Unable to load Sass / Compass after install RVM, to use with Assetic in Symfony2

parameters:
# Assetic
  assetic.filter.compass.images_dir: %kernel.root_dir%/../web/images
  assetic.filter.compass.http_path:  /images
  assetic.ruby.bin: 'pathToRubyBin'

ruby bin 的路径,您可以通过以下方式检查:

which ruby

如上。对于 sass 和 scss 使用罗盘过滤器:

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ FOSUserBundle, XcomplSomeBundle ]
    #java: /usr/bin/java
    filters:
        lessphp:
            file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
            apply_to: "\.less$"
        sass: ~
        compass:
            bin: 'pathtocompass'
            apply_to: "~\.(sass|scss)$~"
        cssrewrite: ~

这是警告!如果您使用 rvm 或系统 ruby​​,则无需创建 100500 个包装器。只是:

$ which compass

它是你的指南针。

现在:

{% block stylesheets %}
    {% stylesheets 'css/general.scss(or .sass)' filter='compass, cssrewrite' output='css/general.css' %}
        <link rel="stylesheet" type="text/css" media="screen" href={{ asset_url }} />
    {% endstylesheets %}
{% endblock %}

最后,我的宝石清单:

~$ gem list

*** LOCAL GEMS ***

bigdecimal (1.1.0)
bundler (1.2.4)
chunky_png (1.2.7)
compass (0.12.2)
fssm (0.2.10)
io-console (0.3)
json (1.5.5)
minitest (2.5.1)
rake (10.0.3, 0.9.2.2)
rdoc (3.9.5)
rubygems-bundler (1.1.0)
rvm (1.11.3.6)
sass (3.2.6)
于 2013-02-23T11:19:03.990 回答