Deeply nested @import statements fail with long chains of relative paths #1076

altearius opened this Issue Jan 7, 2014 · 0 comments


None yet

2 participants


I am using sass 3.2.12 on Windows.

I note that the @import directive begins to fail when it encounters a particularly long chain of relative paths. Although I am happy to respect some limit in path length, the current failure state seems unnecessary: each successive import creates its relative path based on the relative path of all imports before it. Observe this failure message:

C:\Temp\compass\test>sass sass\1_I_Am_The_Very_Model_Of_A_Modern_Major_General\ModernMajorGeneral.scss stylesheets\1_I_Am_The_Very_Model_Of_A_Modern_Major_General\ModernMajorGeneral.css
Syntax error: File to import not found or unreadable: ../5_I_Am_Very_Well_Acquainted_Too_With_Matters_Mathematical/Mathematical.scss.
              Load path: C:/Temp/compass/test
        on line 1 of sass/1_I_Am_The_Very_Model_Of_A_Modern_Major_General/../2_I_Have_Information_Vegetable_Animal_And_Mineral/../3_I_Know_The_Kings_Of_England_And_I_Quote_The_Fights_Historical/../4_From_Marathon_to_Waterloo_In_Order_Categorical/Marathon.scss
        from line 1 of sass/1_I_Am_The_Very_Model_Of_A_Modern_Major_General/../2_I_Have_Information_Vegetable_Animal_And_Mineral/../3_I_Know_The_Kings_Of_England_And_I_Quote_The_Fights_Historical/Monarchy.scss
        from line 1 of sass/1_I_Am_The_Very_Model_Of_A_Modern_Major_General/../2_I_Have_Information_Vegetable_Animal_And_Mineral/Vegetable.scss
        from line 1 of sass\1_I_Am_The_Very_Model_Of_A_Modern_Major_General\ModernMajorGeneral.scss
  Use --trace for backtrace.

Based on the error message, I infer that it is attempting to load a file using this very long path:


This monstrous path is 304 characters long, and I find it quite reasonable that such a long path should fail. However, note all those ".." bits in there! If those were resolved, the true path would be simply:


At only 81 characters, it seems much more reasonable.

If I rename 5_I_Am_Very_Well_Acquainted_Too_With_Matters_Mathematical/Mathematical.scss to merely 5b/M.scss (and adjust the corresponding @import statement), the problem goes away.

Although this example is contrived, I am actually encountering this in a real-world scenario. While I am using compass, the problem occurs even when I use the sass compiler directly.


@nex3 nex3 added a commit that referenced this issue Jan 23, 2014
@nex3 nex3 Clean up file paths when importing.
Closes #1076
@nex3 nex3 closed this Jan 23, 2014
@nex3 nex3 added a commit that referenced this issue Jan 24, 2014
@nex3 nex3 Clean up file paths when importing.
Closes #1076
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment