Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Compiling via Grunt-sass results in: Assertion failed: (val->IsString()) error #337

Closed
benfrain opened this issue Jun 6, 2014 · 62 comments · Fixed by #374
Closed

Compiling via Grunt-sass results in: Assertion failed: (val->IsString()) error #337

benfrain opened this issue Jun 6, 2014 · 62 comments · Fixed by #374

Comments

@benfrain
Copy link

benfrain commented Jun 6, 2014

Just updated to the latest grunt-sass and when I try and compile I get this error:

Assertion failed: (val->IsString()), function _NanGetExternalParts, file ../node_modules/nan/nan.h, line 1725.

I'm presuming this is due to Libsass 2.0? Or am I (probably) doing something obviously stupid?

I've have tried nuking my node-modules folder and running sudo npm install afresh but the same issue.

@jharmelink
Copy link

Since gulp-sass switched from version ~0.8.0 to version ^0.9.0 of node-sass I have the same problem.

nan.h:1725: bool _NanGetExternalParts(v8::Handle<v8::Value>, const char**, size_t*): Assertion `val->IsString()' failed.

@joemaller
Copy link

Seeing the same thing, Grunt and Gulp. Only workaround I've found is to remove sourceComments: 'map'from options.

@cesarandreu
Copy link

👍 Had the same issue when updating to gulp-sass to 0.7.2. Removing sourceComments: 'map' solves it, though.

@adamyeats-zz
Copy link

Could this be related in some way to #245?

@binarykitchen
Copy link

Nope, I do not have sourceComments in my options and it's still happening with the following code:

gulp.task('sass', function() {
    return gulp.src('/home/michael.heuberger/binarykitchen/code/videomail.io/src/assets/scss/**/*.scss')
        .pipe(sass({
            outputStyle:     'nested',
            errLogToConsole: true
        }))
        .pipe(gulp.dest('/home/michael.heuberger/binarykitchen/code/videomail.io/var/local/www/css'));
});

@robotlovesyou
Copy link

Seeing the same issue trying to update grunt-libsass to the latest version of node-sass. Has the API changed at all?

@andrew
Copy link
Contributor

andrew commented Jun 8, 2014

Quick question, which version of node are you using here? We updated nan fairly recently, it might be related.

@benfrain
Copy link
Author

benfrain commented Jun 9, 2014

@andrew I'm on 0.10.28

@mjonuschat
Copy link

Seeing the same error with node-sass 0.9.2 and mincer 1.0.4 on node-sass when I enable sourceComments: 'map'. Values of 'none' and 'normal' do not trigger this assertion failures.

I'm also using node 0.10.28

@andrew
Copy link
Contributor

andrew commented Jun 9, 2014

After so poking around this evening, I'm fairly sure this bug is related to the updated version of nan, but will need to dig further to determine exactly what's wrong cc @rvagg

@ckihneman
Copy link

@andrew @benfrain Did you set sourceMap: 'path/to/sass' in your grunt options that get passed to node-sass?

At least in my case (using gulp-sass) the sourceMap path is relative to the path of your css file to output. When I remove the sourceMap option from gulp I get this error.

Assertion failed: (val->IsString()), function _NanGetExternalParts, file ../node_modules/nan/nan.h, line 1725.
18882 abort      gulp

Edit: For further reference, here is my gulp task:

gulp.task('styles', function() {
    return gulp.src('assets/css/sass/main.scss')
        .pipe(sass({
            sourceMap: 'sass',
            sourceComments: 'map',
            precision: 10,
            imagePath: 'assets/img',
            includePaths: [
                'bower_components/bootstrap-sass/vendor/assets/stylesheets',
                'bower_components/jasny-bootstrap',
            ]
        }))
        .pipe(gulp.dest('assets/css'));
});

@kevindice
Copy link

I have the exact same issue as OP.
I am running node-sass as a docpad plugin.

@pwalczyszyn
Copy link

Seeing same error and removing sourceComments: 'map' helps.

@andrew
Copy link
Contributor

andrew commented Jun 10, 2014

@adamyeats after mulling this over last night, I think you might be right in it being related to #245

dlmanning referenced this issue in dlmanning/gulp-sass Jun 10, 2014
weilu added a commit to hivewallet/hive-js that referenced this issue Jun 11, 2014
@OClement
Copy link

Just tried to fix the same issue here and made it working, thanks to @ckihneman :

Just had to pass both sourceComments: 'map' and sourceMap: 'sass' to gulp-sass
Here's my styles task:

gulp.task('styles', ['clean-css'], function () {
  return gulp.src([
  './src/app/**/*.scss',
  '!./src/app/**/_*.scss'
])
  .pipe(g.sass({sourceComments: 'map', sourceMap: 'sass', style: 'compact'}))
  .pipe(g.autoprefixer('last 1 version', '> 1%', 'ie 8'))
  .pipe(gulp.dest('./.tmp/css/'))
  .pipe(g.cached('built-css'))
  .pipe(livereload());
});

@rvagg
Copy link
Contributor

rvagg commented Jun 12, 2014

I would have a poke at this but I can't get it to compile, and I blame git submodules ...

make: *** [Release/obj.target/binding/sass_context_wrapper.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from ../sass_context_wrapper.h:1:0,
                 from ../binding.cpp:6:
../libsass/sass_interface.h:5:33: fatal error: sass2scss/sass2scss.h: No such file or directory
 #include "sass2scss/sass2scss.h"

is there a libsass version mismatch here? what commit/branch of libsass should the submodule be at to make this work?

@andrew
Copy link
Contributor

andrew commented Jun 12, 2014

@rvagg libsass has a submodule now, so you'll need to do git submodule update --init --recursive to pull them both down.

@rvagg
Copy link
Contributor

rvagg commented Jun 12, 2014

YO

@gijsroge
Copy link

imagePath triggers the same error.
error: http://take.ms/Ewbhh

@rvagg
Copy link
Contributor

rvagg commented Jun 12, 2014

This is happening because CreateString() just assumes that it can extract a string from the passed property which in all of these cases it's not because it's null, undefined or some other non-String value. It probably worked previously because the assert wasn't in there (@kkoopa does that sound right?) but NAN is now being strict about needing either a Buffer or a String for NanCString() and NanRawString(), you can't just throw anything at it.

I'm not sure what libsass is expecting for the case where you don't have a string to supply but I'd suggest something like this:

char* CreateString(Local<Value> value) {
  size_t count;
  if (!value->IsString()) {
    return 0;
  }
  return NanCString(value, &count);
}

(assuming that libsass is going to accept a 0).

If you take the source_comments_spec.js file and change source_comments: 'normal' to source_comments: 'map' and run it again you'll trigger this error because options.sourceMap isn't defined but binding.cpp is expecting it to be a string. Unfortunately the above code fix doesn't help in this situation because libsass isn't happy about this situation either so there probably needs to be a check further up. Perhaps it'd also be better to ensure that you always set sourceMap to a String if you have source_comments set to 'map'. By the sound of some of the comments in here though it might be more than just sourceMap so more sanity checking for CreateString() would be good all-round (perhaps even throw a TypeError if you don't get a String where there needs to be one).

While you're at it, upgrade to NAN 1.2.0 and replace all of the NanSymbol() calls with NanNew() as the former has been deprecated because it's been removed from V8 completely and not coming back in any form.

@andrew
Copy link
Contributor

andrew commented Jun 12, 2014

Thanks for the insight @rvagg, I'll get a new issue opened up for upgraded NAN as well.

@kkoopa
Copy link
Contributor

kkoopa commented Jun 12, 2014

That assert has been there since the string converters were first written. git blame says I added it on 2013-07-30, almost a year ago. My guess is that the upgrade of libsass changed something there, starting it to use non-string values.

Also, NanCString and NanRawString are on their way out, as nobody seems to remember that the returned buffer needs to be cleaned up. We'll probably do some converters similar to String::Utf8Value, avoiding this problem. So, to guard for the future, use String::Utf8Value to do the conversion.

@sethburtonhall
Copy link

My problem is this:

sourceComments set to map

sourceComments: 'map' displays .scss files in inspector as it should

screenshot 2014-08-12 11 12 53

but it crashes gulp-sass and throws this error Segmentation fault: 11

sourceComments set to normal or none

sourceComments: 'normal/none' does not crash gulp-sass, and sass keeps running as it should.

but the .scss files are no longer displayed in inspector, which sucks because displaying .scss files in the inspector is the whole point.

screenshot 2014-08-12 11 16 09

Can anyone offer any insight into this. Thanks.

@tobyl
Copy link

tobyl commented Aug 13, 2014

Not sure if this is helpful but I found this while searching for this error in gulp. I cleared out my SCSS file and gulp shows this error - but if I add anything at all to my CSS file, even charset declaration, the error is resolved. Hope this helps someone..

joshdmiller pushed a commit to ngbp/spell-sass that referenced this issue Aug 13, 2014
For more information on this bug, see sass/node-sass#337. Source maps will be re-enabled as the
default upon resolution of the upstream bug.
@mikehaas763
Copy link

+1 same thing happened to me with gulp.

@nicolasaiz173
Copy link

I had the same problem but I resolved it adding some content to the empty SCSS file. Thanks @tobyl

@gorkamolero
Copy link

I had this problem for a while. Turns out some @import path was wrong in an .scss file. Get rid of SourceMaps and check your paths

@benfrain
Copy link
Author

@gorkamolero – that's not the solution for the problem I originally posted. Most of us will need to wait for the next node-sass release before we see this fixed. Certainly those of us using grunt-sass.

@BrandonJF
Copy link

I was having this same issue, turns out that my file paths were incorrect. Changed them to point at the right locations of my scss files and all was resolved. Hope this helps someone else!

@laurelnaiad
Copy link

Yes, if your syntax and semantics don't trigger the bug then you are ok... until your syntax or semantics trigger the bug the next time... :)

@am11
Copy link
Contributor

am11 commented Sep 17, 2014

Speaking of this bug, this is fixed in the master branch.

@keithamus I think we should consider making the next build this weekend. Thoughts?

@keithamus
Copy link
Member

@am11 Fine by me, if you need someone to build for Nix/OSX I can do it. I'm sure we had some auto-build thing going on but I don't know the status of it. @andrew?

@verpixelt
Copy link

Same issue here. Is there already a way to fix this? Previous mentioned tips don't work for me.

@am11
Copy link
Contributor

am11 commented Sep 21, 2014

@verpixelt, you can try out the release candidate v0.9.4: npm install [email protected].

@am11
Copy link
Contributor

am11 commented Sep 21, 2014

v0.9.4 final is released; just use npm install node-sass.

@benfrain
Copy link
Author

Thanks node-sass peeps. Appreciate all the hard work :)

@Jakobud
Copy link

Jakobud commented Sep 22, 2014

Can you use node-sass with gulp? I have always used gulp-sass but its not updated with these fixes yet.

@dlmanning
Copy link

@Jakobud : Actually, gulp-sass is just a gulp plugin for node-sass. If you reinstall it, or just run npm update, it will automatically be using node-sass 0.9.4

@Jakobud
Copy link

Jakobud commented Sep 22, 2014

Ah okay. I assumed it was depending on an old version of node-sass, but yeah I see it's just depending on ^0.9.

Okay after an npm update for my project I am getting an error:

Traceback (most recent call last):
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
    sys.exit(gyp.script_main())
AttributeError: 'module' object has no attribute 'script_main'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 2.6.32-358.18.1.el6.x86_64
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /vhosts/mysite/node_modules/gulp-sass/node_modules/node-sass
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
Build failed
npm ERR! [email protected] install: `node build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 2.6.32-358.18.1.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "update"
npm ERR! cwd /vhosts/mysite
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.4.4
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /vhosts/mysite/npm-debug.log
npm ERR! not ok code 0

