0

my bash script :

#!/bin/bash . ~/er/erl/activate kiex use 1.13.4 mix phx.server 

i user kerl and kiex to manage my erlang and elixir installations

I am trying to use this script in my service;

 [Unit] Description=BlockScout Server After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 User=ubuntu StandardOutput=syslog StandardError=syslog WorkingDirectory=/usr/local/blockscout ExecStart=/usr/local/bin/startBlockscout.sh EnvironmentFile=/usr/local/blockscout/env_vars.env [Install] WantedBy=multi-user.target 

as you can see, startBlockscout.sh is the name of my bash script. i intend to run this script as a part of the Execstart field in a linux service

i want to know, how can i make sure that my script recognises the kerl and kiez while running in a service

i keep getting the errors;

line 3: kiex: command not found line 4: mix: command not found 

if i try to use the same commands in a bash script that i launch directly from the shell, the commands of kiex and mix work !

they just don't work when i am trying to execute them using the service

any advice is greatly appreciated !

4
  • What user is the script running as (i.e., what directory is ~ in the script referring to when running as a service)? Commented Aug 8, 2023 at 11:10
  • Are you using the full paths of the commands in the script? I assume that the PATH variable of the ubuntu-user does load the commands only via e.g. bashrc, which would not happen for the service. Commented Aug 8, 2023 at 11:30
  • @FelixJN how can i make it happen for the service ? Commented Aug 8, 2023 at 15:29
  • @Kusalananda the username is Ubuntu Commented Aug 8, 2023 at 15:29

1 Answer 1

1

kiex and mix are probably installed into a path that is added to your search path (the PATH environment variable) when you log in or start an interactive shell.

Since the service neither logs you in nor starts an interactive shell, that doesn't happen.

So, simply specify the full path to kiex and mix.

3
  • kiex is the version manager for elixir. do you think specifying kiex should help me use mix ? Commented Aug 8, 2023 at 15:30
  • I don't understand what is unclear about the instructions – specify the full path path of kiex and mix, instead of just saying kiex and mix. Commented Aug 8, 2023 at 15:36
  • entschuldigung , i was just asking to confirm Commented Aug 9, 2023 at 1:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.