0

I used gulp to build a html project. For some css staff,I used compass to build. I have task as follow

gulp.task('compass',function(){
    gulp.src('public_html/app/scss/style.scss')
            //.pipe(plumber())
            .pipe(compass({
                config_file: './config.rb',
                css: 'public_html/app/css',
                sass: 'public_html/app/scss',
                require: ['susy']
            }))
            //.pipe(autoprefixer('last 2 versions'))
            .pipe(gulp.dest('public_html/app/css'))
            .pipe(reload({stream:true}));
});

When I build as gulp compass, I have error as

LoadError on line ["55"] of ~/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb: cannot load such file -- susy
Run with --trace to see the full backtrace


events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Compass failed

I have that file kernel_require.rb in the exact folder. I export PATH as

 export PATH=$PATH:~/.rbenv/versions/2.3.1/lib   
export PATH=$PATH:~/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext 

But doesn't work. How to solve this error?

Thanks

EDIT:

gem list

*** LOCAL GEMS ***

cairo (1.12.8)
chunky_png (1.3.7)
compass-core (1.0.3)
compass-import-once (1.0.5)
execjs (2.7.0)
gettext (3.0.3)
locale (2.1.0)
multi_json (1.12.1)
rb-fsevent (0.9.7)
rdoc (3.9.4)
sass (3.4.22)
susy (2.2.12)
text (1.2.1)
nyan@nyan-Inspiron-7537:~$ susy -v
susy: command not found
batuman
  • 7,066
  • 26
  • 107
  • 229
  • 'kernel_require' isn't the file that can't be loaded, it's the file that does the loading; the file that kernel_require is trying (and failing) to load is 'susy'. – philomory Oct 22 '16 at 01:50
  • @philomory, ic. so susy is missing.let me try . thanks – batuman Oct 22 '16 at 04:06
  • @philomory, I have installed susy, you can see in EDIT in the original post. But I typed susy -v, susy command not found. What is wrong? – batuman Oct 22 '16 at 04:22
  • @philomory Yes, correct. I installed susy and it works. Can please answer? – batuman Oct 22 '16 at 04:24

1 Answers1

4

You were mis-interpreting the error message:

LoadError on line ["55"] of ~/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb: cannot load such file -- susy

The first part, LoadError, tells you what type of error you were running into; the documentation for LoadError states,

Raised when a file required (a Ruby script, extension library, ...) fails to load.

require 'this/file/does/not/exist'

raises the exception:

LoadError: no such file to load -- this/file/does/not/exist

The next part of the error message, on line ["55"] of ~/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:, tells you where the error occurred, that is, some piece of code called another piece of code which called another piece of code, eventually leading to line 55 of the file 'kernel_require.rb', which is part of the infrastructure of RubyGems. That line is, ultimately, what triggered the LoadError.

The final part of the error message, cannot load such file -- susy, gives you details about the problem; specifically, in the case of a LoadError such as this, it tells you what file it tried to (and failed) to load: 'susy'.

This all comes down to the fact that you had a directive in your gulp file, require: ['susy'], but did not have the 'susy' gem installed. As you discovered, installing 'susy' (with gem install susy) resolved the issue.

You also note that susy -v on the command line gave an error, but that's a red herring; the susy gem does not install any command line tools, only Ruby code.

philomory
  • 1,709
  • 12
  • 13
  • Where does `require 'this/file'` look for this file? – Cadoiz Sep 05 '22 at 06:25
  • @Cadoiz The short answer is, it looks for the file in the load path, as defined (mostly) by the `$LOAD_PATH` variable. What, exactly, that contains by default is going to vary depending on operating system and how Ruby was installed. However, it never includes the working directory, nor anything relative to the file the `require` statement appears in. If you want to require a file using a path relative to the currently executing file, you want `require_relative 'this/file'`, instead. See the docs for [Kernel#require](https://docs.ruby-lang.org/en/3.1/Kernel.html#method-i-require) for details. – philomory Sep 06 '22 at 22:21