dongzilu0178 2019-01-31 01:43
浏览 346
已采纳

Composer找不到配置文件 - 在Windows上使用Jenkins

I have an Ant build script that is trying to execute Composer install but I get this error when executed through Jenkins:

     [exec] Composer could not find the config file: C:\ProgramData\ComposerSetup\bin
     [exec] To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
     [exec] Result: 1
     [echo] composer update complete

Here is the target from Ant:

<target name="self-update"
        if="composer.self-update"
        unless="composer.installed"
        description="Self-update Composer">
    <echo message="Self-updating composer" level="debug"/>
    <exec executable="${composer.phar}">
        <arg value="self-update" />
        <arg value="--quiet" />
        <arg value="--no-interaction" />
    </exec>
    <echo message="composer self-update complete" level="debug"/>
</target>

However, this works fine when running the Ant build locally.

Some people say to delete the environment variables that the composer installer sets; however it does not seem to change anything.

  • 写回答

1条回答 默认 最新

  • dongmi5177 2019-02-12 14:01
    关注

    There was an environment variable named COMPOSER that was set to C:\ProgramData\ComposerSetup\bin. The variable was not visible through the Environment Variables control panel.

    I could work around this by setting the env key="composer" to "".

    <target name="composer"
            depends="init, self-install, self-update"
            if="composer.run">
        <condition property="composer.command" value="update" else="install">
            <available file="${composer.lock}"/>
        </condition>
        <echo message="Beginning composer ${composer.command}" level="debug"/>
        <exec executable="php">
            <env key="composer" value=""/>
            <arg value="${composer.phar}"/>
            <arg value="${composer.command}"/>
            <arg value="--verbose"/>
            <arg value="--no-interaction"/>
            <arg value="--optimize-autoloader"/>
            <arg value="--prefer-dist"/>
        </exec>
        <echo message="composer ${composer.command} complete" level="debug"/>
    </target>
    

    It's also possible set it to composer.json.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