Conan: run_in_windows_bash does not escape bash path

Created on 9 Jan 2018  路  13Comments  路  Source: conan-io/conan

Tool: conan 1.0.0b5.
Where: Appveyor CI job

Profile:

include(default)
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.exception=seh
compiler.libcxx=libstdc++
compiler.threads=posix
compiler.version=4.9
[options]
libjpeg-turbo:shared=True
[env]
[build_requires]
*:mingw_installer/1.0@conan/stable

Conanfile from the commit https://github.com/bincrafters/conan-libjpeg-turbo/commit/762a2f1f97c9476a85a01bc563c9ea3cb6c34463

Check the error output: https://ci.appveyor.com/project/BinCrafters/conan-libjpeg-turbo/build/job/2glrxw48a3e25h86
Excerpt:

libjpeg-turbo/1.5.2@bincrafters/testing: Calling build()
libjpeg-turbo/1.5.2@bincrafters/testing: run_in_windows_bash: C:\Program Files\Git\usr\bin\bash.exe --login -c ^"cd \^"/c/users/appveyor/.conan/data/libjpeg-turbo/1.5.2/bincrafters/testing/build/7c9ef433461cef2d9b13c9b7adecf55b65d32d05/sources\^" ^&^& PATH=\^"/c/users/appveyor/.conan/data/mingw_installer/1.0/conan/stable/package/5320696b2bd3aa9608353ee93d9dcc782987250b/bin:/c/users/appveyor/.conan/data/nasm/2.13.01/conan/stable/package/456f15897172eef340fcbac8a70811f2beb26a93/nasm-2.13.01:$PATH\^" ^&^& ./configure --prefix=/c/users/appveyor/.conan/data/libjpeg-turbo/1.5.2/bincrafters/testing/build/7c9ef433461cef2d9b13c9b7adecf55b65d32d05/libjpeg-turbo-install --disable-static --enable-shared  ^"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
libjpeg-turbo/1.5.2@bincrafters/testing: 
libjpeg-turbo/1.5.2@bincrafters/testing: ERROR: Package '7c9ef433461cef2d9b13c9b7adecf55b65d32d05' build failed
libjpeg-turbo/1.5.2@bincrafters/testing: WARN: Build folder C:\Users\appveyor\.conan\data\libjpeg-turbo\1.5.2\bincrafters\testing\build\7c9ef433461cef2d9b13c9b7adecf55b65d32d05
ERROR: libjpeg-turbo/1.5.2@bincrafters/testing: Error in build() method, line 80
    self.build_configure()
while calling 'build_configure', line 64
    env_build.configure(args=args)
    ConanException: Error 1 while executing C:\Program Files\Git\usr\bin\bash.exe --login -c ^"cd \^"/c/users/appveyor/.conan/data/libjpeg-turbo/1.5.2/bincrafters/testing/build/7c9ef433461cef2d9b13c9b7adecf55b65d32d05/sources\^" ^&^& PATH=\^"/c/users/appveyor/.conan/data/mingw_installer/1.0/conan/stable/package/5320696b2bd3aa9608353ee93d9dcc782987250b/bin:/c/users/appveyor/.conan/data/nasm/2.13.01/conan/stable/package/456f15897172eef340fcbac8a70811f2beb26a93/nasm-2.13.01:$PATH\^" ^&^& ./configure --prefix=/c/users/appveyor/.conan/data/libjpeg-turbo/1.5.2/bincrafters/testing/build/7c9ef433461cef2d9b13c9b7adecf55b65d32d05/libjpeg-turbo-install --disable-static --enable-shared  ^"

Seems like conan detects bash from git and does not properly escape the path. Double quotes are enough.

To help us debug your issue please explain:

  • [x] I've read the CONTRIBUTING guide.
  • [x] I've specified the Conan version, operating system version and any tool that can be relevant.
  • [x] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.
bug

All 13 comments

Hi

I seem to have a problem with the above patch on my machine.

Tested this with conan 1.0.0b5 and 1.0.0.

I use a bash.exe provided by git, installed in C:\Tools\Git.

Trying to execute the following command:
tools.run_in_windows_bash(self, "./genMakefiles mingw")

In conan 1.0.0b5 I get:

live555/2017.09.12@lba/testing: run_in_windows_bash: C:\Tools\Git\bin\bash.exe --login -c ^"cd \^"/c/users/lba/.conan/data/live555/2017.09.12/lba/testing/build/7818d4a4fb0bdf3916b923b7a45639892047044a/live555\^" ^&^& ./genMakefiles mingw ^"

I conan 1.0.0 I get:

live555/2017.09.12@lba/testing: run_in_windows_bash: "C:\Tools\Git\bin\bash.exe" --login -c ^"cd \^"/c/users/lba/.conan/data/live555/2017.09.12/lba/testing/build/7818d4a4fb0bdf3916b923b7a45639892047044a/live555\^" ^&^& ./genMakefiles mingw^"
'C:\Tools\Git\bin\bash.exe" --login -c ^"cd' is not recognized as an internal or external command, operable program or batch file.

Notice the missing double quote (") in the beginning of the command in the error message before C:\Tools. Perhaps the quotes around the bash executable should be escaped like the other quotes in the command (^")?

Regards
Lau Bakman

Hi @lbakman, thanks for reporting. I'm checking.

@lbakman could you try using pip install conan==1.0.1rc1 and post the results?
Thanks!

I get the following result:

live555/2017.09.12@lba/testing: run_in_windows_bash: ""C:\Tools\Git\bin\bash.exe" --login -c ^"cd \^"/c/users/lba/.conan/data/live555/2017.09.12/lba/testing/build/7818d4a4fb0bdf3916b923b7a45639892047044a/live555\^" ^&^& ./genMakefiles mingw ^""

