1

Curious if anyone has ever run into this before or may know what's going on here. I'm using the execWidget plugin (https://github.com/marionnewlevant/craft-exec_widget) to run a script from Craft's dashboard that does a composer install when the lock file has changed.

Here is the configuration for the plugin:

<?php
return [
  '*' => [
  ],
  'local' => [
    'commands' => [
      'composer install' => '../scripts/ed-day_composer.sh',
      'pull assets from production' => '../scripts/pull_assets.sh',
    ]
  ],
  'staging' => [
    'commands' => [
      'composer install' => '../scripts/ed-day_composer.sh',
      'push everything production' => '../scripts/push_all.sh',
    ]
  ],
];

Here is the composer install script:

#!/bin/bash

# Get the directory of the currently executing script
DIR="$(dirname "${BASH_SOURCE[0]}")"

# Include files
INCLUDE_FILES=(
            "common/defaults.sh"
            ".env.sh"
            "common/common_env.sh"
            "common/common_db.sh"
            )
for INCLUDE_FILE in "${INCLUDE_FILES[@]}"
do
    if [ -f "${DIR}/${INCLUDE_FILE}" ]
    then
        source "${DIR}/${INCLUDE_FILE}"
    else
        echo "File ${DIR}/${INCLUDE_FILE} is missing, aborting."
        exit 1
    fi
done

(cd "${LOCAL_ROOT_PATH}/craft"; HOME=${LOCAL_HOME} composer install)

I get a returned 127 error from the queue.log and the scrip does not actually work:

2018-06-25 14:10:12 [50.200.203.190][1][-][info][craft\queue\QueueLogBehavior::beforeExec]  [45] ExecWidget Task (attempt: 1) - Started
2018-06-25 14:10:12 [50.200.203.190][1][-][info][marionnewlevant\execwidget\jobs\ExecWidgetTask::log] executing ../scripts/ed-day_composer.sh
2018-06-25 14:10:12 [50.200.203.190][1][-][info][marionnewlevant\execwidget\jobs\ExecWidgetTask::log] returned 127

Based on testing I've done, I'm almost certain the issue is with composer because I get a success error message when I remove just the composer part of the line.

Composer works when SSHing in. Any idea what might be causing the issue?

  • If you SSH in and execute scripts/ed-day_composer.sh directly, do you get the same error response? – Brad Bell Jun 25 '18 at 22:31
  • Hey @BradBell - good suggestion! So if I SSH in and execute the script, it works, but still gives the same error when attempting to run it via the Craft control panel. Any idea as to what that means or where to investigate further? – dpayne Jun 26 '18 at 15:02
  • Update here - seems likely this is tied to some sort of permissions issue as I get this error when I attempt to install a plugin from the plugin store: Error: file_put_contents(/home/ediscoveryday/www/stage/craft/composer.json): failed to open stream: Permission denied. Working to find the exact permissions I need to adjust. – dpayne Jun 26 '18 at 15:31
1

The problem seems to be tied to Composer not having the correct permissions. Will work with our IT team to update so Composer can write appropriately when initiated from Craft.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.