Skip to content

Allow specifying executable in artifact section and skip bash from WSL - #1169

Merged
andrewnester merged 6 commits into
mainfrom
windows-wsl-bash
Feb 1, 2024
Merged

Allow specifying executable in artifact section and skip bash from WSL#1169
andrewnester merged 6 commits into
mainfrom
windows-wsl-bash

Conversation

@andrewnester

@andrewnesterandrewnester commented Feb 1, 2024

Copy link
Copy Markdown
Contributor

Changes

Allow specifying executable in artifact section

artifacts:
test:
type: whl
executable: bash
...

We also skip bash found on Windows if it's from WSL because it won't be correctly executed, see the issue above

Fixes#1159

@codecov-commenter

codecov-commenter commented Feb 1, 2024

Copy link
Copy Markdown

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (6beda44) 51.49% compared to head (37ad5c2) 51.45%.

FilesPatch %Lines
libs/exec/exec.go0.00%13 Missing ⚠️
bundle/config/artifact.go57.14%1 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #1169 +/- ##
==========================================
- Coverage 51.49% 51.45% -0.05% 
==========================================
Files 292 292 Lines 16333 16352 +19 ==========================================
+ Hits 8411 8414 +3 - Misses 7315 7329 +14 - Partials 607 609 +2 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@andrewnesterandrewnester changed the title Use CMD on Windows first as a shell to build artifactsAllow specifying executable in artifact sectionFeb 1, 2024

@pieternpietern left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the underlying issue in #1159?

Comment threadlibs/exec/exec.go Outdated
@andrewnester

Copy link
Copy Markdown
ContributorAuthor

@pietern it's essentially as described in the ticket, when running deploy from let's say CMD, if CLI finds bash installed as WSL it tries to use it to build wheels. To execute scripts we create temporary files, in the case described in the issue they will be created from CMD scope in Windows tmp path. But when path to this script passed to found bash it can't be accessed because WSL bash does not have access to Windows FS paths.

@andrewnester

Copy link
Copy Markdown
ContributorAuthor

With this change, it's possible to explicitly tell CLI to use CMD to avoid the issue described in the ticket

@pietern

Copy link
Copy Markdown
Contributor

Understood. Then this fix allows Windows users to override and use cmd by specifying it, but the default will still be broken, correct? Can't we detect if the bash we resolve is WSL bash and then fall through? I.e. it's fine to use bash, as long as the CLI is also being executed from WSL. If it still OK to run bash if it is Git Bash or MingW Bash.

@andrewnester

Copy link
Copy Markdown
ContributorAuthor

Can't we detect if the bash we resolve is WSL bash and then fall through?

I haven't found reliable way yet, but I don't think we should because the logic would become a bit too complex as we will need to fall through only if WSL bash is detected but CLI is running NOT in WSL bash

@pietern

Copy link
Copy Markdown
Contributor

I don't think it should be hard;

  • If we pick up Git or MINGW Bash, we can proceed as normal and use regular Windows paths
  • If we are running in WSL, we'll get Bash from /bin anyway, and the logic/behavior is no different from Linux
  • Therefore, as long as there is a predictable Windows-style path (or we use runtime.GOOS == "windows") that indicates we found the WSL trampoline, we can fall through and pick up cmd.

This also means the default templates work if WSL is installed. I suspect they don't right now because of this.

@pieternpietern left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please hint in the summary that we're now skipping WSL bash when running on Windows.

}

// Skipping WSL bash if found one
if strings.Contains(out, `\Windows\System32\bash.exe`) || strings.Contains(out, `\Microsoft\WindowsApps\bash.exe`) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: these can be suffix checks.

