Composer 无法运行安装后脚本 [英] Composer unable to run post install script

查看:37
本文介绍了Composer 无法运行安装后脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 Composer 安装/更新后挂钩中运行 bash 脚本时出现以下错误:

I'm getting the following error when trying to run a bash script in Composer post install/update hooks:

> post-install.sh
sh: 1: post-install.sh: not found
Script post-install.sh handling the post-install-cmd event returned with an error



  [RuntimeException]
  Error Output: sh: 1: post-install.sh: not found

原作曲家.json

可以,但是更新后安装/更新命令以在两个地方运行很烦人.

{
  "require": {
    "twbs/bootstrap": "3.3.5"
    ...
    ...
  },
  "scripts": {
    "post-install-cmd": [
      "mkdir -p _libraries",
      "cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/",
      ...
      ...
    ],
    "post-update-cmd": [
      "mkdir -p _libraries",
      "cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/",
      ...
      ...
    ]
  }
}

根据作曲家文档:

在 Composer 的术语中,脚本可以是 PHP 回调(定义作为静态方法)或任何命令行可执行命令.

A script, in Composer's terms, can either be a PHP callback (defined as a static method) or any command-line executable command.

所以我的 composer.json 应该可以这样工作:

So my composer.json should be able to work as such:

需要 composer.json

{
  "require": {
    "twbs/bootstrap": "3.3.5"
    ...
    ...
  },
  "scripts": {
    "post-install-cmd": [
      "post-install.sh"
    ],
    "post-update-cmd": [
      "post-install.sh"
    ]
  }
}

post-install.sh

每个人都可以执行 (0775) 并且与 composer.json 位于同一目录中

Executable by everyone (0775) and located in the same directory as the composer.json

#!/bin/bash

mkdir -p _libraries
cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/
...
...

推荐答案

评论我建议使用

bash post-install.sh

这似乎有效.

这篇关于Composer 无法运行安装后脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