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

Provide alternative for $GITHUB_PATH inside MSYS2 with path-type: minimal #347

Open
takase1121 opened this issue Dec 25, 2023 · 9 comments

Comments

@takase1121
Copy link

I want to use path-type: minimal (the default), but I want to be able to add things to PATH like appending to $GITHUB_PATH does. I don't want to inherit $env:PATH entirely.

Currently, a workaround I use is to do echo 'export PATH=$PATH:/blabla' >> .bashrc, which I don't think is as elegant as the $GITHUB_PATH solution. I propose $MSYS2_PATH as the equivalent to $GITHUB_PATH in MSYS2.

@Biswa96
Copy link
Member

Biswa96 commented Dec 25, 2023

Currently, a workaround I use is to do echo 'export PATH=$PATH:/blabla' >> .bashrc

May I ask why you are using that workaround? Would not the export PATH=path/to/folder:$PATH command work?

@takase1121
Copy link
Author

I've not thought of that and I'm unsure if that would work. My rationale is that I would add my path directly to PATH by exporting it in .bashrc. I'm not sure if the changes are inherited in next steps (that's what I want).

@Biswa96
Copy link
Member

Biswa96 commented Dec 25, 2023

I'm not sure if the changes are inherited in next steps (that's what I want).

Yes, the changes are "inherited" in next steps if you are using shell: msys2 {0} option in actions yml file as documented here https://www.msys2.org/docs/ci/

@takase1121
Copy link
Author

That did not seem to work. Here is a snippet of what I am doing:

  build_windows_msys2:
    name: Windows
    runs-on: windows-2019
    strategy:
      matrix:
        config:
          - {msystem: MINGW32, arch: i686}
          - {msystem: MINGW64, arch: x86_64}
    defaults:
      run:
        shell: msys2 {0}
    steps:
    - uses: actions/checkout@v3

    - uses: msys2/setup-msys2@v2
      with:
        msystem: ${{ matrix.config.msystem }}
        release: false
        install: >-
          git
          zip
          wget
          curl
          mingw-w64-${{ matrix.config.arch }}-gcc
          mingw-w64-${{ matrix.config.arch }}-ntldd

    - name: Set Environment Variables
      run: |
        echo "INSTALL_REF=${GITHUB_REF##*/}" >> "$GITHUB_ENV"
        echo "INSTALL_NAME=lite-xl-${GITHUB_REF##*/}-windows-${{ matrix.config.arch }}" >> "$GITHUB_ENV"
        export PATH="$PATH:$HOME/.local/bin:$USERPROFILE/.local/bin:$(cygpath '${{ steps.git-path.outputs.path }}')"

    - uses: actions/setup-python@v4
      id: install-python
      with:
        python-version: '3.11'

    - name: Cache Poetry and other build tools
      id: build-tools
      uses: actions/cache@v3
      with:
        path: ~/.local
        key: build-tools-msys2-${{ runner.os }}-${{ steps.install-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

    - name: Install Poetry
      if: steps.build-tools.outputs.cache-hit != 'true'
      uses: snok/install-poetry@v1
    
    - name: Configure Poetry
      run: |
        echo "$PATH" # does not have %USERPROFILE%/.local/bin and ~/.local/bin
        poetry config virtualenvs.path "$(cygpath -w "$USERPROFILE/.local/virtualenvs")"

Hopefully this explains my intentions better.

@Biswa96
Copy link
Member

Biswa96 commented Dec 25, 2023

Now I wonder why poetry need additional directories in PATH environment variable. But that would be different topic. Please wait for other to comment on this issue.

@silverqx
Copy link

I have exactly the same problem, exporting the same path in every step isn't ideal, in every other shell env. I can add to GITHUB_PATH once and that's it, but on MSYS2 it doesn't work like that of course.

@silverqx
Copy link

Appending to .bashrc is a nice workaround for this problem, thx

@silverqx
Copy link

Also, would be nice to have eg. path parameter on msys2/setup-msys2 action and it should do this work for us behind the scene.

@ReenigneArcher
Copy link

+1 for adding a path input option to append or prefix the path. I'm trying to add only the system nodejs install directory, but not everything, as the npm version available from msys2 doesn't work with latest versions of vite.

I would think this would be rather easy to implement. Could add a new case here (https://github.com/msys2/MSYS2-packages/blob/99ac5123c37254e5e3fdda53663d8c09d30cf1cd/filesystem/profile#L28-L45) which is almost the same as the * case, but add the input path as well.

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

No branches or pull requests

4 participants