Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using LibSass on MacOS #16

Closed
pefgoncalves opened this issue Aug 23, 2017 · 31 comments
Closed

Using LibSass on MacOS #16

pefgoncalves opened this issue Aug 23, 2017 · 31 comments

Comments

@pefgoncalves
Copy link

pefgoncalves commented Aug 23, 2017

Hi! First, I need to congrats you for this lib. Really useful. So, I am porting and existing .net app to mono but i couldn't install 'LibSassHost.Native.osx-x64.1.0.4' there. Probably i am missing something.

I generated the build file described here: https://github.com/Taritsyn/LibSassHost#os-x, but the output generated was *.dylib, and i couldn't make it work on my project. If you could help me with that i really appreciate.

This is the error i got:

Could not install package 'LibSassHost.Native.osx-x64 1.0.4'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

edit:
I moved the generated file to: /Library/Frameworks/ and it's working.

tks!

@pefgoncalves
Copy link
Author

The only thing is still not working is the importing path. Looks like it's getting on app root folder.

During translation of SCSS code, readed from the file '~/Styles/_bootstrap.scss', to CSS code syntax error has occurred. 
See more details:

Message: File to import not found or unreadable: bootstrap/variables.
Parent style sheet: ~/Styles/_bootstrap.scss
File: ~/Styles/_bootstrap.scss
Line number: 8
Column number: 1
Source fragment:

Line 7: // Core variables and mixins
Line 8: @import "bootstrap/variables";
--------^
Line 9: @import "bootstrap/mixins";

