Skip to content

.NET Core + Chakra + Ubuntu can't find jsx file #355

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

Closed
malachib opened this issue Nov 28, 2016 · 18 comments
Closed

.NET Core + Chakra + Ubuntu can't find jsx file #355

malachib opened this issue Nov 28, 2016 · 18 comments

Comments

@malachib
Copy link

malachib commented Nov 28, 2016

I am trying to learn from the tutorial (https://reactjs.net/getting-started/tutorial.html) and navigated my way around this issue #338 as it appears to apply to Ubuntu also. Now, it looks like it's almost working, but it appears the file path resolution is incorrect:

System.IO.FileNotFoundException: Could not find file '/home/malachi/Projects/notos.server/src/notos.server/notos.server.web/bin/Debug/netcoreapp1.0/wwwroot/home/malachi/Projects/notos.server/src/notos.server/notos.server.web/bin/Debug/netcoreapp1.0/wwwroot/js/tutorial.jsx'.

See how the path is doubling up? That doesn't seem quite right. I doublechecked the path from <script src="@Url.Content("~/js/tutorial.jsx")"></script> and it spits out <script src="/js/tutorial.jsx"></script> , which seems to be expected behavior.

On a related note, when I attempt to do anything with Debian, I get a different error:

Error initialising JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngineFactory: JavaScriptEngineSwitcher.Core.JsEngineLoadException: During loading of ChakraCoreJsEngine error has occurred.
	
See more details:

Unable to load DLL 'ChakraCore': The specified module could not be found.
 (Exception from HRESULT: 0x8007007E) ---> System.DllNotFoundException: Unable to load DLL 'ChakraCore': The specified module could not be found.
 (Exception from HRESULT: 0x8007007E)
   at JavaScriptEngineSwitcher.ChakraCore.JsRt.NativeMethods.JsCreateRuntime(JsRuntimeAttributes attributes, JsThreadServiceCallback threadService, JsRuntime& runtime)
   at JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngine..ctor(ChakraCoreSettings settings)
   --- End of inner exception stack trace ---
   at JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngine..ctor(ChakraCoreSettings settings)
   at JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngineFactory.CreateEngine()
   at React.JavaScriptEngineFactory.GetFactory(JsEngineSwitcher jsEngineSwitcher, Boolean allowMsie)
Loaded '/home/malachi/.nuget/packages/VroomJs/1.2.3/lib/netstandard1.6/VroomJs.dll'. Cannot find or open the symbol file.

Startup ConfigureServices code uses:

            services.AddReact();

            // also for ReactJS.net, explicitly using Chakra lib since default Vroom
            // isn't fully available except on Windows
            services.AddJsEngineSwitcher(options =>
                options.DefaultEngineName = ChakraCoreJsEngine.EngineName).
                    AddChakraCore();

            // Add framework services.
            services.AddMvc();
@malachib malachib changed the title .NET Core + Chakra + Debian can't find jsx file .NET Core + Chakra + Ubuntu can't find jsx file Nov 28, 2016
@Taritsyn
Copy link
Contributor

Hello, Malachi!

Unable to load DLL 'ChakraCore': The specified module could not be found.

You have installed the JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64 package?

@malachib
Copy link
Author

malachib commented Nov 29, 2016

Hi @Taritsyn - thanks for the quick response!

Yes, I have installed ChakraCore.Native.debian-x64 - to the best of my knowledge. I have Startup.cs configured not only as described above, but also:

app.UseReact(config =>
            {
                // If you want to use server-side rendering of React components,
                // add all the necessary JavaScript files here. This includes
                // your components as well as all of their dependencies.
                // See http://reactjs.net/ for more information. Example:
                //config
                //  .AddScript("~/Scripts/First.jsx")
                //  .AddScript("~/Scripts/Second.jsx");

                // If you use an external build too (for example, Babel, Webpack,
                // Browserify or Gulp), you can improve performance by disabling
                // ReactJS.NET's version of Babel and loading the pre-transpiled
                // scripts. Example:
                //config
                //  .SetLoadBabel(false)
                //  .AddScriptWithoutTransform("~/Scripts/bundle.server.js");
            });

            app.UseStaticFiles();

Furthermore, my project.json has the following:

    "React.AspNet": "3.0.0",
    "JavaScriptEngineSwitcher.ChakraCore": "2.1.2",
    "JavaScriptEngineSwitcher.V8.Native.win-x64": "2.1.1",
    "JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64": "2.1.0",
    "JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64": "2.1.0",
    "JavaScriptEngineSwitcher.ChakraCore.Native.win-x64": "2.1.1",
    "JavaScriptEngineSwitcher.Extensions.MsDependencyInjection": "2.0.0",```

Lastly, the aforementioned exception is augmented also by this exception:

React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.ReactEnvironment ---> React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.JavaScriptEngineFactory ---> React.Exceptions.VroomJsInitialisationException: Failed to initialise VroomJs. This is most likely caused by the native library (libVroomJsNative.so) being out of date or your system lacking a compatible version of V8. Please run Mono with the `MONO_LOG_LEVEL=debug` environment variable for more debugging information, and refer to the ReactJS.NET Mono documentation at http://reactjs.net/guides/mono.html for further debugging hints.

 More details: Exception has been thrown by the target of an invocation.
   at React.JavaScriptEngineUtils.EnsureEngineFunctional[TEngine,TException](Func`2 exceptionFactory)
   at React.JavaScriptEngineFactory.GetFactory(JsEngineSwitcher jsEngineSwitcher, Boolean allowMsie)
   at React.JavaScriptEngineFactory..ctor(JsEngineSwitcher jsEngineSwitcher, IReactSiteConfiguration config, IFileSystem fileSystem)
   at lambda_method(Closure , Object[] )
   at React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
   --- End of inner exception stack trace ---
   at React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.SingletonFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
   --- End of inner exception stack trace ---
   at React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.CustomObjectLifetimeFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.Resolve[ResolveType]()
   at React.AspNet.BabelFileMiddleware.<Invoke>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()

