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

rbenv /usr/bin/env: ‘bash’: No such file or directory when creating a systemd service #49

Open
aashishvasu opened this issue Sep 28, 2022 · 1 comment

Comments

@aashishvasu
Copy link

I've followed the steps outlined in vps.md to set up Journal, and I have managed to get it running on manual starts quite easily.

However, I'm running into issues when creating a systemd service using the guide, and the service always fails.
running journalctl -u journal.service gives me the error:

rbenv[1215]: /usr/bin/env: ‘bash’: No such file or directory

After logging into the journal user, running the command

/home/journal/.rbenv/bin/rbenv exec bundle exec rails s

manually works correctly, it's only when the service starts is when the problem occurs.
What do you think could be going wrong?

My journal.service file for context:

[Unit]
Description=InodaJournal
After=network.target

[Service]
Type=simple
User=journal
Group=journal
WorkingDirectory=/home/journal/journal
Environment="JOURNAL_DATABASE_PASSWORD=***"
Environment="CIPHER_KEY=***"
Environment="SHARING_TOKEN_CIPHER_IV=***"
Environment="RAILS_ENV=production"
Environment="SECRET_KEY_BASE=***"
Environment="PATH=/home/journal/"
ExecStart=/home/journal/.rbenv/bin/rbenv exec bundle exec rails s
TimeoutSec=30
RestartSec=15s
Restart=always

[Install]
WantedBy=multi-user.target
@theClawsmos
Copy link

Hi aashishvasu, I hope you are doing well.

The error message you received, "/usr/bin/env: 'bash': No such file or directory," suggests that the shell specified in your systemd service file is not found. In your case, the shell specified is bash. However, the error indicates that the system cannot locate the bash executable.

To resolve this issue, you can try the following steps:

  1. Check the availability of the bash executable on your system. Run the following command to verify its location:
    which bash

  2. Update the ExecStart line in your systemd service file to explicitly specify the shell executable with its absolute path. For example, if the bash executable is located at /bin/bash, modify the ExecStart line as follows:
    ExecStart=/bin/bash -lc "/home/journal/.rbenv/bin/rbenv exec bundle exec rails s"
    The -lc option ensures that the shell is invoked as a login shell and loads the necessary environment variables.

  3. Save the changes to the systemd service file.

  4. Reload systemd to pick up the changes by running the following command:
    sudo systemctl daemon-reload

  5. Restart the journal.service systemd unit to apply the changes:
    sudo systemctl restart journal.service

Now, systemd should be able to locate the bash executable and execute the command specified in the ExecStart line successfully. Monitor the service logs using journalctl -u journal.service to check for any additional errors or issues that may arise.

Cheers,
theClawsmos

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