If i change my import to use full path, it works:
``` @import "/styles/bootstrap/variables";````

@Taritsyn
Copy link
Owner

Hello!

So, I am porting and existing .net app to mono but i couldn't install 'LibSassHost.Native.osx-x64.1.0.4' there.

In package description and documentation clearly says the following: “This package is only compatible with .NET Core.”. In Mono you need to independently deploy the libsass.dylib assembly file.

I generated the build file described here: https://github.com/Taritsyn/LibSassHost#os-x, but the output generated was *.dylib, and i couldn't make it work on my project.

This is correct behavior.

During translation of SCSS code, readed from the file '~/Styles/_bootstrap.scss', to CSS code syntax error has occurred.

Are you porting an ASP.NET application?

@Taritsyn
Copy link
Owner

You are trying to use the Bundle Transformer in Mono for OS X? Are you using the original assemblies or modified source code?

@pefgoncalves
Copy link
Author

pefgoncalves commented Aug 24, 2017

Yes, porting an .net app and i'm also using Bundle Transformer with original assemblies:

var styleBundle = new CustomStyleBundle("~/lib/css").Include(
               "~/Styles/jquery-ui/jquery-ui.structure.css",
               "~/Styles/jquery-ui/jquery-ui.theme.css",
               "~/Styles/_bootstrap.scss",
               "~/Styles/jquery.webui-popover.css",
               "~/Styles/jscrollpane.css",
               "~/Styles/font-awesome/css/font-awesome.css",
               "~/Styles/bootstrap-datepicker.min.css",
               "~/Styles/animate.css",
               "~/Styles/text-angular/textAngular.css",
               "~/Styles/daterangepicker-angular/daterangepicker.css",
               "~/Styles/app.scss"
            );

            styleBundle.Builder = new NullBuilder();
            styleBundle.Transforms.Add(new StyleTransformer());
            styleBundle.Orderer = new NullOrderer();
            bundles.Add(styleBundle);

@Taritsyn
Copy link
Owner

Taritsyn commented Aug 24, 2017

During translation of SCSS code, readed from the file '~/Styles/_bootstrap.scss', to CSS code syntax error has occurred.
…

This error message shows, that path of _bootstrap.scss file was not converted to absolute. It still starts with a ~/, but must starts with a /.

I recommend you to debug a ToAbsolutePath method of VirtualFileManager class. Most likely, this problem is caused by specificity of the Virtual Path Provider implementation for Mono. How to set your own VPP read the “New Web Optimization Pre-Release Package on NuGet” article.

P.S.: I do not guarantee compatibility of the Bundle Transformer with operating systems other than Windows.

@Taritsyn
Copy link
Owner

Try to update the Bundle Transformer to version 1.9.171 Beta 1. Waiting for feedback.

@pefgoncalves
Copy link
Author

pefgoncalves commented Aug 25, 2017

Still not working:

These assets are not style sheets: ~/Styles/_bootstrap.scss, ~/Styles/twyne.scss.

Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): BundleTransformer.Core.
Exception stack trace:

at BundleTransformer.Core.Validators.StyleAssetTypesValidator.Validate (System.Collections.Generic.IList`1[T] assets) [0x00092] in <2225cff0685c4a3da247b1bb67f35bcf>:0 
  at BundleTransformer.Core.Transformers.StyleTransformer.ValidateAssetTypes (System.Collections.Generic.IList`1[T] assets) [0x00006] in <2225cff0685c4a3da247b1bb67f35bcf>:0 
  at BundleTransformer.Core.Transformers.TransformerBase.Transform (System.Collections.Generic.IList`1[T] assets, System.Web.Optimization.BundleContext bundleContext, System.Web.Optimization.BundleResponse bundleResponse, System.Web.Hosting.VirtualPathProvider virtualPathProvider, System.Boolean isDebugMode) [0x00000] in <2225cff0685c4a3da247b1bb67f35bcf>:0 
  at BundleTransformer.Core.Transformers.TransformerBase.Process (System.Web.Optimization.BundleContext bundleContext, System.Web.Optimization.BundleResponse bundleResponse, System.Boolean isDebugMode) [0x00088] in <2225cff0685c4a3da247b1bb67f35bcf>:0 
  at BundleTransformer.Core.Transformers.TransformerBase.Process (System.Web.Optimization.BundleContext bundleContext, System.Web.Optimization.BundleResponse bundleResponse) [0x0000d] in <2225cff0685c4a3da247b1bb67f35bcf>:0 
  at System.Web.Optimization.Bundle.ApplyTransforms (System.Web.Optimization.BundleContext context, System.String bundleContent, System.Collections.Generic.IEnumerable`1[T] bundleFiles) [0x00041] in <1722374db59b42df883d8c695dc145b3>:0 
  at System.Web.Optimization.Bundle.GenerateBundleResponse (System.Web.Optimization.BundleContext context) [0x00061] in <1722374db59b42df883d8c695dc145b3>:0 
  at BundleTransformer.Core.Resolvers.CustomBundleResolver.GetBundleResponse (System.Web.Optimization.Bundle bundle, System.Web.Optimization.BundleContext context) [0x00013] in <2225cff0685c4a3da247b1bb67f35bcf>:0 
  at BundleTransformer.Core.Resolvers.CustomBundleResolver.GetBundleContents (System.String bundleVirtualPath) [0x0003a] in <2225cff0685c4a3da247b1bb67f35bcf>:0 
  at System.Web.Optimization.AssetManager.DeterminePathsToRender (System.Collections.Generic.IEnumerable`1[T] assets) [0x0003a] in <1722374db59b42df883d8c695dc145b3>:0 
  at System.Web.Optimization.AssetManager.RenderExplicit (System.String tagFormat, System.String[] paths) [0x00000] in <1722374db59b42df883d8c695dc145b3>:0 
  at System.Web.Optimization.Styles.RenderFormat (System.String tagFormat, System.String[] paths) [0x0004d] in <1722374db59b42df883d8c695dc145b3>:0 
  at System.Web.Optimization.Styles.Render (System.String[] paths) [0x00005] in <1722374db59b42df883d8c695dc145b3>:0 
  at ASP._Page_Views_Shared__LoginLayout_cshtml.Execute () [0x0005d] in /Users/pgoncalves/dev/clients/twyne/twyne.admin.v2/Views/Shared/_LoginLayout.cshtml:7 
  at System.Web.WebPages.WebPageBase.ExecutePageHierarchy () [0x00054] in <455c0c5cbc804c5abc3af7275091c0c5>:0 
  at System.Web.Mvc.WebViewPage.ExecutePageHierarchy () [0x0001d] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.WebPages.WebPageBase.ExecutePageHierarchy (System.Web.WebPages.WebPageContext pageContext, System.IO.TextWriter writer, System.Web.WebPages.WebPageRenderingBase startPage) [0x0002f] in <455c0c5cbc804c5abc3af7275091c0c5>:0 
  at System.Web.WebPages.WebPageBase.ExecutePageHierarchy (System.Web.WebPages.WebPageContext pageContext, System.IO.TextWriter writer) [0x00000] in <455c0c5cbc804c5abc3af7275091c0c5>:0 
  at System.Web.WebPages.WebPageBase+<>c__DisplayClass3.<RenderPageCore>b__2 (System.IO.TextWriter writer) [0x00085] in <455c0c5cbc804c5abc3af7275091c0c5>:0 
  at System.Web.WebPages.HelperResult.WriteTo (System.IO.TextWriter writer) [0x00000] in <455c0c5cbc804c5abc3af7275091c0c5>:0 
  at System.Web.WebPages.WebPageExecutingBase.WriteTo (System.IO.TextWriter writer, System.Web.WebPages.HelperResult content) [0x00003] in <455c0c5cbc804c5abc3af7275091c0c5>:0 
  at System.Web.WebPages.WebPageBase.Write (System.Web.WebPages.HelperResult result) [0x00006] in <455c0c5cbc804c5abc3af7275091c0c5>:0 
  at System.Web.WebPages.WebPageBase.RenderSurrounding (System.String partialViewName, System.Action`1[T] body) [0x00027] in <455c0c5cbc804c5abc3af7275091c0c5>:0 
  at System.Web.WebPages.WebPageBase.PopContext () [0x00037] in <455c0c5cbc804c5abc3af7275091c0c5>:0 
  at System.Web.WebPages.WebPageBase.ExecutePageHierarchy (System.Web.WebPages.WebPageContext pageContext, System.IO.TextWriter writer, System.Web.WebPages.WebPageRenderingBase startPage) [0x00035] in <455c0c5cbc804c5abc3af7275091c0c5>:0 
  at System.Web.Mvc.RazorView.RenderView (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer, System.Object instance) [0x000c7] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.BuildManagerCompiledView.Render (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) [0x00067] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x00080] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0000b] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0009b] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0009b] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0009b] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters (System.Web.Mvc.ControllerContext controllerContext, System.Collections.Generic.IList`1[T] filters, System.Web.Mvc.ActionResult actionResult) [0x0000a] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass21+<>c__DisplayClass2b.<BeginInvokeAction>b__1c () [0x0008a] in <cc73190bab9d435c831510ff295c572a>:0 