@Taritsyn
Copy link
Contributor

What version of Ubuntu are you using?

Give a example of the frameworks section from the project.json file.

@malachib
Copy link
Author

It's Ubuntu 16.04.01 & uname produces:

Linux vm-c131-ubuntudev 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

frameworks section looks like:

  "frameworks": {
    "netcoreapp1.0": {
      "buildOptions": {
        "define": [ "DNXCORE50" ]
      }
    }
  },

My debian machine uname produces: Linux vm-c131-debian 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux

@Taritsyn
Copy link
Contributor

Taritsyn commented Nov 29, 2016

"frameworks": {
  "netcoreapp1.0": {
    "buildOptions": {
      "define": [ "DNXCORE50" ]
    }
  }
},

I recommend to remove all the JavaScriptEngineSwitcher.V8 packages, because it is not compatible with the netcoreapp1.0.

My debian machine uname produces: Linux vm-c131-debian 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux

I have built and tested the libChakraCore.so assembly for the JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64 package on Ubuntu 16.04.1 x64.
Much has been done by analogy with the ASP.NET Libuv Package, therefore not tested for compatibility with Debian.

Try to build the libChakraCore.so assembly on Debian. To do this, follow these steps:

  1. Download source code of ChakraCore version of October 29, 2016 and uncompress it.
  2. Open terminal and start the update process:
sudo apt-get update
sudo apt-get dist-upgrade
  1. Install dependencies:
sudo apt-get install -y build-essential cmake clang libunwind-dev libicu-dev
  1. Change current directory to the directory with source code of ChakraCore.
  2. Start build:
./build.sh
  1. From the BuildLinux/Release/ directory copy the libChakraCore.so file to the ~/.nuget/packages/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/2.1.0/runtimes/debian-x64/native/ directory.

After all these steps, run your web application.

@malachib
Copy link
Author

Thank you for this insight.

Firstly, I'll ensure the .V8 is removed.

Secondly, struggling a bit since Debian and its ever-so-antiquated packages are only up to clang 3.5 but ChakraCore wants 3.7. Still futzing with that.

Lastly, revisiting the Ubuntu scenario (the title issue) - any clues as to why the FileNotFoundException is occurring?

@Taritsyn
Copy link
Contributor

Hello, Malachi!

Lastly, revisiting the Ubuntu scenario (the title issue) - any clues as to why the FileNotFoundException is occurring?

To solve this problem can only @Daniel15, because I am creator of the JavaScript Engine Switcher and have to the React.NET project only indirectly related.

It seems to me, that the problem is in implementation of the MapPath method of AspNetFileSystem class.

@Daniel15
Copy link
Member

Daniel15 commented Dec 1, 2016

struggling a bit since Debian and its ever-so-antiquated packages

This is why I use Debian Testing (Stretch) in production, it's still stable enough for everyday use :)

Lastly, revisiting the Ubuntu scenario (the title issue) - any clues as to why the FileNotFoundException is occurring?

I suspect something is wrong with MapPath, like @Taritsyn mentioned. It's working fine for me on Mono (http://dan.cx/socialfeed.htm is running on Mono) but I haven't done extensive testing on .NET Core on Linux. Pull requests are appreciated :)

@malachib
Copy link
Author

malachib commented Dec 2, 2016

OK well I appreciate the attention and feedback - for now I am gonna do some workarounds, Since I'm so new to react, I'm not even sure how extensively I'll be using it. When things settle down and if I'm still in the react world, I'll have a look at AspNetFileSystem

@pablinos
Copy link

I had this same error running the dotnet docker container. I went to get the source to build a version of ChakraCore as suggested and noticed that there was a linux-x64 binary version.

https://github.com/Microsoft/ChakraCore/releases

I downloaded that and copied the libCharkaCore.so to the ~/.nuget/packages/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/2.1.0/runtimes/debian-x64/native/ directory and it fixed it.

Would it be worth updating the native packages so it's just a linux-x64 one and could track the official binary releases?

@Taritsyn
Copy link
Contributor

Hello, Paul!

I had this same error running the dotnet docker container.

Which Linux are you using?

I downloaded that and copied the libCharkaCore.so to the ~/.nuget/packages/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/2.1.0/runtimes/debian-x64/native/ directory and it fixed it.

May be need to upgrade to version 2.4.6?

Would it be worth updating the native packages so it's just a linux-x64 one and could track the official binary releases?

I do not quite understand how Microsoft's employees build such an assembly. In official instruction, nothing is written about this. Microsoft's version of the libCharkaCore.so assembly weighs 2.5 times more than my version. As an experiment, I will add the JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64 package to version 3.0.0 Alpha 6.

@pablinos
Copy link

Hi,

Linux version is Debian Jessie as it's the dotnet Docker image.

That is weird that it defaulted to the 2.1 version. Could it be to do with the project being dotnet core/tools 1.1.4?

I'm not sure how they'd be a universal library like that either, but being 2.5 times the size, it does suggest there's a lot more in there! Perhaps they explain it if we asked the question there?

@Taritsyn
Copy link
Contributor

I'm not sure how they'd be a universal library like that either, but being 2.5 times the size, it does suggest there's a lot more in there! Perhaps they explain it if we asked the question there?

It seems, that Microsoft's employees build a ChakraCore library with the following parameters:

./build.sh --embed-icu -j=2

I.e. your problem is very similar to the same problem with OS X. Both problems caused by lack of a suitable version of the ICU library. All this universality is achieved through embedding of the ICU-57 library to the ChakraCore assembly (because of this, assembly size is increased by 2,5 times).

@pablinos
Copy link

Ah, unicode and timezones, two things that have given me a lot of headaches over the years!

I'll try installing ICU and see if the library version in the Debian package works or not.

@Taritsyn
Copy link
Contributor

@pablinos In version 3.0.0 Alpha 6 ICU-57 library was embedded into the libChakraCore.so and libChakraCore.dylib assemblies.

@Taritsyn
Copy link
Contributor

@pablinos I moved the corresponding functionality from 3.X branch to version 2.4.12.

@pablinos
Copy link

pablinos commented Feb 21, 2018 via email

@dustinsoftware
Copy link
Member

Closing issues older than a year, please re-open if you think this is still relevant.

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

5 participants