, no errors and the project compiles normally.

Thank you!

Good to know that it works, but I think the fix could still break when uses bash from msys2, cygwin etc. I have to look at it carefully. We are releasing 1.0.1 without this patch with some urgent stuff and I hope to have it ready and fixed for a following 1.0.2 or 1.1.0 (probably 1.0.2) Thanks for reporting and your patience.

No worries, keep up the good work!

Regards
Lau Bakman

This bug also affects the official tutorial in http://docs.conan.io/en/latest/getting_started.html when someone tries to build the first example in Msys2:

$ conan install .. --build missing
(...content cut by me...)
OpenSSL/1.0.2l@conan/stable: run_in_windows_bash: "D:/app/msys64/usr/bin/bash.exe" --login -c ^"cd \^"/c/users/fazer/.conan/data/openssl/1.0.2l/conan/stable/build/63307e240b41ef8839dcfb74542a850772ef7dc9/openssl-1.0.2l\^" ^&^& ./Configure mingw64  --with-zlib-include=\^"/c/users/fazer/.conan/data/zlib/1.2.11/conan/stable/package/42951bc9791ea38175dc6d678bd77956f88c4796/include\^" --with-zlib-lib=\^"/c/users/fazer/.conan/data/zlib/1.2.11/conan/stable/package/42951bc9791ea38175dc6d678bd77956f88c4796/lib/zlib.lib\^" ^"
'D:/app/msys64/usr/bin/bash.exe" --login -c ^"cd' is not recognized as an internal or external command,
operable program or batch file.
OpenSSL/1.0.2l@conan/stable:
OpenSSL/1.0.2l@conan/stable: ERROR: Package '63307e240b41ef8839dcfb74542a850772ef7dc9' build failed
OpenSSL/1.0.2l@conan/stable: WARN: Build folder C:/Users/Fazer/.conan/data/OpenSSL/1.0.2l/conan/stable/build/63307e240b41ef8839dcfb74542a850772ef7dc9
ERROR: OpenSSL/1.0.2l@conan/stable: Error in build() method, line 109
        self.mingw_build(config_options_string)
while calling 'mingw_build', line 318
        tools.run_in_windows_bash(self, config_line)
        ConanException: Error 1 while executing "D:/app/msys64/usr/bin/bash.exe" --login -c ^"cd \^"/c/users/fazer/.conan/data/openssl/1.0.2l/conan/stable/build/63307e240b41ef8839dcfb74542a850772ef7dc9/openssl-1.0.2l\^" ^&^& ./Configure mingw64  --with-zlib-include=\^"/c/users/fazer/.conan/data/zlib/1.2.11/conan/stable/package/42951bc9791ea38175dc6d678bd77956f88c4796/include\^" --with-zlib-lib=\^"/c/users/fazer/.conan/data/zlib/1.2.11/conan/stable/package/42951bc9791ea38175dc6d678bd77956f88c4796/lib/zlib.lib\^" ^"

Environment:
Conan 1.0.1 from pip3 from Msys2
CMake 3.10.1 x64 from Msys2
Msys2 MinGW x64
Windows 10 x64

Hi! @lbakman @ArekPiekarz could you try with pip install conan==1.0.2rc1?
I think I found a more solid solution to this problem but I would like to have your feedback to validate it. Thanks both!

In conan 1.0.2r1 I get the following error:

live555/2017.09.12@lba/testing: Calling build()
live555/2017.09.12@lba/testing: run_in_windows_bash: "C:\Tools\Git\bin\bash.exe" --login -c ^"cd \^"/c/users/lba/.conan/
data/live555/2017.09.12/lba/testing/build/7818d4a4fb0bdf3916b923b7a45639892047044a/live555\^" ^&^& ./genMakefiles mingw^"
'C:\Tools\Git\bin\bash.exe" --login -c ^"cd' is not recognized as an internal or external command,
operable program or batch file.
live555/2017.09.12@lba/testing:
live555/2017.09.12@lba/testing: ERROR: Package '7818d4a4fb0bdf3916b923b7a45639892047044a' build failed
live555/2017.09.12@lba/testing: WARN: Build folder C:\Users\lba\.conan\data\live555\2017.09.12\lba\testing\build\7818d4a
4fb0bdf3916b923b7a45639892047044a
ERROR: live555/2017.09.12@lba/testing: Error in build() method, line 53
        self.build_with_make()
while calling 'build_with_make', line 106
        self._run_cmd("./genMakefiles %s" % target)
while calling '_run_cmd', line 74
        tools.run_in_windows_bash(self, command)
        ConanException: Error 1 while executing "C:\Tools\Git\bin\bash.exe" --login -c ^"cd \^"/c/users/lba/.conan/data/
live555/2017.09.12/lba/testing/build/7818d4a4fb0bdf3916b923b7a45639892047044a/live555\^" ^&^& ./genMakefiles mingw ^"

For what it is worth, I am running bash 4.4.12 on Windows:

GNU bash, version 4.4.12(1)-release (x86_64-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Regards
Lau Bakman

Could you try with conan==1.0.2rc2? Thanks.

Conan 1.02rc2 works for me.

I can also confirm 1.0.2rc2 fixes the problem on Msys2. The tutorial still cannot be built there, but that is a different issue, which I'll try to report separately.

Edit: And done - https://github.com/conan-io/conan/issues/2317

Released to 1.0.2, please upgrade. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mpdelbuono picture mpdelbuono  路  3Comments

kwint picture kwint  路  3Comments

uilianries picture uilianries  路  3Comments

niosHD picture niosHD  路  3Comments

tonka3000 picture tonka3000  路  3Comments