That is the content o _bootstrap.scss


// Core variables and mixins
@import "bootstrap/variables";
@import "bootstrap/mixins";

// Reset and dependencies
@import "bootstrap/normalize";

@Taritsyn
Copy link
Owner

These assets are not style sheets: ~/Styles/_bootstrap.scss, ~/Styles/twyne.scss.

It looks like you do not have the following settings in the Web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
	…
	<bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">
		<core>
			…
			<css …>
				…
				<fileExtensions>
					…
					<add fileExtension=".sass" assetTypeCode="Sass" />
					<add fileExtension=".scss" assetTypeCode="Scss" />
					…
				</fileExtensions>
				…
			</css>
			…
		</core>
		…
	</bundleTransformer>
	…
</configuration>

I already see such a error today.

Yes, porting an .net app...

If your .NET application is not a ASP.NET web application, then what kind of .NET application is it?

@pefgoncalves
Copy link
Author

With your suggestion, worked, but looks like the imported files are not loading up:

image

@Taritsyn
Copy link
Owner

You have installed the BundleTransformer.SassAndScss package?

@Taritsyn
Copy link
Owner

Remove the following line:

styleBundle.Transforms.Add(new StyleTransformer());

@Taritsyn
Copy link
Owner

You registered a bundle with a ~/Styles/bootstrap/mixins name?

