actions-rs / toolchain

🛠️ GitHub Action for `rustup` commands
https://github.com/marketplace/actions/rust-toolchain
MIT License
585 stars 86 forks source link

Fails with 'Error: The "path" argument must be of type string. Received type undefined' #185

Open ctron opened 3 years ago

ctron commented 3 years ago

Do the checklist before filing an issue:

Description

The actions fails with:

To configure your current shell, run:
source $HOME/.cargo/env
Error: The "path" argument must be of type string. Received type undefined

Workflow code

      - name: Install latest stable
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true

Action output

/home/builder/actions-runner/_work/_temp/e7a37539-272f-47cf-9559-376c37ffd79c --default-toolchain none -y
info: downloading installer
info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: skipping toolchain installation

Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source $HOME/.cargo/env
Error: The "path" argument must be of type string. Received type undefined

Expected behavior

It should succeed.

Additional context

This is running on an self-hosted runner. Both fedora34 and ubuntu-20.04 fail the same way.

ctron commented 3 years ago

Ok, after digging a bit into this issue: It seems that self hosted runner (when installed as service using ./svc.sh) get installed as "root", which doesn't seem to have "HOME" set, which then fails right here:

https://github.com/actions-rs/core/blob/4487ec12063a411d19993339db585c95b354ffb4/src/commands/rustup.ts#L89-L90

I guess just ignoring the error wasn't the best choice :grin:

Anyway, it isn't an issue of this repository. And you can work around this by installing the service as a dedicated user:

./svc.sh install <user>

Which works better for me anyway.