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

Can no longer include relative paths upwards on windows #231

Closed
togakangaroo opened this issue Jan 22, 2014 · 18 comments
Closed

Can no longer include relative paths upwards on windows #231

togakangaroo opened this issue Jan 22, 2014 · 18 comments

Comments

@togakangaroo
Copy link

W:\temp\nst> ls -Recurse
    Directory: Microsoft.PowerShell.Core\FileSystem::W:\temp\nst
d----     1/22/2014  2:19 PM        <DIR> styles
d----     1/22/2014  2:18 PM        <DIR> vendor
    Directory: Microsoft.PowerShell.Core\FileSystem::W:\temp\nst\styles
-a---     1/22/2014  2:18 PM           36 main.scss
    Directory: Microsoft.PowerShell.Core\FileSystem::W:\temp\nst\vendor
-a---     1/22/2014  2:21 PM           40 included.scss

W:\temp\nst> cat .\vendor\included.scss
@mixin hidden {
        display: none;
}
W:\temp\nst> cat .\styles\main.scss
@import '../vendor/included.scss';

Notice the relative path to included.scss goes up one level before descending into the vendor directory.

W:\temp\nst> cd .\styles
W:\temp\nst\styles> node-sass.cmd .\main.scss
W:\temp\nst\styles/.\main.scss:1: error: file to import not found or unreadable: '../vendor/included.scss'
'vendor/included.scss'

This is something that worked before I did npm -g update node-sass but now is breaking. Please fix asap. Until then I have to re-arrange my entire file structure

@LaurentGoderre
Copy link
Contributor

I was able to reproduce but I,m wondering if this is a problem with node-sass or libsass. I'm investigating.

@LaurentGoderre
Copy link
Contributor

It appears to be working fine with libsass

@coryroloff
Copy link

I don't know about why this broke after v0.7.0, but to get around it for now, make sure you replace all backslashes with forward slashes in your includePaths even on Windows.

@nschonni
Copy link
Contributor

@LaurentGoderre there was a bad commit that might have undone your windows path fixes, can you recheck those?

@LaurentGoderre
Copy link
Contributor

They still seem fine, however I never did fix the deprecatedRender one...

@gabegorelick
Copy link

@LaurentGoderre what do you mean by the deprecatedRender one? I ask because libsass is complaining about not finding my import on Windows and the code (I'm using sass-middleware) is flowing through deprecatedRender. I'm wondering if that's the same bug as this or if I should file a new one.

@LaurentGoderre
Copy link
Contributor

On this line https://github.com/andrew/node-sass/blob/master/sass.js#L65

options.paths.join(':'), should be options.path.join(path.delimiter) like the following line:

https://github.com/andrew/node-sass/blob/master/sass.js#L79

@LaurentGoderre
Copy link
Contributor

: is the linux/mac path seperator. Window's one is the ;. path.delimiter is node.js way of dealing with cross OS paths

@gabegorelick
Copy link

Thanks. Unfortunately that doesn't fix my issue. And it turns out it fails even without ... I'll do some more investigating before filing a new bug.

@LaurentGoderre
Copy link
Contributor

Are you sure? can yopu post the logs?

@gabegorelick
Copy link

The error is

error: source string:4: error: file to import not found or unreadable: "bootstrap-sass/lib/bootstrap"

The error looks to be coming straight out of libsass. My .scss file has @import "bootstrap-sass/lib/bootstrap";. I'm using the middleware like so:

var parentDir = __dirname + '/..';
app.use(require('node-sass').middleware({
      src: parentDir + '/public/styles',
      dest: parentDir + '/.tmp/styles',
      prefix: '/.tmp/styles',
      includePaths: [path.join(parentDir, 'public/bower_components')], 
      debug: true,
      outputStyle: 'expanded'
}));
app.use('/.tmp', express.static(__dirname + '/../.tmp'));

source, dest, and read from debug: true are all pointing to the full path of the correct place.

I should add that it builds fine in ruby-sass (via gulp-ruby-sass):

gulp.src(paths.styles)
    .pipe(sass({
      style: 'expanded',
      loadPath: 'public/bower_components'
    }))

I've also tried includePaths: ['public/bower_components'], but that gives the same error.
Anything else I should add?

@LaurentGoderre
Copy link
Contributor

Is this an issue on Windows only or on Linux as well?

@gabegorelick
Copy link

I only tried it on Windows.

@nschonni
Copy link
Contributor

@gabegorelick bootstrap-sass doesn't currently support libsass (which node-sass wraps) twbs/bootstrap-sass#494
It also doesn't have any SCSS files in the lib folder, they are all in vendor/assets/stylesheets

This is also way off topic to the original issue 😉

@gabegorelick
Copy link

This is also way off topic to the original issue 😉

Well I was going to file a new bug, but now we know that's not necessary. 😉

bootstrap-sass doesn't currently support libsass (which node-sass wraps) twbs/bootstrap-sass#494

Thanks for the link. Now I know not to bother trying until that's fixed. Although I do think there's another issue at play here.

It also doesn't have any SCSS files in the lib folder, they are all in vendor/assets/stylesheets

I'm using an older version that put them there. I've since upgraded to the official bootstrap SASS port, changed the include directive, and I still get this bug.

@am11
Copy link
Contributor

am11 commented Jun 20, 2014

Guys, see the workaround of this issue: madskristensen/WebEssentials2013#1191 (comment)

I once observe the similar issue in CoffeeLint's code (on Windows) but never got a chance to dive deeper and report it.
AFAIR, it was something to do with resolve (or resolve-require) package, which was eating up a parent directory in relative path. If you guys are using that package, you might want to start from there as the issue is with that package (not necessarily in your code).

@yantakus
Copy link

Here is a pull request for gulp-sass resolving this issue: dlmanning/gulp-sass#45
I think it should be integrated into node-sass, because this is certainly node-sass issue, not gulp-sass.

@am11
Copy link
Contributor

am11 commented Oct 22, 2014

This was libsass issue.

This was fixed by series of path related commits in libsass.

To wit:

PS C:\temp\styles> cat .\main.scss
@import '../vendor/included.scss';

PS C:\temp\styles> cat ..\vendor\included.scss
@mixin hidden {
        display: none;
}

PS C:\temp\styles> node ..\node_modules\node-sass\bin\node-sass .\main.scss
Rendering Complete, saving .css file...
Wrote CSS to C:\temp\styles\main.css

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

No branches or pull requests

7 participants