volta-cli / action

GitHub Action to Setup Volta
https://volta.sh
MIT License
93 stars 23 forks source link

Failure in Github workflows on ec2-runners #141

Open AndesKrrrrrrrrrrr opened 10 months ago

AndesKrrrrrrrrrrr commented 10 months ago

I'm using this action in my CI, but getting errors regarding my profile/bashrc.

executing `/__w/_tool/volta/1.1.1/x64/bin/volta setup`
/__w/_tool/volta/1.1.1/x64/bin/volta setup
error: Could not locate user profile.
Tried $PROFILE (), ~/.bashrc, ~/.bash_profile, ~/.zshrc, ~/.profile, and ~/.config/fish/config.fish

Please create one of these and try again; or you can edit your profile manually to add '/__w/_tool/volta/1.1.1/x64/bin' to your PATH
Error: The process '/__w/_tool/volta/1.1.1/x64/bin/volta' failed with exit code 6

Minimum Working Example

name: Minimum Working Example
on:
  push:
defaults:
  run:
    shell: bash
jobs:
  success-ubuntu:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Volta-cli
        uses: volta-cli/action@v4
  fail-ec2:
    runs-on: ec2-runners
    container:
      image: ${{ vars.EC2_RUNNER }}
    steps:
      - uses: actions/checkout@v3
      - name: Setup Volta-cli
        uses: volta-cli/action@v4
rwjblue commented 10 months ago

I'm not familiar with ec2-runners here, is that something you've setup in your organization?

rwjblue commented 10 months ago

This might ultimately be something we need to tweak in Volta itself. As long as someone makes sure that $PATH is updated we don't really care if we could edit your profile (bash/fish/zsh/etc).

We might be able to add a flag to volta setup for that, but we'd need to consider the pros/cons specifically.

rwjblue commented 10 months ago

Hmm. We might be able to avoid this error in the action itself if we setup VOLTA_HOME on $PATH first:

https://github.com/volta-cli/volta/blob/75581e5e8c36b58fa88557cfd4d01440fa1fd9ad/src/command/setup.rs#L46-L57

Basically, this would mean either changing setupVolta to always pass PATH as well as VOLTA_HOME:

https://github.com/volta-cli/action/blob/d253558a6e356722728a10e9a469190de21a83ef/src/installer.ts#L297-L310

Or calling .addPath before calling voltaSetup (though it would take a bit of reworking to actually handle correctly):

https://github.com/volta-cli/action/blob/d253558a6e356722728a10e9a469190de21a83ef/src/installer.ts#L386-L409

🤔