Skip to content

Conversation

@wweic
Copy link
Contributor

@wweic wweic commented Jan 8, 2016

This is a quick fix.

Maybe we should consider:

  • add help doc to -I option
  • add documentation on how to use the generated js to interoperate with other js code.

@bobzhang
Copy link
Member

bobzhang commented Jan 8, 2016

thanks, I am a bit interesting what is the error message when missing I ../stdlib, since I did follow it step by step, but did not find an error

@wweic
Copy link
Contributor Author

wweic commented Jan 9, 2016

This is a session in a new host:

➜  tmp git:(master) ✗ OCAML_RAW_JS=1 ocamlscript -I . -I ../ -c hello.ml
WARN: File "bin/compiler.ml", line 3386, characters 34-41 Pervasives.cmj not found
WARN: File "bin/compiler.ml", line 6870, characters 36-43 Pervasives.js not found in search path - while compiling hello.ml
➜  tmp git:(master) ✗ cat hello.js
// Generated CODE, PLEASE EDIT WITH CARE
"use strict";
var Pervasives = require("pervasives");

console.log("hello world");

/*  fail the pure module */
➜  tmp git:(master) ✗ node hello.js
module.js:340
    throw err;
    ^

Error: Cannot find module 'pervasives'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:289:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/home/wei/workspace/ocamlscript/jscomp/tmp/hello.js:3:18)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Function.Module.runMain (module.js:467:10)
➜  tmp git:(master) ✗ pwd
/home/wei/workspace/ocamlscript/jscomp/tmp

The root cause is because https://github.com/ocaml/ocaml/blob/trunk/utils/misc.ml#L115 does NOT do recursive directory find. -I will append the path to Config.load_path.

I suspect you might have some paths in your .ocamlinit file.

@bobzhang
Copy link
Member

bobzhang commented Jan 9, 2016

ah, it's because you didn't create tmp dir

@wweic
Copy link
Contributor Author

wweic commented Jan 9, 2016

I see. The commands all depend on previous commands' state. I have to be inside stdlib. thanks. Closing for now.

@wweic wweic closed this Jan 9, 2016
@wweic wweic deleted the fix-sample-command branch January 9, 2016 21:51
Mathspy pushed a commit to Mathspy/melange that referenced this pull request Mar 28, 2021
less generated dune files. requires 2.7
kevinbarabash pushed a commit to kevinbarabash/rescript-compiler that referenced this pull request Dec 24, 2021
Change poly variant `##` spread to `#...`
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

Successfully merging this pull request may close these issues.

2 participants