Path problems: How to give buildkite-agent user access to yarn and python (Amazon Linux)

We have made a VM on Amazon EC2 that will be used to test builds. I’ve installed yarn, python, as well as rustup, and while those all work for the default user, but the buildkite-agent user doesn’t have access to these (likely as they are installed locally). I’m trying to install the various dependencies for the buildkite-agent, but I can’t figure out where to update the $PATH variable so that it can use yarn and the like.

Any help would be greatly appreciated

Hello, @sotrh! Welcome to the community!

It would greatly help if you could provide more information. How did you install the agent? Can you please outline the steps you’ve taken because the issue might not be just about the path?

To update the $PATH variable for your Buildkite agent, you can add the desired paths to the buildkite-agent script.

To do it, you need to locate the buildkite-agent script on your system (typically located in /usr/local/bin/buildkite-agent). Open the script and find the line where the $PATH variable is set (it should look like PATH="$BUILDKITE_AGENT_PATH:$PATH"). Add the desired paths to the $PATH variable, save and close the script.

You’ll need to restart the Buildkite agent for the changes to take effect.

Alternatively, you can also set the $PATH variable on the command line before starting the agent (running it as buildkite-agent user). For example:

export PATH=$PATH:/usr/local/bin
buildkite-agent start

Looking forward to receiving the additional information from you.
Cheers!

I installed the Buildkite agent via the docs Installing Buildkite Agent on Ubuntu v3 | Buildkite Documentation. I checked to the buildkite-agent script you mentioned, but the /usr/local/bin directory is empty.

Also as far as running as the buildkite-agent user, I don’t know the password associated with the account. I can access it with sudo su buildkite-agent, but installing nvm and yarn that way doesn’t add it to the path.

EDIT: To give more context I have a .profile file at /var/lib/buildkite-agent. Loading directly in the shell allows me to run build commands, but the automated system doesn’t seem to be using the file.

Hello, @sotrh! Thank you for supplying the additional information!
There are several possible ways to get your buildkite-agent user to be able to use yarn and nvm:

  • You can make your first step in the pipeline the step that does the installation of all the packages that will be necessary.
  • You can install all the dependencies globally - so all users on your machine will have access to them.
  • Or you can isolate all the dependencies by using Docker.

Cheers!