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

Generator fails in bsb but succeeds when run manually #4369

Closed
jchavarri opened this issue May 10, 2020 · 1 comment
Closed

Generator fails in bsb but succeeds when run manually #4369

jchavarri opened this issue May 10, 2020 · 1 comment

Comments

@jchavarri
Copy link
Contributor

jchavarri commented May 10, 2020

I published a BuckleScript generator for atdgen with the intention to make it Windows compatible, so that Windows users in BuckleScript community can also have access to it.

But it seems that when running it, bsb (or ninja) has some issue with paths:

C:\Users\IEUser\Downloads\bs-atdgen-generator-master\test>yarn build
yarn run v1.19.2
$ bsb -make-world
bsb: no work to do.
bsb: no work to do.
[1/16] �[34mBuilding�[39m �[2mC:\Users\IEUser\Downloads\bs...ds\bs-atdgen-generator-master\test\src\atd\Foo_bs.mli�[22m
FAILED: C:/Users/IEUser/Downloads/bs-atdgen-generator-master/test/src/atd/Foo_bs.ml C:/Users/IEUser/Downloads/bs-atdgen-generator-master/test/src/atd/Foo_bs.mli
npx atdgen -bs C:\Users\IEUser\Downloads\bs-atdgen-generator-master\test\src\atd\Foo.atd
CreateProcess failed: The system cannot find the file specified.
[2/16] �[34mBuilding�[39m �[2mC:\Users\IEUser\Downloads\bs...ads\bs-atdgen-generator-master\test\src\atd\Foo_t.mli�[22m
FAILED: C:/Users/IEUser/Downloads/bs-atdgen-generator-master/test/src/atd/Foo_t.ml C:/Users/IEUser/Downloads/bs-atdgen-generator-master/test/src/atd/Foo_t.mli
npx atdgen -t C:\Users\IEUser\Downloads\bs-atdgen-generator-master\test\src\atd\Foo.atd
CreateProcess failed: The system cannot find the file specified.
FAILED: subcommand failed.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

When running the command manually npx atdgen -bs C:\Users\IEUser\Downloads\bs-atdgen-generator-master\test\src\atd\Foo.atd, it works.

From the error above, after the FAILED: string it can be seen how the path has unix slashes /, one hypothesis that fits the error is that the path expected in the resulting file is not adapted for Windows file system?

Example failing run from GH actions with the whole flow.

Version

7.3.2

Repro

git clone https://github.com/jchavarri/bs-atdgen-generator/
cd bs-atdgen-generator/test
npm install
npm build

build.ninja

g_pkg_flg = -bs-package-name bs-atdgen-generator-integration-test -bs-ns BsAtdgenGeneratorIntegrationTest
src_root_dir = C:\Users\IEUser\Downloads\bs-atdgen-generator-master\test
bsc = "C:\Users\IEUser\Downloads\bs-atdgen-generator-master\test\node_modules\bs-platform\win32\bsc.exe"
bsdep = "C:\Users\IEUser\Downloads\bs-atdgen-generator-master\test\node_modules\bs-platform\win32\bsb_helper.exe"
warnings =  -warn-error +101
bsc_flags = 
ppx_flags = 
g_dpkg_incls = 
g_ns = -bs-ns BsAtdgenGeneratorIntegrationTest
bsb_dir_group = 0
g_lib_incls = -I . -I src -I "src\atd" -I "C:\Users\IEUser\Downloads\bs-atdgen-generator-master\test\node_modules\@ahrefs\bs-atdgen-codec-runtime\lib\ocaml"
rule custom_atd_bs
  command = npx atdgen -bs $in
  description = �[34mBuilding�[39m �[2m${out}�[22m
build  $src_root_dir\src\atd\Foo_bs.ml $src_root_dir\src\atd\Foo_bs.mli : custom_atd_bs $src_root_dir\src\atd\Foo.atd
rule custom_atd_t
  command = npx atdgen -t $in
  description = �[34mBuilding�[39m �[2m${out}�[22m
build  $src_root_dir\src\atd\Foo_t.ml $src_root_dir\src\atd\Foo_t.mli : custom_atd_t $src_root_dir\src\atd\Foo.atd
rule build_ast
  command = $bsc  $warnings -color always $bsc_flags -o $out -bs-syntax-only -bs-binary-ast $in
  description = �[34mBuilding�[39m �[2m${out}�[22m
build  src\atd\Foo_t.mlast : build_ast $src_root_dir\src\atd\Foo_t.ml
rule build_deps
  command = $bsdep -hash 8c69b5c0dbf5425022677fda7f45e9ac $g_ns -g $bsb_dir_group $in
  restat = 1
  description = �[34mBuilding�[39m �[2m${out}�[22m
build  src\atd\Foo_t.d : build_deps src\atd\Foo_t.mlast src\atd\Foo_t.mliast
build  src\atd\Foo_t.mliast : build_ast $src_root_dir\src\atd\Foo_t.mli
rule ml_cmi
  command = $bsc $g_pkg_flg -color always -bs-suffix $g_lib_incls $warnings $bsc_flags -o $out $in
  dyndep = $in_e.d
  restat = 1
  description = �[34mBuilding�[39m �[2m${out}�[22m
build  src\atd\Foo_t-BsAtdgenGeneratorIntegrationTest.cmi : ml_cmi src\atd\Foo_t.mliast ||  src\atd\Foo_t.d
  g_pkg_flg = $g_pkg_flg  -bs-package-output commonjs:src\atd
rule ml_cmj_only
  command = $bsc $g_pkg_flg -color always -bs-suffix -bs-read-cmi $g_lib_incls $warnings $bsc_flags -o $out $in
  dyndep = $in_e.d
  restat = 1
  description = �[34mBuilding�[39m �[2m${out}�[22m
build  src\atd\Foo_t-BsAtdgenGeneratorIntegrationTest.cmj |  $src_root_dir\src\atd\Foo_t.bs.js : ml_cmj_only src\atd\Foo_t.mlast |  src\atd\Foo_t-BsAtdgenGeneratorIntegrationTest.cmi ||  src\atd\Foo_t.d
  g_pkg_flg = $g_pkg_flg  -bs-package-output commonjs:src\atd
build  src\atd\Foo_bs.mlast : build_ast $src_root_dir\src\atd\Foo_bs.ml
build  src\atd\Foo_bs.d : build_deps src\atd\Foo_bs.mlast src\atd\Foo_bs.mliast
build  src\atd\Foo_bs.mliast : build_ast $src_root_dir\src\atd\Foo_bs.mli
build  src\atd\Foo_bs-BsAtdgenGeneratorIntegrationTest.cmi : ml_cmi src\atd\Foo_bs.mliast ||  src\atd\Foo_bs.d
  g_pkg_flg = $g_pkg_flg  -bs-package-output commonjs:src\atd
build  src\atd\Foo_bs-BsAtdgenGeneratorIntegrationTest.cmj |  $src_root_dir\src\atd\Foo_bs.bs.js : ml_cmj_only src\atd\Foo_bs.mlast |  src\atd\Foo_bs-BsAtdgenGeneratorIntegrationTest.cmi ||  src\atd\Foo_bs.d
  g_pkg_flg = $g_pkg_flg  -bs-package-output commonjs:src\atd
build  src\Test.mlast : build_ast $src_root_dir\src\Test.ml
build  src\Test.d : build_deps src\Test.mlast
rule ml_cmj_cmi
  command = $bsc $g_pkg_flg -color always -bs-suffix $g_lib_incls $warnings $bsc_flags -o $out $in
  dyndep = $in_e.d
  restat = 1
  description = �[34mBuilding�[39m �[2m${out}�[22m
build  src\Test-BsAtdgenGeneratorIntegrationTest.cmj |  src\Test-BsAtdgenGeneratorIntegrationTest.cmi $src_root_dir\src\Test.bs.js : ml_cmj_cmi src\Test.mlast ||  src\Test.d
  g_pkg_flg = $g_pkg_flg  -bs-package-output commonjs:src
rule build_package
  command = $bsc -w -49 -color always -no-alias-deps  $in
  restat = 1
  description = �[34mBuilding�[39m �[2m${out}�[22m
build  BsAtdgenGeneratorIntegrationTest.cmi : build_package BsAtdgenGeneratorIntegrationTest.mlmap
@jchavarri
Copy link
Contributor Author

It seems this was an issue with the way ninja uses CreateProcess, which does some shenanigans with .exe extension. Using absolute paths to generator binary fixes it, see TheSpyder/rescript-atdgen-generator#3.

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

1 participant