@andrewnesterandrewnester changed the title Allow specifying executable in artifact sectionAllow specifying executable in artifact section and skip bash from WSLFeb 1, 2024
@andrewnester
andrewnester added this pull request to the merge queueFeb 1, 2024
Merged via the queue into main with commit 0b3eeb8Feb 1, 2024
@andrewnester
andrewnester deleted the windows-wsl-bash branch February 1, 2024 14:16
andrewnester added a commit that referenced this pull request Feb 7, 2024
Bundles:
* Allow specifying executable in artifact section and skip bash from WSL ([#1169](#1169)).
* Added warning when trying to deploy bundle with `--fail-if-running` and running resources ([#1163](#1163)).
* Group bundle run flags by job and pipeline types ([#1174](#1174)).
* Make sure grouped flags are added to the command flag set ([#1180](#1180)).
* Add short_name helper function to bundle init templates ([#1167](#1167)).
Internal:
* Fix dynamic representation of zero values in maps and slices ([#1154](#1154)).
* Refactor library to artifact matching to not use pointers ([#1172](#1172)).
* Harden `dyn.Value` equality check ([#1173](#1173)).
* Ensure every variable reference is passed to lookup function ([#1176](#1176)).
* Empty struct should yield empty map in `convert.FromTyped` ([#1177](#1177)).
* Zero destination struct in `convert.ToTyped` ([#1178](#1178)).
* Fix integration test with invalid configuration ([#1182](#1182)).
* Use `acc.WorkspaceTest` helper from bundle integration tests ([#1181](#1181)).
@andrewnesterandrewnester mentioned this pull request Feb 7, 2024
github-merge-queueBot pushed a commit that referenced this pull request Feb 7, 2024
Bundles:
* Allow specifying executable in artifact section and skip bash from WSL
([#1169](#1169)).
* Added warning when trying to deploy bundle with `--fail-if-running`
and running resources
([#1163](#1163)).
* Group bundle run flags by job and pipeline types
([#1174](#1174)).
* Make sure grouped flags are added to the command flag set
([#1180](#1180)).
* Add short_name helper function to bundle init templates
([#1167](#1167)).
Internal:
* Fix dynamic representation of zero values in maps and slices
([#1154](#1154)).
* Refactor library to artifact matching to not use pointers
([#1172](#1172)).
* Harden `dyn.Value` equality check
([#1173](#1173)).
* Ensure every variable reference is passed to lookup function
([#1176](#1176)).
* Empty struct should yield empty map in `convert.FromTyped`
([#1177](#1177)).
* Zero destination struct in `convert.ToTyped`
([#1178](#1178)).
* Fix integration test with invalid configuration
([#1182](#1182)).
* Use `acc.WorkspaceTest` helper from bundle integration tests
([#1181](#1181)).
denik pushed a commit that referenced this pull request May 20, 2026
#1169)
## Changes
Allow specifying executable in artifact section
```
artifacts:
test:
type: whl
executable: bash
...
```
We also skip bash found on Windows if it's from WSL because it won't be
correctly executed, see the issue above
Fixes#1159
denik pushed a commit that referenced this pull request May 20, 2026
Bundles:
* Allow specifying executable in artifact section and skip bash from WSL
([#1169](#1169)).
* Added warning when trying to deploy bundle with `--fail-if-running`
and running resources
([#1163](#1163)).
* Group bundle run flags by job and pipeline types
([#1174](#1174)).
* Make sure grouped flags are added to the command flag set
([#1180](#1180)).
* Add short_name helper function to bundle init templates
([#1167](#1167)).
Internal:
* Fix dynamic representation of zero values in maps and slices
([#1154](#1154)).
* Refactor library to artifact matching to not use pointers
([#1172](#1172)).
* Harden `dyn.Value` equality check
([#1173](#1173)).
* Ensure every variable reference is passed to lookup function
([#1176](#1176)).
* Empty struct should yield empty map in `convert.FromTyped`
([#1177](#1177)).
* Zero destination struct in `convert.ToTyped`
([#1178](#1178)).
* Fix integration test with invalid configuration
([#1182](#1182)).
* Use `acc.WorkspaceTest` helper from bundle integration tests
([#1181](#1181)).
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI fails to deploy when building python wheels on Windows with WSL installed

3 participants

@andrewnester@codecov-commenter@pietern