techpavan/mvn-repo-cleaner

Error on SH

Narimm opened this issue · 7 comments

total 3372
drwxrwxr-x  2 jenkins jenkins    4096 Sep  7 09:47 .
drwxr-xr-x 28 jenkins jenkins    4096 Sep  7 09:45 ..
-rwxr-xr-x  1 jenkins jenkins      51 Jan 21  2018 execute.sh
-rw-r--r--  1 jenkins jenkins 3432440 Jun  3 16:59 mvn-repo-cleaner.jar
-rw-r--r--  1 jenkins jenkins    2394 Jun  3 16:25 README.md
-rwxr-xr-x  1 jenkins jenkins      55 Jan 21  2018 simulate.sh
jenkins@fry:~/mavencleaner$ ./simulate.sh
**/usr/bin/env: ‘bash\r’: No such file or directory**

Ensured that the .sh files by themselves do not seem to have any issues. But the released zip file, when extracted seems to have a \r character which might be causing the issue. I believe it is because a Windows machine was used to run the build process.

As I try to fix the release, you can either run the command like sh simulate.sh or run the below command to fix the file itself.

dos2unix simulate.sh simulate.sh

Can this work on Windows at all? It's my understanding that the Windows filesystem does not track access time.

Hi, I am trying to run simulate.bat but it shows me following error:

C:\Users\Tural\Downloads\mvn-repo-cleaner\src\assembly\scripts>java -jar mvn-repo-cleaner.jar -dr
Error: Unable to access jarfile mvn-repo-cleaner.jar

Could you help please?

@atural91 Seems like you are trying to run from the cloned repository. This batch file was made to be run from the release package. Can you try executing with the release zip file?

https://github.com/techpavan/mvn-repo-cleaner/releases/latest

Great!! Thank you

jhult commented

I bumped into this on macOS (using the release zip).

This explains the issue and how to resolve: https://github.com/koalaman/shellcheck/wiki/SC1017

Carriage returns do not exist on code nor release artifact. Checked in both latest and pre-latest. Probably the issue occurred due to involvement of a Windows machine (or ASCII mode) while transferring files.