blt / port_compiler

A rebar3 port compiler
MIT License
65 stars 38 forks source link

space in working path for deps #51

Closed c-bik closed 4 years ago

c-bik commented 6 years ago

If dependencies use port_compiler and the project root contains spaces (and/or special characters like )) in path, port_compiler is unable to see the source files. The reason seems to be that it is introducing extra escapes in path string. As shown with pc_test demo project below:

...
===> Compiling erlscrypt
===> Provider: {pc,compile}
===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt", pre_hooks, {pc, compile}) -> no hooks defined

===> Found no source files for:
"c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/scrypt_port.cpp"
===> Found no source files for:
"c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/scrypt.cpp"
===> Found no source files for:
"c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/sha256.cpp"
===> Found no source files for:
"c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/scrypt_nif.cpp"
===> Found no source files for:
"c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/scrypt.cpp"
===> Found no source files for:
"c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/sha256.cpp"
...
Full Compile Logs with rebar3 DEBUG enabled ```cmd C:\projects\git\c-bik\folder with space and ( special chars )\pc_test>rebar3 compile ===> Fetching pc ({git,"https://github.com/blt/port_compiler",{branch,master}}) ===> sh info: cwd: "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test" cmd: git --version ===> opts: [] ===> Port Cmd: cmd /q /c git --version Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof] ===> sh info: cwd: "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test" cmd: git clone https://github.com/blt/port_compiler .tmp_dir483529917677 -b master --single-branch ===> opts: [{cd,"./tmp"}] ===> Port Cmd: cmd /q /c git clone https://github.com/blt/port_compiler .tmp_dir483529917677 -b master --single-branch Port Opts: [{cd,"./tmp"}, exit_status, {line,16384}, use_stdio,stderr_to_stdout,hide,eof] ===> sh info: cwd: "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test" cmd: rd /q /s "c:\\projects\\git\\c-bik\\folder with space and ( special chars )\\pc_test\\_build\\default\\plugins\\pc" ===> opts: [{use_stdout,false},return_on_error] ===> Port Cmd: cmd /q /c rd /q /s "c:\\projects\\git\\c-bik\\folder with space and ( special chars )\\pc_test\\_build\\default\\plugins\\pc" Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof] ===> Moving checkout "./tmp/.tmp_dir483529917677" to "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc" ===> sh info: cwd: "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test" cmd: robocopy /move /e ".\\tmp\\.tmp_dir483529917677" "c:\\projects\\git\\c-bik\\folder with space and ( special chars )\\pc_test\\_build\\default\\plugins\\pc" ===> opts: [{use_stdout,false},return_on_error] ===> Port Cmd: cmd /q /c robocopy /move /e ".\\tmp\\.tmp_dir483529917677" "c:\\projects\\git\\c-bik\\folder with space and ( special chars )\\pc_test\\_build\\default\\plugins\\pc" Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof] ===> Compiling pc ===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc", pre_hooks, compile) -> no hooks defined ===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc", pre_hooks, erlc_compile) -> no hooks defined ===> erlopts [debug_info,inline_list_funcs,warn_deprecated_function, warn_export_all,warn_export_vars,warn_obsolete_guard, warn_shadow_vars,warn_untyped_record,warn_unused_function, warn_unused_import,warnings_as_errors] ===> files to compile ["c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc/src/pc_util.erl", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc/src/pc_prv_compile.erl", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc/src/pc_prv_clean.erl", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc/src/pc_port_specs.erl", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc/src/pc_port_env.erl", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc/src/pc_compilation.erl", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc/src/pc.erl"] ===> Compiled pc_util.erl ===> Compiled pc_prv_compile.erl ===> Compiled pc_prv_clean.erl ===> Compiled pc_port_specs.erl ===> Compiled pc_port_env.erl ===> Compiled pc_compilation.erl ===> Compiled pc.erl ===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc", post_hooks, erlc_compile) -> no hooks defined ===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc", pre_hooks, app_compile) -> no hooks defined ===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc", post_hooks, app_compile) -> no hooks defined ===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins/pc", post_hooks, compile) -> no hooks defined ===> Expanded command sequence to be run: [{default,app_discovery}, {default,install_deps}, {default,lock}, {default,compile}] ===> Provider: {default,app_discovery} ===> Not adding provider pc compile from module pc_prv_compile because it already exists from module pc_prv_compile ===> Not adding provider pc clean from module pc_prv_clean because it already exists from module pc_prv_clean ===> Not adding provider pc compile from module pc_prv_compile because it already exists from module pc_prv_compile ===> Not adding provider pc clean from module pc_prv_clean because it already exists from module pc_prv_clean ===> Provider: {default,install_deps} ===> Verifying dependencies... ===> Fetching erlscrypt ({git,"https://github.com/K2InformaticsGmbH/erlscrypt.git", {ref,"f8039eba30c17075b0277343c84f6a1f06349671"}}) ===> sh info: cwd: "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test" cmd: git clone -n https://github.com/K2InformaticsGmbH/erlscrypt.git .tmp_dir124982016233 ===> opts: [{cd,"./tmp"}] ===> Port Cmd: cmd /q /c git clone -n https://github.com/K2InformaticsGmbH/erlscrypt.git .tmp_dir124982016233 Port Opts: [{cd,"./tmp"}, exit_status, {line,16384}, use_stdio,stderr_to_stdout,hide,eof] ===> sh info: cwd: "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test" cmd: git checkout -q f8039eba30c17075b0277343c84f6a1f06349671 ===> opts: [{cd,"./tmp/.tmp_dir124982016233"}] ===> Port Cmd: cmd /q /c git checkout -q f8039eba30c17075b0277343c84f6a1f06349671 Port Opts: [{cd,"./tmp/.tmp_dir124982016233"}, exit_status, {line,16384}, use_stdio,stderr_to_stdout,hide,eof] ===> sh info: cwd: "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test" cmd: rd /q /s "c:\\projects\\git\\c-bik\\folder with space and ( special chars )\\pc_test\\_build\\default\\lib\\erlscrypt" ===> opts: [{use_stdout,false},return_on_error] ===> Port Cmd: cmd /q /c rd /q /s "c:\\projects\\git\\c-bik\\folder with space and ( special chars )\\pc_test\\_build\\default\\lib\\erlscrypt" Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof] ===> Moving checkout "./tmp/.tmp_dir124982016233" to "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt" ===> sh info: cwd: "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test" cmd: robocopy /move /e ".\\tmp\\.tmp_dir124982016233" "c:\\projects\\git\\c-bik\\folder with space and ( special chars )\\pc_test\\_build\\default\\lib\\erlscrypt" ===> opts: [{use_stdout,false},return_on_error] ===> Port Cmd: cmd /q /c robocopy /move /e ".\\tmp\\.tmp_dir124982016233" "c:\\projects\\git\\c-bik\\folder with space and ( special chars )\\pc_test\\_build\\default\\lib\\erlscrypt" Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof] ===> Not adding provider pc compile from module pc_prv_compile because it already exists from module pc_prv_compile ===> Not adding provider pc clean from module pc_prv_clean because it already exists from module pc_prv_clean ===> Provider: {default,lock} ===> sh info: cwd: "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test" cmd: git --git-dir="c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt/.git" --work-tree="c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt" rev-parse --verify HEAD ===> opts: [{use_stdout,false}, {debug_abort_on_error,"Locking of git dependency failed in c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt"}] ===> Port Cmd: cmd /q /c git --git-dir="c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt/.git" --work-tree="c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt" rev-parse --verify HEAD Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof] ===> Provider: {default,compile} ===> Compiling erlscrypt ===> Provider: {pc,compile} ===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt", pre_hooks, {pc, compile}) -> no hooks defined ===> Found no source files for: "c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/scrypt_port.cpp" ===> Found no source files for: "c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/scrypt.cpp" ===> Found no source files for: "c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/sha256.cpp" ===> Found no source files for: "c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/scrypt_nif.cpp" ===> Found no source files for: "c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/scrypt.cpp" ===> Found no source files for: "c:/projects/git/c-bik/folder\\ with\\ space\\ and\\ \\(\\ special\\ chars\\ \\)/pc_test/_build/default/lib/erlscrypt/c_src/sha256.cpp" ===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt", pre_hooks, compile) -> no hooks defined ===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt", pre_hooks, erlc_compile) -> no hooks defined ===> erlopts [debug_info] ===> files to compile ["c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt/src/scrypt_port.erl", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt/src/scrypt_nif.erl", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt/src/erlscrypt.erl"] ===> Compiled scrypt_port.erl ===> Compiled scrypt_nif.erl ===> Compiled erlscrypt.erl ===> run_hooks("c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt", pre_hooks, app_compile) -> no hooks defined ===> sh info: cwd: "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test" cmd: del /F /Q c_src\*.o c_src\*.d priv\*.exp priv\*.lib ===> opts: [use_stdout, {cd,"c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt"}, {env,[{"REBAR_DEPS_DIR", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib"}, {"REBAR_BUILD_DIR", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default"}, {"REBAR_ROOT_DIR", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/."}, {"REBAR_CHECKOUTS_DIR", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_checkouts"}, {"REBAR_PLUGINS_DIR", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins"}, {"REBAR_GLOBAL_CONFIG_DIR", "c:/Users/Bikram/.config/rebar3"}, {"REBAR_GLOBAL_CACHE_DIR", "c:/Users/Bikram/.cache/rebar3"}, {"REBAR_TEMPLATE_DIR", "c:/Users/Bikram/.config/rebar3/templates"}, {"REBAR_APP_DIRS", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/apps/*:c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/*:c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/."}, {"REBAR_SRC_DIRS",[]}, {"ERLANG_ERTS_VER","9.2"}, {"ERLANG_ROOT_DIR","c:/Program Files/erlang/erl9.2"}, {"ERLANG_LIB_DIR_erl_interface", "c:/Program Files/erlang/erl9.2/lib/erl_interface-3.10.1"}, {"ERLANG_LIB_VER_erl_interface","3.10.1"}, {"ERL","c:/Program Files/erlang/erl9.2/bin/erl"}, {"ERLC","c:/Program Files/erlang/erl9.2/bin/erlc"}, {"ERLANG_ARCH","64"}, {"ERLANG_TARGET","20.2-win32-64"}]}, {abort_on_error,"Hook for compile failed!\n"}] ===> Port Cmd: cmd /q /c del /F /Q c_src\*.o c_src\*.d priv\*.exp priv\*.lib Port Opts: [{cd,"c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/erlscrypt"}, {env,[{"REBAR_DEPS_DIR", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib"}, {"REBAR_BUILD_DIR", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default"}, {"REBAR_ROOT_DIR", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/."}, {"REBAR_CHECKOUTS_DIR", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_checkouts"}, {"REBAR_PLUGINS_DIR", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/plugins"}, {"REBAR_GLOBAL_CONFIG_DIR","c:/Users/Bikram/.config/rebar3"}, {"REBAR_GLOBAL_CACHE_DIR","c:/Users/Bikram/.cache/rebar3"}, {"REBAR_TEMPLATE_DIR", "c:/Users/Bikram/.config/rebar3/templates"}, {"REBAR_APP_DIRS", "c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/apps/*:c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/lib/*:c:/projects/git/c-bik/folder with space and ( special chars )/pc_test/_build/default/."}, {"REBAR_SRC_DIRS",[]}, {"ERLANG_ERTS_VER","9.2"}, {"ERLANG_ROOT_DIR","c:/Program Files/erlang/erl9.2"}, {"ERLANG_LIB_DIR_erl_interface", "c:/Program Files/erlang/erl9.2/lib/erl_interface-3.10.1"}, {"ERLANG_LIB_VER_erl_interface","3.10.1"}, {"ERL","c:/Program Files/erlang/erl9.2/bin/erl"}, {"ERLC","c:/Program Files/erlang/erl9.2/bin/erlc"}, {"ERLANG_ARCH","64"}, {"ERLANG_TARGET","20.2-win32-64"}]}, exit_status, {line,16384}, use_stdio,stderr_to_stdout,hide,eof] The system cannot find the file specified. ===> Hook for compile failed! C:\projects\git\c-bik\folder with space and ( special chars )\pc_test> ```

This issue was already discussed and closed as resolved but the problems still exists (at least reproduced in Windows).

See also https://github.com/blt/port_compiler/issues/21#issuecomment-318011321 from @acautin