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

sculpin fails to run from vendor/bin directory after a composer install #318

Closed
steverhoades opened this issue Oct 30, 2016 · 7 comments
Closed

Comments

@steverhoades
Copy link

Error described in title.

steverhoades added a commit to steverhoades/sculpin that referenced this issue Oct 30, 2016
@briggsd
Copy link

briggsd commented Oct 31, 2016

I have a similar issue, not sure if it is related, with sculpin failing to run after composer install.

Execute:
vendor/bin/sculpin generate --watch --server

Returns:
Fatal error: Call to a member function getPrettyVersion() on a non-object in vendor/sculpin/sculpin/src/Sculpin/Bundle/SculpinBundle/Console/Application.php on line 57

Note this is being attempted on Windows.

@ghost
Copy link

ghost commented Dec 26, 2016

you have to add php in front of that command, but that will most likely lead to another problem on Windows, which I have.

php vendor/bin/sculpin generate --watch --server

The problem immediately after running above:

dir=$(d=${0%[/\\]*}; cd "$d"; cd "../sculpin/sculpin/bin" && pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
        # Cygwin paths start with /cygdrive/ which will break windows PHP,
        # so we need to translate the dir path to windows format. However
        # we could be using cygwin PHP which does not require this, so we
        # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
        if [[ $(which php) == /cygdrive/* ]]; then
                dir=$(cygpath -m "$dir");
        fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/sculpin" "$@"

@yaredc
Copy link

yaredc commented Dec 29, 2016

Just create your own bootstrap file sculpin.php in your root folder, and place following code

<?php

$classLoader = include __DIR__ . '/vendor/autoload.php';
include_once __DIR__ . '/vendor/sculpin/sculpin/bin/sculpin.php';

and now you can call it like php sculpin.php generate. With 5 mins of debugging you can find out that prettyVersion() thingie is caused on Win in

vendor/dflydev/embedded-composer/src/Dflydev/EmbeddedComposer/Core/EmbeddedComposerBuilder.php:164

On Win, paths are built like C:\WIN\PATH (not Unix style), and also, at that point, the path is actually the correct one. Just modify it like this:

if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
    if (0 !== strpos($externalVendorDirectory, '/')) {
        $externalVendorDirectory = $this->externalRootDirectory . '/' . $externalVendorDirectory;
    }
}

It worked for me. I did not get into details exactly where and why this happens, but it should work.

NOTE: This is just a quick fix, NOT the real deal.

@edwardhew @j-danner

@gugglegum
Copy link

Hi! I had all the same issues described here. And last fix with strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' helped. I think all these issues related to Windows platform. If fix was so easy, why not to commit this fix to dflydev/embedded-composer?

@yaredc
Copy link

yaredc commented Jan 19, 2017

It's because I am lazy.

@cMurschall
Copy link

The fix worked for me right away.

@simensen
Copy link
Member

This should be workable in the most recent @dev version of embedded composer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants