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

It says emscripten is not installed but it is! #60

Open
Boscop opened this issue Jan 30, 2018 · 24 comments
Open

It says emscripten is not installed but it is! #60

Boscop opened this issue Jan 30, 2018 · 24 comments

Comments

@Boscop
Copy link

Boscop commented Jan 30, 2018

I followed the steps here and it worked with the hello.rs to hello.js with rustc --target asmjs-unknown-emscripten hello.rs but now I'm trying to build a yew example and it says emscripten is not installed, why?

D:\3rdparty\yew\examples\counter>"d:\Program Files\emsdk-portable-64bit\emsdk_env.bat"
Adding directories to PATH:
PATH += d:\Program Files\emsdk-portable-64bit

Setting environment variables:
EMSDK = d:/Program Files/emsdk-portable-64bit
EM_CONFIG = C:\Users\me\.emscripten


D:\3rdparty\yew\examples\counter>cargo web start
error: you don't have Emscripten installed!

Download and install emscripten from the official site: http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html

(I have to use asmjs instead of wasm to support old browsers.)

EDIT: The hello.rs example worked in the emscripten sdk folder, but when I copy the hello.rs file to another folder and start a cmd.exe there and then run rustc --target asmjs-unknown-emscripten hello.rs I get note: 'emcc.bat' is not recognized as an internal or external command, operable program or batch file. even though I ran emsdk_env.bat in that shell, why?

@koute
Copy link
Owner

koute commented Jan 30, 2018

The emcc.bat needs to be in your PATH for it to work, so I guess you should check whenever it really is?

Also on a side note - I'd love to have precompiled Emscripten binaries for Windows too in cargo-web. If you (or someone else) would be interested in contributing something like that I'd be willing to help out. (Basically, we'd probably need a build script that would automatically build Emscripten on a fresh Windows 10 VM under something like Vagrant, and then perhaps a little bit of code for Windows-specific environmental setup in cargo-web itself.)

@Boscop
Copy link
Author

Boscop commented Jan 30, 2018

  1. It works when I also run emsdk activate latest, but shouldn't running emsdk_env.bat in a shell be enough?

  2. Any idea why this fails? asmjs build fails with NameError: name '_main' is not defined yewstack/yew#124

@koute
Copy link
Owner

koute commented Jan 30, 2018

  1. I have no idea. Does emsdk_env.bat set up the PATH properly?

  2. That's interesting; it looks like it thinks the main symbol is not defined for some reason...? Do cargo web build or cargo web test fail with the same error?

@Boscop
Copy link
Author

Boscop commented Jan 30, 2018

  1. It adds some emscripten paths to PATH but activate sets more..
  2. Yes, same error. Is it because the arg is passed without quotation marks?

ERROR:root:a problem occurred in evaluating content after a "-s", specifically EXPORTED_FUNCTIONS=[_main,_rust_eh_personality] . one possible cause of this is missing quotation marks (this depends on the shell you are running in; you may need quotation marks around the entire EXPORTED_FUNCTIONS=[_main,_rust_eh_personality] , or on an individual element)

@koute
Copy link
Owner

koute commented Jan 30, 2018

Hmm... can you try making a new crate with cargo new --bin foobar and then try to cargo web build it?

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

That one works! So why doesn't it work with the yew examples?

@koute
Copy link
Owner

koute commented Jan 31, 2018

Can you now try to add a Web.toml, add a prepend-js key (Look at cargo-web's README on how to do it.) and try to compile that?

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

I added the Web.toml file next to my Cargo.toml file:

prepend-js = "prepend.js"

and the js file:

console.log("prepend");

when I build it, it returns immediately (as if the source didn't change) and when I execute it with node target\asmjs-unknown-emscripten\debug\foobar.js it only outputs Hello world!, not prepend, why?

@koute
Copy link
Owner

koute commented Jan 31, 2018

Hmmm... that might be an issue with Rust not rebuilding the project when Emscripten flags change.

Anyhow, can you just delete the target directory and rebuild?

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

Ah yes, now it works!

prepend
Hello, world!

Now how does it bring us closer to a solution to the issue above?

@koute
Copy link
Owner

koute commented Jan 31, 2018

I wanted to see whenever prepend-js was the culprit or not (since the path to the specified .js file is passed to Emscripten through an environment variable.) But I guess I forgot that yew is using stdweb 0.3 which doesn't use prepend-js yet, sorry.

Hmm... I guess you could maybe try take the yew example which fails to compile and successively strip it down until it starts compiling?

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

Strip it down in what way? Where does the error even originate? Which part is passing those flags?

@koute
Copy link
Owner

koute commented Jan 31, 2018

Start removing things as long as it still exhibits the problem. For example, delete the example code and leave an empty crate, remove yew dependency and leave only stdweb, etc. Once we'll know what exactly makes it stop compiling we should be able to figure out how to fix it.

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

But who is the one calling emcc with "-s" "EXPORTED_FUNCTIONS=[\"_main\",\"_rust_eh_personality\"]"?

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

I remember I had a similar problem before where something (cargo or something else) wasn't putting quotation marks around the value of args..

Maybe it should be "-s" "EXPORTED_FUNCTIONS=\"['_main','_rust_eh_personality']\""?

@koute
Copy link
Owner

koute commented Jan 31, 2018

Rust is. But there must be some reason why it fails.

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

Is this related? emscripten-core/emscripten#4342

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

Which line of code in cargo web calls emcc with "-s" "EXPORTED_FUNCTIONS=[\"_main\",\"_rust_eh_personality\"]"?

@koute
Copy link
Owner

koute commented Jan 31, 2018

cargo-web doesn't set that. Either rustc or cargo does.

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

Thanks, after talking on IRC I found out the correct quotation syntax and opened an issue: rust-lang/rust#47909

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

But why does it work when I try to compile foobar (hello world) but not with that yew example?
Shouldn't rustc also call emcc the same way for foobar?

@koute
Copy link
Owner

koute commented Jan 31, 2018

Yes. That's why I suggested to try to cut down that example crate from yew so that we can maybe find out what triggers it and figure out why it happens.

@Boscop
Copy link
Author

Boscop commented Jan 31, 2018

Ok, and how can I print out how emcc is called when building foobar? I tried cargo web build -vvvv but it said only 1 verbosity level is allowed, why? With only one level, it doesn't print enough info..

@DJMcNab
Copy link

DJMcNab commented Apr 10, 2018

This issue occurs because when there are too many arguments, rustc and emcc use a response file to get around the windows command max length, and the parsing messes this up. Explained further: yewstack/yew#124 (comment).

But I'm not sure about the original error. I got that and had to restart to fix it.

kripken pushed a commit to emscripten-core/emscripten that referenced this issue Apr 30, 2018
Adds some custom parsing functions into emcc.py to replace evals.

Also ensures that --js-opts and --llvm-lto are integers

Additionally replaces eval in em-config

Closes #6069
Fixes #4342

Should Fix:

    yewstack/yew#124
    Part of koute/cargo-web#60
    rust-lang/rust#47909
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

3 participants