excubo-ag / WebCompiler

Apache License 2.0
151 stars 30 forks source link

Sass compilation fails on linux x64 #60

Closed 8399Saalsat closed 1 year ago

8399Saalsat commented 2 years ago

Reproduction steps

  1. On an x64 linux machine run the unit test (dotnet test in the solution directory)

Expected results: All tests pass

Actual results: 20 of 30 tests fail with a Sass compiler error

Environment

The error states that the V8JsEngine instances couldn't be created due to a missing dependency. The dependency appears to be correctly referenced as a package in WebCompiler.csproj, so this seems like an issue in the V8 library with detecting the operating system at runtime

<PackageReference Include="Microsoft.ClearScript.V8.Native.linux-x64" Version="7.2.3" />

I have attached a screenshot of the test failure and the corresponding stack trace.

webcompiler_test_failure

Stack Trace:
     at Tests_WebCompiler.WholeProgramTests.UseConfigWithRecursion() in /home/buildagent/webcompilertest/WebCompiler/Tests_WebCompiler/WholeProgramTests.cs:line 202

  Standard Error Messages:
 A compilation step encountered an exception During loading of Sass compiler error has occurred. Failed to create instance of the V8JsEngine. Most likely it happened, because the 'ClearScriptV8.linux-x64.so' assembly or one of its dependencies was not found. Try to install the Microsoft.ClearScript.V8.Native.linux-x64 package via NuGet. with stacktrace:
    at DartSassHost.SassCompiler.InitializeCompiler()
    at DartSassHost.SassCompiler.CompileFile(String inputPath, String outputPath, String sourceMapPath, CompilationOptions options)
    at WebCompiler.Compile.SassCompiler.Compile(List`1 file_sequence) in /home/buildagent/webcompilertest/WebCompiler/WebCompiler/Compile/SassCompiler.cs:line 72
    at WebCompiler.Compile.CompilationStep.With(Compiler compiler) in /home/buildagent/webcompilertest/WebCompiler/WebCompiler/Compile/CompilationStep.cs:line 22

 The internal compiler SassCompiler encountered an exception: During loading of Sass compiler error has occurred. Failed to create instance of the V8JsEngine. Most likely it happened, because the 'ClearScriptV8.linux-x64.so' assembly or one of its dependencies was not found. Try to install the Microsoft.ClearScript.V8.Native.linux-x64 package via NuGet..
 The stacktrace was:
    at DartSassHost.SassCompiler.InitializeCompiler()
    at DartSassHost.SassCompiler.CompileFile(String inputPath, String outputPath, String sourceMapPath, CompilationOptions options)
    at WebCompiler.Compile.SassCompiler.Compile(List`1 file_sequence) in /home/buildagent/webcompilertest/WebCompiler/WebCompiler/Compile/SassCompiler.cs:line 72
    at WebCompiler.Compile.CompilationStep.With(Compiler compiler) in /home/buildagent/webcompilertest/WebCompiler/WebCompiler/Compile/CompilationStep.cs:line 22
 The state before this operations looked like this:
 - /home/buildagent/webcompilertest/WebCompiler/Tests_WebCompiler/TestCases/Scss/sub/foo.scss (False)
8399Saalsat commented 2 years ago

I was able to get all of the tests passing by switching the ClearScript.V8 engine switcher packages out with the ChakraCore equivalent packages. The ChakraCore libaries work on both Linux and Windows (I am unable to test on Mac).

I'm not sure if there was a specific reason V8 was chosen over ChakraCore. I did notice the example projects in the DartSassHost library also use ChakraCore.

I can submit my changes for PR if there's interest.


  Restored /home/buildagent/webcompilertest/WebCompiler/WebCompiler/WebCompiler.csproj (in 348 ms).
  Restored /home/buildagent/webcompilertest/WebCompiler/Tests_WebCompiler/Tests_WebCompiler.csproj (in 348 ms).
/home/buildagent/webcompilertest/WebCompiler/WebCompiler/Program.cs(63,17): warning SYSLIB0020: 'JsonSerializerOptions.IgnoreNullValues' is obsolete: 'JsonSerializerOptions.IgnoreNullValues is obsolete. To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingNull.' [/home/buildagent/webcompilertest/WebCompiler/WebCompiler/WebCompiler.csproj]
/home/buildagent/webcompilertest/WebCompiler/WebCompiler/Program.cs(266,38): warning CS8604: Possible null reference argument for parameter 'value' in 'bool string.StartsWith(string value)'. [/home/buildagent/webcompilertest/WebCompiler/WebCompiler/WebCompiler.csproj]
/home/buildagent/webcompilertest/WebCompiler/WebCompiler/Program.cs(255,20): warning CS8603: Possible null reference return. [/home/buildagent/webcompilertest/WebCompiler/WebCompiler/WebCompiler.csproj]
/home/buildagent/webcompilertest/WebCompiler/WebCompiler/Compile/SassCompiler.cs(167,50): warning CS8604: Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'. [/home/buildagent/webcompilertest/WebCompiler/WebCompiler/WebCompiler.csproj]
/home/buildagent/webcompilertest/WebCompiler/WebCompiler/Compile/SassCompiler.cs(178,50): warning CS8604: Possible null reference argument for parameter 'path1' in 'string Path.Combine(string path1, string path2)'. [/home/buildagent/webcompilertest/WebCompiler/WebCompiler/WebCompiler.csproj]
/home/buildagent/webcompilertest/WebCompiler/WebCompiler/Compile/Place.cs(48,47): warning CS8604: Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'. [/home/buildagent/webcompilertest/WebCompiler/WebCompiler/WebCompiler.csproj]
  WebCompiler -> /home/buildagent/webcompilertest/WebCompiler/WebCompiler/bin/Debug/net6.0/Excubo.WebCompiler.dll
  Tests_WebCompiler -> /home/buildagent/webcompilertest/WebCompiler/Tests_WebCompiler/bin/Debug/net6.0/Tests_WebCompiler.dll
Test run for /home/buildagent/webcompilertest/WebCompiler/Tests_WebCompiler/bin/Debug/net6.0/Tests_WebCompiler.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:    50, Skipped:     0, Total:    50, Duration: 26 s -```
8399Saalsat commented 2 years ago

I went ahead and opened the PR https://github.com/excubo-ag/WebCompiler/pull/61

stefanloerwald commented 2 years ago

Hi @8399Saalsat,

Thanks for raising this. The JS engine is certainly the weakest link... I had to replace it a few times already and it seems to continue to be a source of issues.

I think we had ChakraCore in the past and I remember that there were issues as well. I'll take a look at the history and try to remember what that was. I'll get back to you on this once I've found the pieces of information.

Stefan

stefanloerwald commented 2 years ago

Actually, let me do it right now. Easier to find than I thought...

Using ChakraCore, these were the issues: https://github.com/Taritsyn/AutoprefixerHost/issues/1 https://github.com/Taritsyn/DartSassHost/issues/2

I'm not quite comfortable at this point to switch back, because I want to avoid a back-and-forth thing... What do you think? Does it work for you to work with a locally built version until the issues with the dependencies are resolved?

8399Saalsat commented 2 years ago

Yeah we've got a local build of my fork that will work for now. In the mean time I'll try to get an issue opened in the ClearScript repository.

Thanks for the quick response!