jkeenan1 has asked for the wisdom of the Perl Monks concerning the following question:

I am doing my annual revision and upload of an income-tax-related CPAN module. For testing on Windows (to which I myself don't have access), this year I added an AppVeyor configuration file (.appveyor.yml) essentially cloned from one of existing AppVeyor config files.

$ cat .appveyor.yml version: 1.0.{build} branches: except: - /travis/ skip_tags: true cache: - C:\strawberry -> .appveyor.yml install: - if not exist "C:\strawberry" cinst strawberryperl - set PATH=C:\strawberry\perl\bin;C:\strawberry\perl\site\bin;C:\str +awberry\c\bin;%PATH% - cd C:\projects\%APPVEYOR_PROJECT_NAME% - cpanm --installdeps . build_script: - perl Makefile.PL - gmake test_script: - gmake test TEST_VERBOSE=1 notifications: - provider: Email to: - jkeenan@cpan.org on_build_status_changed: true

However, the AppVeyor process repeatedly fails. Here's the relevant part of the output:

StrawberryPerl v5.40.0.1 [Approved] strawberryperl package files install completed. Performing other insta +llation steps. Downloading strawberryperl 64 bit from 'https://github.com/StrawberryPerl/Perl-Dist-Strawberry/release +s/download/SP_54001_64bit_UCRT/strawberry-perl-5.40.0.1-64bit.msi' Progress: 100% - Completed download of C:\Users\appveyor\AppData\Local +\Temp\1\chocolatey\StrawberryPerl\5.40.0.1\strawberry-perl-5.40.0.1-6 +4bit.msi (196.43 MB). Download of strawberry-perl-5.40.0.1-64bit.msi (196.43 MB) completed. Hashes match. Installing strawberryperl... strawberryperl has been installed. strawberryperl may be able to be automatically uninstalled. Environment Vars (like PATH) have changed. Close/reopen your shell to see the changes (or in powershell/cmd.exe just type `refreshenv`). The install of strawberryperl was successful. Software installed to 'C:\Strawberry\' Chocolatey installed 1/1 packages. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.lo +g). set PATH=C:\strawberry\perl\bin;C:\strawberry\perl\site\bin;C:\strawbe +rry\c\bin;%PATH% cd C:\projects\%APPVEYOR_PROJECT_NAME% The system cannot find the path specified. Command exited with code 1

If I download the log.txt file from this run, the last 10 to 12 lines match the tail of the output above.

My other distros using .appveyor.yml configuration files build and test as expected, so I am at a lost as to explain why this one does not. Any suggestions?

Replies are listed 'Best First'.
Re: AppVeyor failing to build/test CPAN distro
by swl (Prior) on Feb 21, 2025 at 03:54 UTC

    What does echo C:\projects\%APPVEYOR_PROJECT_NAME% produce?

    One possibility is that the CI is running under powershell, which uses a perl-like syntax for variables. The config does not specify the shell, but maybe it is in the system setup.

    The cd call also might also not be needed if the system is already in the project dir. (Edited typo)

    (Some of the above was cribbed from https://help.appveyor.com/discussions/problems/10635-cant-cd-to-appveyor_build_folder).

      I don't have a terminal at which to echo that command. The only way I know how to use AppVeyor is what I'm provided with at ci.appveyor.com.

        In recent years, my windows-based test has been focused on GHActions rather than AppVeyor, but many of my older projects still have the AppVeyor setup.

        swl said,

        One possibility is that the CI is running under powershell

        As the "cribbed" source says, AppVeyor defaults to cmd for its script, and you have to prefix powershell scripts with ps: . So , since jkeenan1's cat shows no ps prefixes, I don't think that's the problem. (In the "cribbed" question, the questioner was specifically doing the cd in a - ps: cd ... command, so needed to use powershell syntax.)

        swl said,

        The cd call also might also not be needed if the system is already in the project dir.

        I just checked a handful of my .appveyor.yml files, and none of them needs a cd to properly work. So I would agree with this advice.

        However, AppVeyor's env-var docs claim that %APPVEYOR_PROJECT_NAME% is the correct name for that variable. I haven't printed that variable in a while (if ever), so I concur with swl's advice: jkeenan1 may want to echo both that variable, and I will add the suggestion for also echoing the %APPVEYOR_BUILD_FOLDER% mentioned in the "cribbed" source, because it doesn't make sense to me that the cd isn't working -- I thought momentarily that it might be because the variable value is lowercase whereas the directory might really be uppercase (or vice versa), but this is Windows, so case should be irrelevant. So even if the cd is not needed, I am still curious why it isn't working.

        jkeenan1 said,

        I don't have a terminal at which to echo that command.

        I believe you misunderstood swl's echo advice: you can add commands your your .appveyor.yml to do the echo, and then re-run the CI. Change your "install" section to:

        install: - if not exist "C:\strawberry" cinst strawberryperl - set PATH=C:\strawberry\perl\bin;C:\strawberry\perl\site\bin;C:\str +awberry\c\bin;%PATH% - echo cd C:\projects\%APPVEYOR_PROJECT_NAME% - echo %APPVEYOR_BUILD_FOLDER% - echo %CD% - cpanm --installdeps .

        I think this will do two things: 1) assuming that the echo commands don't cause the "install" step to fail, it should show that the cd isn't needed, since my version of the "install" step doesn't actually execute the cd, and (2) it will show the current values of those environment variables, if it's needed for future debugging.


        update: I tried an .appveyor.yml that includes those three echoes I showed (among other things), with the AppVeyor results showing that echoing C:\projects\%APPVEYOR_PROJECT_NAME% and %APPVEYOR_BUILD_FOLDER% and %CD% all give the same value for my repository ("avtest") . So, unless jkeenan1 has something weird in the project name, I see no reason why the cd wouldn't've worked, which is exceedingly confusing to me.
        Environment Vars (like PATH) have changed. Close/reopen your shell to
        see the changes (or in powershell/cmd.exe just type `refreshenv`).


        AIUI, APPVEYOR_PROJECT_NAME is an "Environment Var".
        Is there anything in the outputs (to which you have access) that indicates what APPVEYOR_PROJECT_NAME has been set to ?

        Cheers,
        Rob