1

I'm running the Ubuntu version of Windows Subsystem for Linux. In there I've set up a simple cmake project and created a script to save me from typing out

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ../../

every time I want to build. My CMakeLists.txt exists in two directories above (thus ../../). The build works fine if I type the command above manually OR run a powershell script with the exact same command and nothing else.

But running this bash script inside WSL

#!/bin/bash
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ../../

I receive the error " does not exist.source directory "/mnt/c/dev-files/C/Practice/.

It looks like the bash script messes up the error output of cmake, so I'm guessing the script is executing cmake or passing the arguments incorrectly but I have no idea why.

  • Did you create the script using a Windows editor? does it have DOS-style (CRLF) line endings by any chance? – steeldriver Jul 31 '19 at 14:48
  • @steeldriver I did edit the script a few times with vscode while executing it through the vscode terminal. – winidis Jul 31 '19 at 15:38
  • How exactly do you execute the script? Where it is located? – pa4080 Jul 31 '19 at 15:49
  • @pa4080 The script is located in "/mnt/c/dev-files/C/Practice/debug/linux" and it can only be executed in that directory. No sym links or and not available through PATH. – winidis Jul 31 '19 at 15:59
  • Probably, as workaround, you can try to cd ../../ first and then execute the cmeake command with the current directory as argument. – pa4080 Jul 31 '19 at 16:12
1

When trying out other commands i noticed that some the other command arguments had the \r in line endings pointed out by errors.

The issue was that the script had windows line endings, as steeldriver commented in the question.

It was en easy fix with the dos2unix command, ex:

dos2unix script.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.