问题
Ruby is installed by 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)
This is my config.yml:
# Assetic Configuration
assetic:
// ...
ruby: /home/user/.rbenv/shims/ruby
filters:
cssrewrite: ~
sass:
bin: /home/user/.rbenv/shims/sass
// ...
This is the error I get:
[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)
The error in my other setup:
config.yml:
# Assetic Configuration
assetic:
// ...
ruby: /home/user/.rbenv/shims/ruby
filters:
cssrewrite: ~
sass: ~
// ...
This is the error I get:
Error Output:
ruby: No such file or directory -- /usr/bin/sass (LoadError)
Sass does not function. Is it a problem referencing the gem?
回答1:
I've got this error after cloning a rails repo:
$ rails server
c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe: no Ruby script found in input (LoadError)
The problem was in bin/rails
and bin/rake
. Top line was #!/usr/bin/env
, but should have been #!/usr/bin/env ruby
.
回答2:
Sf 2.1.7, rvm installed, installed compass,sass as gem, particulary based on 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'
path to ruby bin you can check by:
which ruby
as above. For sass and scss use compass filter:
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: ~
And here is Warning! There is no need 100500 wrappers to create if you use rvm or system ruby. Just:
$ which compass
And it is your pathtocompass.
And now:
{% 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 %}
Finally, my 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)
来源:https://stackoverflow.com/questions/14887335/why-is-no-ruby-script-found-in-input-loaderror