{{ message }}

# [fix] Issues related to OSInfo.bash_path()#3455

Merged
merged 2 commits into from Sep 3, 2018
Merged

# [fix] Issues related to OSInfo.bash_path()#3455

merged 2 commits into from Sep 3, 2018

## Conversation

### jgsogo commented Sep 1, 2018 • edited by lasote

 Fails when there is no windows_subsytem Changelog: Bugfix: Fixed OSInfo.bash_path() when there is no windows_subsystem. The text was updated successfully, but these errors were encountered:
 call the function! 
 edd6fc5 
assigned jgsogo Sep 1, 2018
added the stage: review label Sep 1, 2018

### jgsogo commented Sep 1, 2018

I need to fix also this test, but I need some advice about it...

Line 813 in 860fb81

 def run_in_bash_test(self):

It fails when there is no windows_subsystem because of these lines in run_in_windows_bash:

        bash_path = os_info.bash_path()  # <--- Returns None!!!
bash_path = '"%s"' % bash_path if " " in bash_path else bash_path

We can skip the test if not os_info.detect_windows_subsystem() or run these tests only if cygwin is present...

requested a review from memsharded Sep 1, 2018

### memsharded commented Sep 1, 2018

 What you spotted is indeed a bug in the test, good catch. The run_in_bash_test() bug, I am not sure, the test seems Mocked, so it shouldn't need a real subsystem to run, what am I missing? How does the test fail in your system?

### jgsogo commented Sep 1, 2018

 The two lines from function run_in_windows_bash that I copied from the function code:  bash_path = os_info.bash_path() # <--- Returns None!!! bash_path = '"%s"' % bash_path if " " in bash_path else bash_path  If there is no "bash" in the system, bash_path is None (see comment) and in the next line it is trying to iterate it: if " " in bash_path, so: ====================================================================== ERROR: run_in_bash_test (conans.test.util.tools_test.ToolsTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Javi\dev\conan\conans\test\util\tools_test.py", line 830, in run_in_bash_test tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin") File "C:\Javi\dev\conan\conans\client\tools\win.py", line 481, in run_in_windows_bash bash_path = '"%s"' % bash_path if " " in bash_path else bash_path TypeError: argument of type 'NoneType' is not iterable  To keep the test we need to mock the call to bash_path().

### memsharded commented Sep 2, 2018

 Yes, I think that mocking OSInfo.bash_path() could be the way to go, specially because in the test, we can see:  with tools.environment_append({"CONAN_BASH_PATH": "path\\to\\mybash.exe"}): tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin") self.assertIn('path\\to\\mybash.exe --login -c', conanfile._runner.command) Maybe it is good enough to set CONAN_BASH_PATH, instead of actually mocking.

added this to the 1.8 milestone Sep 2, 2018
 patch OSInfo.bash_path function call 
 b38179f 
merged commit 8c9ea8d into conan-io:develop Sep 3, 2018
2 checks passed
removed the stage: review label Sep 3, 2018
deleted the fix/tests/osinfo_bash_path branch Sep 19, 2018
pushed a commit to grisumbras/conan that referenced this issue Dec 27, 2018
 Merge pull request conan-io#3455 from jgsogo/fix/tests/osinfo_bash_path 
 f21e106 
[fix] Issues related to OSInfo.bash_path()