Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using TART_EXECUTOR_SHELL does not initialize the environment #45

Closed
umlaeute opened this issue Nov 29, 2023 · 3 comments · Fixed by #46
Closed

using TART_EXECUTOR_SHELL does not initialize the environment #45

umlaeute opened this issue Nov 29, 2023 · 3 comments · Fixed by #46

Comments

@umlaeute
Copy link

umlaeute commented Nov 29, 2023

we are using tart for running gitlab-ci pipelines (great project btw, it's really the thing i've been looking for)

now, a couple of our pipelines have code like this:

FLAGS="--foo --bar"
./somecmd ${FLAGS}

under bash (which used to be the default shell for all our cross-platform pipelines until now) this will run ./somecmd --foo --bar.

however, the tart executor defaults to using zsh, which does not do word-splitting for non-quoted variables, and the command excuted is effectively ./somecmd "--foo --bar", which of course is something completely different.

now seeing that there is a TART_EXECUTOR_SHELL variable that i can set to bash, i figured that this would solve my problems...
only to discover, that the bash-environment significantly differs from the default environment.

for me the difference is most prominently the lack of the brew, which stems from paths not being initialized.

so here's a test-pipeline to examine the current behaviour

sonoma:
  tags:
    - tart
  image: ghcr.io/cirruslabs/macos-sonoma-xcode:latest
  script:
    - echo $PATH
    - which brew

sonoma-matrix:
  extends: sonoma
  parallel:
    matrix:
      - TART_EXECUTOR_SHELL:
        - bash
        - zsh

which gives me one successful job (where TART_EXECUTOR_SHELL is unset) and two failing ones (where it is set):

TART_EXECUTOR_SHELL brew available? $PATH
-- 🎉 /Users/admin/flutter:/Users/admin/flutter/bin/:/Users/admin/flutter/bin/cache/dart-sdk/bin:/usr/local/bin/:/Users/admin/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/admin/android-sdk/cmdline-tools/latest/bin:/Users/admin/android-sdk/platform-tools:/Users/admin/android-sdk/emulator
bash 💥 /usr/bin:/bin:/usr/sbin:/sbin
zsh 💥 /usr/bin:/bin:/usr/sbin:/sbin

is this expected behaviour?

@umlaeute
Copy link
Author

just for completeness sake: the original problem i'was trying to solve with using TART_EXECUTOR_SHELL (that zsh does not do word-splitting on unquoted variables), can be worked around by adding something like this to the pipeline:

set -o shwordsplit || true

but it nevertheless seems that the TART_EXECUTOR_SHELL's usefulness is severely lessened if many tools cannot be used when it is set.

@edigaryev
Copy link
Contributor

edigaryev commented Nov 29, 2023

I think this can be accomplished by simply starting a login shell (the one that reads .profile and other files).

For example, if you need Bash, use TART_EXECUTOR_SHELL="bash -l".

I've created #46 to better document this.

@umlaeute
Copy link
Author

indeed that seems to do the trick.

i didn't check the code, so I assumed that TART_EXECUTOR_SHELL could have exactly three values (bash, zsh and none), rather than some arbitrary value.

thanks for the documentation update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants