sass/dart-sass

Cannot open any files in a case-sensitive directory in Windows

Closed this issue · 5 comments

When I try to compile any file located in a case-sensitive directory on Windows, I get the following error: Error reading styles.scss: Cannot open file. However, it works if the file is not in a case-sensitive directory or when running it from WSL (Linux). Presumably, sass treats all files as case-insensitive on Windows, when it should detect whether the directory is case-sensitive or not.

nex3 commented

We're going to need some more details here:

  • What version of Dart Sass are you using?
  • How did you install Dart Sass?
  • How are you invoking Dart Sass?
  • What's the contents of your stylesheet?
  • What's the full path to the file you're trying to load?
  • What portion of that path is case-sensitive?
  1. Dart Sass version: 1.30.0
  2. I tried two methods: install by copying the files from the GitHub Windows 64-bit release and adding the location I put them to Path (as recommended on the Sass site), and install by the Chocolatey package manager. (Actually, I also tried node sass, which I installed by npm, which had the same problem).
  3. Since it's on the Path, I invoke it by the sass command. For example, sass styles.scss while the file is in the same directory.
  4. At the time I was just testing, so:
:root {
    --abc: 1;
}
  1. Path: D:\Libraries\Desktop\Computer\Games\SWTOR\Alts Site\sass\styles.scss. I tried using the full path (with quotes, obviously), or just the partial path while in the directory it's in, with the same result.
  2. The portion after Computer is case-sensitive. I set it up like this for better compatibility with WSL, which I often use.
nex3 commented

What output do you see if you run the command with --trace, in both Dart mode (installed from the GitHub release or Chocolatey) and npm mode?

Trace from dart sass (Chocolatey):

Error reading styles.scss: Cannot open file.

dart:io                                                           _File.readAsBytesSync
package:sass/src/io/vm.dart 40                                    readFile
package:sass/src/importer/filesystem.dart 31                      FilesystemImporter.load
package:sass/src/import_cache.dart 182                            ImportCache.importCanonical.<fn>
dart:collection                                                   _LinkedHashMapMixin.putIfAbsent 
package:sass/src/import_cache.dart 181                            ImportCache.importCanonical     
package:sass/src/compile.dart 56                                  compile
package:sass/src/executable/compile_stylesheet.dart 90            compileStylesheet
c:\programdata\chocolatey\lib\sass\tools\source\bin\sass.dart 64  main

Trace from sass from npm:

Error reading styles.scss: no such file or directory.

C:\Users\Zarai\AppData\Roaming\npm\node_modules\sass\sass.dart.js 1194:17   Object.wrapException
C:\Users\Zarai\AppData\Roaming\npm\node_modules\sass\sass.dart.js 12532:17  Object._systemErrorToFileSystemException
C:\Users\Zarai\AppData\Roaming\npm\node_modules\sass\sass.dart.js 12466:16  Object._readFile
C:\Users\Zarai\AppData\Roaming\npm\node_modules\sass\sass.dart.js 12454:35  Object.readFile
C:\Users\Zarai\AppData\Roaming\npm\node_modules\sass\sass.dart.js 41107:16  FilesystemImporter.load$1
C:\Users\Zarai\AppData\Roaming\npm\node_modules\sass\sass.dart.js 41057:33  ImportCache_importCanonical_closure.call$0
C:\Users\Zarai\AppData\Roaming\npm\node_modules\sass\sass.dart.js 24410:24  JsLinkedHashMap.putIfAbsent$2
C:\Users\Zarai\AppData\Roaming\npm\node_modules\sass\sass.dart.js 41013:32  ImportCache.importCanonical$3
C:\Users\Zarai\AppData\Roaming\npm\node_modules\sass\sass.dart.js 15767:42  <fn>
C:\Users\Zarai\AppData\Roaming\npm\node_modules\sass\sass.dart.js 4313:15   _wrapJsFunctionForAsync_closure.$protected
nex3 commented

Okay, I think I understand the issue here. As part of our canonicalization process, we call path.canonicalize(), which on Windows converts paths to lower case. However, this isn't strictly safe, since as you point out some Windows paths can be case-sensitive. I've filed dart-lang/path#102 to track that.