Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Batch file provided in vendor bin crashes on Windows #188

Closed
3 tasks
SierraKomodo opened this issue May 7, 2024 · 4 comments · Fixed by #189
Closed
3 tasks

[BUG] Batch file provided in vendor bin crashes on Windows #188

SierraKomodo opened this issue May 7, 2024 · 4 comments · Fixed by #189
Assignees
Labels
bug Something isn't working

Comments

@SierraKomodo
Copy link

Describe the issue

Running the csv-blueprint.bat file located in vendor/bin within a composer project utilizing csv-blueprint dumps the below error, regardless of which command is run, or even if no command is provided.

This occurs when running the file from the project root, i.e. via vendor/bin/csv-blueprint.bat, or when navigating to the bin folder and running the file from there.

Based on the error message, it appears to be trying to find the vendor folder within the csv-blueprint project folder instead of the root project folder when installed via composer as a dependency.

Tested using command prompt, powershell, nushell, and git bash shell environments on Windows 10.

Not tested in a linux environment.

To Reproduce

  • composer require jbzoo/csv-blueprint 1.0.0
  • vendor/bin/csv-blueprint.bat validate-schema --help
  • cd vendor/bin ; csv-blueprint.bat validate-schema --help
PHP Warning:  require_once(G:\Projects\Tools\vendor\jbzoo\csv-blueprint/vendor/autoload.php): Failed to open stream: No such file or directory in G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint.php on line 20
PHP Stack trace:
PHP   1. {main}() G:\Projects\Tools\vendor\bin\csv-blueprint:0
PHP   2. include() G:\Projects\Tools\vendor\bin\csv-blueprint:119
PHP   3. require_once() G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint:18

Warning: require_once(G:\Projects\Tools\vendor\jbzoo\csv-blueprint/vendor/autoload.php): Failed to open stream: No such file or directory in G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint.php on line 20

Call Stack:
    0.0003     863032   1. {main}() G:\Projects\Tools\vendor\bin\csv-blueprint:0
    0.0005     863696   2. include('G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint') G:\Projects\Tools\vendor\bin\csv-blueprint:119
    0.0007     866984   3. require_once('G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint.php') G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint:18

PHP Fatal error:  Uncaught Error: Failed opening required 'G:\Projects\Tools\vendor\jbzoo\csv-blueprint/vendor/autoload.php' (include_path='.;C:\php\pear') in G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint.php:20
Stack trace:
#0 G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint(18): require_once()
#1 G:\Projects\Tools\vendor\bin\csv-blueprint(119): include('G:\\Projects\\Too...')
#2 {main}
  thrown in G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint.php on line 20

Fatal error: Uncaught Error: Failed opening required 'G:\Projects\Tools\vendor\jbzoo\csv-blueprint/vendor/autoload.php' (include_path='.;C:\php\pear') in G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint.php on line 20

Error: Failed opening required 'G:\Projects\Tools\vendor\jbzoo\csv-blueprint/vendor/autoload.php' (include_path='.;C:\php\pear') in G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint.php on line 20

Call Stack:
    0.0003     863032   1. {main}() G:\Projects\Tools\vendor\bin\csv-blueprint:0
    0.0005     863696   2. include('G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint') G:\Projects\Tools\vendor\bin\csv-blueprint:119
    0.0007     866984   3. require_once('G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint.php') G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint:18

Expected behavior

The binary should either be functional when called from the vendor/bin folder, or should not be packaged within this folder when installed to a project with composer.

Your environment

Question Answer
CSV Blueprint version 1.0.0
OS Windows 10
PHP 8.3.6
XDebug 4.3.6
Composer 2.7.6
Installation Method Composer

Any links to the CI logs or the repository, if any.

@SierraKomodo SierraKomodo added the bug Something isn't working label May 7, 2024
@SmetDenis
Copy link
Member

SmetDenis commented May 7, 2024

Thank you very much for the report @SierraKomodo

It's interesting... I will try to find Win machine and reproduce the issue to fix.

In the meantime I can just recommend you to try using Docker or Phar file

# Just download the latest version
wget https://github.com/jbzoo/csv-blueprint/releases/latest/download/csv-blueprint.phar
chmod +x ./csv-blueprint.phar
./csv-blueprint.phar validate-csv               \
   --csv=./tests/fixtures/demo.csv              \
   --schema=./tests/schemas/demo_invalid.yml

@SmetDenis SmetDenis linked a pull request May 8, 2024 that will close this issue
SmetDenis added a commit that referenced this issue May 8, 2024
This change uses various possible path locations to locate the `autoload.php` file and throws an error if not found.
It closes #188
@SmetDenis
Copy link
Member

Hi @SierraKomodo

I fixed the issue in the release v1.0.1

When you have a chance, try to install a new version a test it again. Please let me know about the results.

Thank you in advance.

@SierraKomodo
Copy link
Author

Hi @SierraKomodo

I fixed the issue in the release v1.0.1

When you have a chance, try to install a new version a test it again. Please let me know about the results.

Thank you in advance.

Added to my todo list for today when I get home from work.

@SierraKomodo
Copy link
Author

Looks to be working now in testing. Tested both the batch and bash script files in various windows terminals (And git bash for the bash script) on windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants