为什么在输入(LoadError)中找不到Ruby脚本?

时间:2013-02-15 02:03:14

标签: ruby sass rbenv

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)

我的其他设置中的错误:

config.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)

Sass不起作用。这是引用宝石的问题吗?

2 个答案:

答案 0 :(得分:6)

克隆rails repo后我遇到了这个错误:

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

问题出在bin/railsbin/rake。第一行是#!/usr/bin/env,但应该是#!/usr/bin/env ruby

答案 1 :(得分:1)

Sf 2.1.7,rvm安装,安装指南针,sass as gem,特别基于Unable to load Sass / Compass after installing 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 %}

最后,我的gemlist:

~$ 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)