Search code examples
androidkotlinprocessbuilder

Android Process Builder suddenly says file not found


I start a shell script using process builder. This has been working fine for days now but today, when I uploaded my files to bitbucket and messed around with them, everything seems to work again except that the ProcessBuilder which can't find the file which is already there:

val processBuilder = ProcessBuilder().command(
                    filesDir.absolutePath + File.separator + "start.sh").start()

The start.sh script is already in the app's files directory but I'm receiving:

 java.io.IOException: Cannot run program "/data/user/0/com.example.project/files/start.sh": error=2, No such file or directory

I've tried to run it like this:

   val processBuilder = ProcessBuilder().command("start.sh", filesDir.absolutePath + File.separator).start()

and then I'm receiving access denied although all files have chmod 777 and this file has even a+rx flags.


Solution

  • Well this will not likely help anyone but here is what happened:

    I tried to put my code on bitbucket and in the process, I managed to delete everything from my local folder. Luckily my code was still on Bitbucket so I just downloaded a tar file with it and started from scratch. On my second attempt, I managed to do everything correctly but I used the downloaded sources from Bitbucket. Everything was fine except that apparently, when I imported the project directly from Bitbucket, the EOL sequence of the synced/downloaded shell script file changed to CRLF instead of LF... I resaved the file with LF and the problem was solved afterwards.