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

Can't run in Github Actions due to sudo use #8

Open
nihohit opened this issue Jul 9, 2024 · 4 comments
Open

Can't run in Github Actions due to sudo use #8

nihohit opened this issue Jul 9, 2024 · 4 comments

Comments

@nihohit
Copy link

nihohit commented Jul 9, 2024

When I try to use this in Github Actions I get these errors:

initdb failed! stdout: 

stderr: sudo: initdb: command not found
), location: Location { file: "/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgtemp-0.3.0/src/run_db.rs", line: 72, col: 9 }

from what I see, this happens because sudo can't find initdb in its secure path - adding the path to postgres to $PATH doesn't solve the issue.
I mitigated the issue by copying the whole postgresql bin &lib folders into /usr/bin & /usr/lib respectively, but it would be nice if the library could handle this.

@boustrophedon
Copy link
Owner

If you have the $GITHUB_PATH step in your github action, you probably need to do something like sudo -E so that the updated $PATH environment variable is carried over.

However, postgres itself refuses to run as root so I'm not sure what you're doing will work at all.

@nihohit
Copy link
Author

nihohit commented Jul 9, 2024

However, postgres itself refuses to run as root so I'm not sure what you're doing will work at all.

It works, I assume thanks to the sudo call in pgtemp.

As for using sudo -E - it seems like it isn't supported by the sudo in the runner:

Run sudo -E
usage: sudo -h | -K | -k | -V
usage: sudo -v [-ABkNnS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-ABkNnS] [-g group] [-h host] [-p prompt] [-U user]
            [-u user] [command [arg ...]]
usage: sudo [-ABbEHkNnPS] [-r role] [-t type] [-C num] [-D directory]
            [-g group] [-h host] [-p prompt] [-R directory] [-T timeout]
            [-u user] [VAR=value] [-i | -s] [command [arg ...]]
usage: sudo -e [-ABkNnS] [-r role] [-t type] [-C num] [-D directory]
            [-g group] [-h host] [-p prompt] [-R directory] [-T timeout]
            [-u user] file ...

I'm not sure that there is a solution to this issue 🤷

@boustrophedon
Copy link
Owner

boustrophedon commented Jul 9, 2024

It works, I assume thanks to the sudo call in pgtemp.

Ah, I had gone back and forth on whether to include that feature and forgot that I actually ended up keeping it.

I'm not sure why it isn't working for you in github actions then. You definitely have the $GITHUB_PATH step included in your action prior to starting pgtemp?

@nihohit
Copy link
Author

nihohit commented Jul 9, 2024 via email

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

2 participants