Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

propel-gen.bat different when installing Propel via Composer #588

Closed
wants to merge 1 commit into from

4 participants

Markus Staab William Durand Jordi Boggiano Marc J. Schmidt
Markus Staab
Collaborator

Just moved away from a PEAR setup propel project and went to a composer based approach.

After installing propel1 using composer I recognized, that the propel-gen.bat contains:

@ECHO OFF
SET BIN_TARGET=%~dp0\"../propel/propel1/generator/bin"\propel-gen
bash "%BIN_TARGET%" %*

when running vendor\bin\propel-gen.bat it aborts with a bash not found error.

Markus Staab
Collaborator

changing the batch file to just

@ECHO OFF
%~dp0\..\propel\propel1\generator\bin\propel-gen

and it works as expected...

Don't know where this file is defined within propel (or composer)?

William Durand
Owner
Markus Staab
Collaborator

Sure, but I don't know where this batch file is located.. It is not the one located in generator/lib/propel-gen.bat

Markus Staab
Collaborator

Hmm I suppose the errornous file is composer generated....
composer/composer@7e3f809#commitcomment-2545999

Jordi Boggiano

@staabm I don't see why that change should affect the end result. If propel-gen has a shebang that calls bash, calling it with bash directly should work just the same. If it says bash not found it shouldn't find it via the shebang either. The reason we do that in composer is that on windows if you don't use bash/gitshell, the shebang isn't read, so we read it and add that process as called in the .bat file.

Markus Staab
Collaborator

@Seldaek so I cant use the batch from the windows command line, because there is no bash command? Or do I need to install some tooling to be able to use the batch files?

Jordi Boggiano
Markus Staab
Collaborator

I think by default bash will not be on PATH on every windows system?

Hmm propel provides a bash and also a batch file for the cli, maybe this is something composer cannot cope with?
Or in other words: does composer generate this vendor/bin/propel-gen file containing the bash command because propel also provides a propel-gen.sh?

Jordi Boggiano

Traditionally many programs came with both bash and batch files that were just starting a php file. Composer makes it easy to just have one php file marked executable, and if you put a shebang in it, it'll work fine on nix and windows. I think that's easier, and I would encourage everyone to migrate to this solution. If it's not practical then maybe listing both batch and bash files in composer bin would help, but not sure about this.

Markus Staab
Collaborator

Don't know how to solve this. I have no clue how and why this file is generated in the way it is by composer.
In Propels' repos there is no batch file which contains a bash command.

Markus Staab
Collaborator

Just tried how it works when the "bash" command is available at CLI.

The propel-gen.bat runs in another error, since it cannot find phing command

> vendor\bin\propel-gen
# output..
\vendor\bin\\../propel/
propel1/generator/bin\propel-gen: line 50: phing: command not found
Jordi Boggiano

The problem is that https://github.com/propelorm/Propel/blob/master/generator/bin/propel-gen#L1 is using bash as executable, it is a bash script. And since it's listed first in the composer.json, composer creates a windows proxy for it (propel-gen.bat), then the original propel-gen.bat (https://github.com/propelorm/Propel/blob/master/generator/bin/propel-gen.bat) comes and it's not created since it already got created as the proxy to the first one.

So I see two solutions (cc @willdurand):

  • Reverse the order of the two bins in composer.json, which should fix the problem but is kinda hackish
  • Rewrite propel-gen to be a php script instead, and let composer create a propel-gen.bat proxy for you for windows users.
William Durand
Owner

Thanks Jordi for your comment.

@staabm would you mind rewrite the propel-gen?

Markus Staab
Collaborator

I would suggest to reverse the order of the binaries inside the composer.json in propel1 (as Pointed out by Seldaek) and do the rewrite for propel2...

But I am also willing to do the rewrite for propel1 in case you want me to do it.

Marc J. Schmidt
Owner

We should make a decision here. @staabm, if you're still willing to provide a PR then we should kinda fix that.

Markus Staab
Collaborator

thats the way I would solve it:

I would suggest to reverse the order of the binaries inside the composer.json in propel1 (as Pointed out by Seldaek) and do the rewrite for propel2...

@marcj @jaugustin any opinions?

Marc J. Schmidt
Owner

Yes, I think that's probably the best solution, because

  • it's a fast solution, KISS
  • we don't need to override the whole bin/ scripts
  • I don't see its a hack, because actually composer shouldn't overwrite own repo files and we prevent that with this way
Markus Staab staabm was assigned
Markus Staab
Collaborator

Ok, will try to get a PR prepared for that.

Markus Staab staabm referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Markus Staab
Collaborator

@Seldaek I added the change you proposed.. could you tell me a way, how I could test this without merging it ..? don't know how to reference the propel version of this PR in a test-project to start testing...

Markus Staab
Collaborator

@Seldaek Thank you.

tried using

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/staabm/propel"
        }
    ],
    "require": {
        "propel/propel1": "dev-issue588"
    }
}

but got

> composer update
Loading composer repositories with package information

  [RuntimeException]
  Failed to clone https://github.com/staabm/propel, could not read packages f
  rom it

  fatal: https://github.com/staabm/propel/info/refs?service=git-upload-pack n
  ot found: did you run git update-server-info on the server?

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-custom-instal
lers] [--no-scripts] [--no-progress] [-v|--verbose] [-o|--optimize-autoloader] [
packages1] ... [packagesN]
Jordi Boggiano
Markus Staab
Collaborator

@Seldaek it works with an uppercased 'P' thanks for that.

The actual fix cd82fa3 you suggested didn't work for me. Although I re-ordered the propel-gen.bat composer generates a vendor/bin/propel-gen.bat which is not based on the one provided by propel.

Jordi Boggiano

OK I fixed this in composer/composer@0d06eb1 but it still breaks when executing the file anyway because it assumes phing.bat is in the PATH, which it isn't.

Markus Staab
Collaborator

Thank you, will have another look at it this evening.

Markus Staab
Collaborator

tried composer with your latest patch. The phing command is found but I runs in some errors because of path issues.

phing and the build.xml was found but not the required build.properties.

will investigate further..

Markus Staab
Collaborator

no easy way to resolve this, without rewriting the bat from scratch.. closing

Markus Staab staabm closed this
Christoph xrstf referenced this pull request from a commit in webvariants/datawrapper
Christoph xrstf rebuilt Propel files and added helper for Windows systems
Using Propel 1 with Composer is a nightmare on Windows:
propelorm/Propel#588

The small batch file works around Propel by simply directly
invoking Phing.
15ef3f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 3, 2013
  1. Markus Staab
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  composer.json
2  composer.json
View
@@ -31,5 +31,5 @@
"url": "http://pear.php.net"
}
],
- "bin": ["generator/bin/propel-gen", "generator/bin/propel-gen.bat"]
+ "bin": ["generator/bin/propel-gen.bat", "generator/bin/propel-gen"]
}
Something went wrong with that request. Please try again.