skip to content
Alvin Lucillo

Inline nfpm script causing error

/ 1 min read

If you’re using nfpm to create a .deb package, you might encounter no such file or directory. This is usually due to using inline script in the nfpm package. To fix that, transfer the inline script into its own file.

nfpm pkg --target . -f config.yaml error:

open #!/bin/bash
chown -R myuser:myuser /opt/myapp/
systemctl daemon-reload
...
: no such file or directory

config.yaml contains inline script

scripts:
  postinstall: |
    #!/bin/bash
    chown -R myuser:myuser /opt/myapp/
    systemctl daemon-reload
    systemctl enable myapp.service
    systemctl start myapp.service

config.yaml now references the script file postinstall.sh

# ...
scripts:
  postinstall: ./scripts/postinstall.sh

postinstall.sh

#!/bin/bash
chown -R myuser:myuser /opt/myapp/
systemctl daemon-reload
systemctl enable myapp.service
systemctl start myapp.service