@pefgoncalves
Copy link
Author

I removed that line, but same effect.

I haven't, but why am I need to have it? on _bootstrap, I have this:
@import "bootstrap/mixins";
and mixin has other includes:

@import "mixins/hide-text";
@import "mixins/opacity";
@import "mixins/image";
@import "mixins/labels";
@import "mixins/reset-filter";
@import "mixins/resize";
@import "mixins/responsive-visibility";
@import "mixins/size";
@import "mixins/tab-focus";
@import "mixins/reset-text";
@import "mixins/text-emphasis";
@import "mixins/text-overflow";
@import "mixins/vendor-prefixes";
```

@Taritsyn
Copy link
Owner

Why did you request through the browser this URL - /Styles/bootstrap/mixins/?

@pefgoncalves
Copy link
Author

I didn't do that. Looks like the css is parsing as another file. This is happening when there is nested imports.

@pefgoncalves
Copy link
Author

Check this out, every import is doing extra requests:

image

@Taritsyn
Copy link
Owner

You have this web application worked on Windows?

@pefgoncalves
Copy link
Author

Yes, the same source code is working fine

@Taritsyn
Copy link
Owner

Check which result produces the following expression:

System.Web.VirtualPathUtility.ToAbsolute("~/Styles/_bootstrap.scss")

@Taritsyn
Copy link
Owner

Yes, the same source code is working fine

Where did “These assets are not style sheets: ~/Styles/_bootstrap.scss, ~/Styles/twyne.scss.” error come from?

@pefgoncalves
Copy link
Author

/Styles/_bootstrap.scss

@pefgoncalves
Copy link
Author

I had when i access any route that is including render

@Taritsyn
Copy link
Owner

Now check this expression:

new BundleTransformer.Core.FileSystem.VirtualFileSystemWrapper().ToAbsolutePath("~/Styles/_bootstrap.scss")

@pefgoncalves
Copy link
Author

I can't find this namespace: BundleTransformer.Core

@Taritsyn
Copy link
Owner

I can't find this namespace: BundleTransformer.Core

It doesn't matter. I have tested the Bundle Transformer on Mono for Mac OS X.

To fix a error add the following settings to the Web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
	…
	<system.web>
		…
		<httpHandlers>
			…
			<add path="*.sass" verb="GET"
				type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss" />
			<add path="*.scss" verb="GET"
				type="BundleTransformer.SassAndScss.HttpHandlers.SassAndScssAssetHandler, BundleTransformer.SassAndScss" />
			…
		</httpHandlers>
		…
	</system.web>
	…
</configuration>

This error is described in detail in the “Mono and IHttpHandler” discussion on Stack Overflow. Solution to this problem is also described in the “Sass and SCSS” section of documentation.

@pefgoncalves
Copy link
Author

Awesome! It's working perfectly! Thank you much for your help =)

@pefgoncalves
Copy link
Author

Hey, i updated the libs and i'm having this:

sass_file_manager_set_get_current_directory_delegate

Description: HTTP 500.Error processing request.
Details: Non-web exception.
Exception stack trace:
  at (wrapper managed-to-native) LibSassHost.Internal.Native.Sass_Api:sass_file_manager_set_get_current_directory_delegate_utf8 (LibSassHost.Internal.Native.Func_StringAnsi)
  at LibSassHost.Internal.FileManagerMarshaler.SetFileManager (LibSassHost.IFileManager fileManager) [0x000fb] in <001e106848664c699a34bda535594f0f>:0 
  at LibSassHost.SassCompiler.set_FileManager (LibSassHost.IFileManager value) [0x00016] in <001e106848664c699a34bda535594f0f>:0 
  at BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.Initialize () [0x00035] in <b7a265be386e4ea58be4ccc428d06b2b>:0 
  at BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.Translate (System.Collections.Generic.IList`1[T] assets) [0x00050] in <b7a265be386e4ea58be4ccc428d06b2b>:0 
  at BundleTransformer.Core.Transformers.TransformerBase.Translate (System.Collections.Generic.IList`1[T] assets, System.Boolean isDebugMode) [0x0001e] in <1ce8222a4b614473b2f3be937f52afca>:0 
  at BundleTransformer.Core.Transformers.TransformerBase.Transform (System.Collections.Generic.IList`1[T] assets, System.Web.Optimization.BundleContext bundleContext, System.Web.Optimization.BundleResponse bundleResponse, System.Web.Hosting.VirtualPathProvider virtualPathProvider, System.Boolean isDebugMode) [0x00024] in <1ce8222a4b614473b2f3be937f52afca>:0 
  at BundleTransformer.Core.Transformers.TransformerBase.Process (System.Web.Optimization.BundleContext bundleContext, System.Web.Optimization.BundleResponse bundleResponse, System.Boolean isDebugMode) [0x00088] in <1ce8222a4b614473b2f3be937f52afca>:0 
  at BundleTransformer.Core.Transformers.TransformerBase.Process (System.Web.Optimization.BundleContext bundleContext, System.Web.Optimization.BundleResponse bundleResponse) [0x0000d] in <1ce8222a4b614473b2f3be937f52afca>:0 
  at System.Web.Optimization.Bundle.ApplyTransforms (System.Web.Optimization.BundleContext context, System.String bundleContent, System.Collections.Generic.IEnumerable`1[T] bundleFiles) [0x00041] in <1722374db59b42df883d8c695dc145b3>:0 
  at System.Web.Optimization.Bundle.GenerateBundleResponse (System.Web.Optimization.BundleContext context) [0x00061] in <1722374db59b42df883d8c695dc145b3>:0 
  at BundleTransformer.Core.Resolvers.CustomBundleResolver.GetBundleResponse (System.Web.Optimization.Bundle bundle, System.Web.Optimization.BundleContext context) [0x00013] in <1ce8222a4b614473b2f3be937f52afca>:0 
  at BundleTransformer.Core.Resolvers.CustomBundleResolver.GetBundleContents (System.String bundleVirtualPath) [0x0003a] in <1ce8222a4b614473b2f3be937f52afca>:0 
  at System.Web.Optimization.AssetManager.DeterminePathsToRender (System.Collections.Generic.IEnumerable`1[T] assets) [0x0003a] in <1722374db59b42df883d8c695dc145b3>:0 
  at System.Web.Optimization.AssetManager.RenderExplicit (System.String tagFormat, System.String[] paths) [0x00000] in <1722374db59b42df883d8c695dc145b3>:0 
  at System.Web.Optimization.Styles.RenderFormat (System.String tagFormat, System.String[] paths) [0x0004d] in <1722374db59b42df883d8c695dc145b3>:0 
  at System.Web.Optimization.Styles.Render (System.String[] paths) [0x00005] in <1722374db59b42df883d8c695dc145b3>:0 ```

do you know what it could be?

@pefgoncalves pefgoncalves reopened this Aug 29, 2017
@Taritsyn
Copy link
Owner

Most likely, you are using the version of libsass.dylib assembly, which is not adapted for the LibSass Host. About this is written in the documentation.

I recommend you to download a modified version of the LibSass library.

@pefgoncalves
Copy link
Author

I just copied your file to /Library/Frameworks/ and having the same issue.

@pefgoncalves
Copy link
Author

I had to copy the file to projectroot, and with that worked, Is that the correct behavior?

@Taritsyn
Copy link
Owner

If you installed the LibSass library by using the following command:

brew install libsass

or

brew reinstall libsass

As a result, libsass.0.dylib, libsass.a and libsass.dylib files were linked to the /usr/local/lib/ directory. To remove these files, run the following command:

brew remove --force libsass

Then you can install a modified version of the LibSass library as follows:

mkdir -p /usr/local/lib/ && cp libsass.dylib "$_"

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

No branches or pull requests

2 participants