Should I open a separate issue regarding this?

@dlmanning
Copy link

@Jakobud I'm not sure about that. What happens if you just delete node_modules and reinstall dependencies?

@Jakobud
Copy link

Jakobud commented Sep 22, 2014

Same error. Actually this is the beginning of the error, mean't to paste this above as well:

`linux-x64-v8-3.14` exists; testing
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.10.25"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/vhosts/mysite/node_modules/gulp-sass/node_modules/nods/.node-gyp"
gyp http GET http://nodejs.org/dist/v0.10.25/node-v0.10.25.tar.gz
gyp http 200 http://nodejs.org/dist/v0.10.25/node-v0.10.25.tar.gz
Traceback (most recent call last):
.......

Strange that running as root is causing permissions issues. /root/.node-gyp/ doesn't event exist.

@dlmanning
Copy link

@Jakobud Honestly this looks like an issue with your npm and node-gyp set up. It'd start by updating your version of node and maybe using something like https://github.com/creationix/nvm.

@Jakobud
Copy link

Jakobud commented Sep 22, 2014

Yeah I got around the directory permission error`. Still a problem with node-gyp though. Bummer. I'm out of commission until this is fixed since it hosed my node_modules dir. :-(

@Jakobud
Copy link

Jakobud commented Sep 22, 2014

I got node and npm all updated via yum. Here is the error I'm still getting now:

Here is my package.json

{
  "dependencies": {
    "gulp": "*",
    "gulp-autoprefixer": "0.0.9",
    "gulp-concat": "*",
    "gulp-sass": "*",
    "gulp-uglify": "*",
    "gulp-util": "*",
    "gulp-plumber": "*"
  }
}

And npm install gives the following:

> [email protected] install /vhosts/mywebsite/node_modules/gulp-sass/node_modules/node-sass
> node build.js

`linux-x64-v8-3.14` exists; testing
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.10.29"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/vhosts/mywebsite/node_modules/gulp-sass/node_modules/noe-sass/.node-gyp"
gyp http GET http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz
gyp http 200 http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz
Traceback (most recent call last):
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
    sys.exit(gyp.script_main())
AttributeError: 'module' object has no attribute 'script_main'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 2.6.32-358.18.1.el6.x86_64
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /vhosts/mywebsite/node_modules/gulp-sass/node_modules/node-sass
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
Build failed
npm ERR! [email protected] install: `node build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 2.6.32-358.18.1.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "install"
npm ERR! cwd /vhosts/mywebsite
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.4
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /vhosts/mywebsite/npm-debug.log
npm ERR! not ok code 0

I do not get this error if gulp-sass (which depends on node-sass) is left out of my package.json.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.