question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bash fails to find the temp script file on Windows when the WSL bash is used

See original GitHub issue

Runner Version and Platform

2.162.0

OS of the machine running the runner? OSX/Windows/Linux/… Windows 10

What’s not working?

Given this workflow:

jobs:
  run:
    runs-on:
      pool: Default
    steps:
    - name: Run a one-line script
      run: echo "Hello, world!" > foo.txt
      shell: bash

And given a runner on a Windows machine with C:\Windows\System32 higher in the PATH than C:\Program Files\Git\bin, the step will always fail:

2019-12-10T15:04:26.6972799Z ##[group]Run echo "Hello, world!" > foo.txt
2019-12-10T15:04:26.6973314Z echo "Hello, world!" > foo.txt
2019-12-10T15:04:26.7008574Z shell: C:\WINDOWS\system32\bash.EXE --noprofile --norc -e -o pipefail {0}
2019-12-10T15:04:26.7008971Z ##[endgroup]
2019-12-10T15:04:27.0006449Z /bin/bash: E:SourceGithubrunner_layout_work_temp4d150768-4ef5-4b8b-a310-3effbd9ac7aa.sh: No such file or directory
2019-12-10T15:04:27.0061661Z ##[error]Process completed with exit code 1.

It appears that the WSL bash is expecting a script file path to be Unix-like, e.g. /mnt/E/Source/Github/runner/_layout/....

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dakalecommented, Dec 10, 2019

Nice find

Yea, I think we could use the wslpath command to try to convert the path but it leaves the question open: When do we convert paths? It seems like the best estimate of when it will be required is if the shell is bash, and the resolved path to bash is C:\WINDOWS\system32\bash.EXE but Im hung on whether or not thats useful enough to add this specific behavior. But also Im wondering if this scenario will even work end to end in all cases, eg if your script has other file paths in, will those also need to be translated? Most scripts run this way would probably use relative paths which seem like they should work but will need a little more investigation

Ill try setting something up that uses:

shell: "C:\Windows\System32\bash.exe" -c "$(wslpath '%1')"

or maybe

shell: wsl -c "$(wslpath '%1')"

since wsl seems to be replacing bash

0reactions
TingluoHuangcommented, Jun 6, 2020

I don’t think WSL is our mainline scenario, I am going to close this issue for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running sh script with WSL returns "command not found"
To execute a file, either file needs to be in a directory in the search path (represented by the PATH environment variable) or...
Read more >
Troubleshooting Windows Subsystem for Linux
Provides detailed information about common errors and issues people run into while running Linux on the Windows Subsystem for Linux.
Read more >
Working across Windows and Linux file systems
Learn about the considerations and interop commands available when working across Windows and Linux file systems with WSL.
Read more >
Git-Bash and WSL have a different directory structure
Your Git-Bash is a typical Windows program, and functions as such. It sees C:\ as its root directory. Your WSL however, is different....
Read more >
Bash Scripting Tutorial – Linux Shell Script and Command ...
This involves creating a file containing a series of commands that can be executed together. In this article, we'll start with the basics...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found