-
Notifications
You must be signed in to change notification settings - Fork 9
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
shebang incorrect in v1.0.0 causes CLI console error #8
Comments
Long story short - for anyone encountering this issue, download the source and build it yourself! Thats the beauty of open-source. And, thanks @AnandPilania for creating a great tool, even if it has given me half a day of headache (to be fair, I do enjoy debugging - maybe not so much other peoples tools, but still fun 😁 ) - since they got rid of To build your own release of this tool, you're going to need the wget https://github.com/AnandPilania/php-android-cli/releases/download/v1.0.0/phpandroid.phar # download the source from github
gitclone git@github.com:AnandPilania/php-android-cli.git
# get the vendor folder out of the official release (this extracts to current working dir
# into a new subdirectory 'tmp')
phar extract -f phpandroid.phar tmp
cd php-android-cli
cp -r ../tmp/vendor .
cd tasks
php generate_phar.php # before running this, I modified ../index.php to change the version number, see below
# clean up
rm -rf ../../tmp
# (optionally) put the new phpandroid.phar into your bin
# I used /usr/bin but it probably should be /usr/local/bin or even ~/bin
sudo mv phpandroid.phar /usr/local/bin/.
# I removed the extension when copying to /usr/bin, but you should prolly symbolic link instead
sudo ln -s /usr/local/bin/phpandroid.phar /usr/local/bin/phpandroid
# why? well, what other linux commands have extensions? no, I can't think of any either After following the above commands, you should have a shiny new phpandroid.phar in folder $app = new Symfony\Component\Console\Application('PHP Android Console App [nos self-build]', 'v1.0.99'); |
Hi @Nos78, sorry for the |
@AnandPilania look forward to it! Thanks for the quick response - can't count the number of times there is a nice useful tool with a github repo, and the owner doesn't ever reply 😞 |
I have automated the entire process of this work around, just download this script: https://github.com/Nos78/php-android-cli/blob/master/tasks/fix-phpandroid.sh This script:
|
(NOTE: I have commited but haven't pushed this commit for new version of I have modified my fix script so that it will download the latest release, rather than hardcoding v1.0.0 using this URL: Unfortunately that cannot be used for source archive (zips or tars). It now gets the source by accessing the API to get
|
The latest release v1.0.0 causes a console error when trying to run phpandroid.phar
I downloaded the latest release, and placed it in
/usr/bin
as phpandroid, then tried to run it in a bash shell:A simple
hexedit
of the phpandroid.phar shows that the hashbang/shebang line has windows type file endings 0D0A /r/n (instead of just 0A or /n) and so it is interpretting the shebang as#!/usr/bin/env/php\r
instead of#!/usr/bin/env php
.Unfortunately (for me) I couldn't just hexedit the line ending, changing it to 0A0A (cannot remove a byte, only change it, so effectively this adds a blank line with a unix line-ending character) because that breaks the SHA1 file signature.
I also tried to
phar extract
the archive and re-pack it withphar pack -b '#!/usr/bin/env php' -f phpandroid.phar *
but this does not even insert a shebang at all? (again, viewing with hexedit shows no shebang where there should be one). In the end I downloaded the source and re-compiled my own binary usingcd tasks && php generate_phar.php
, which added the shebang correctly formatted with proper line ending.For curiosity-sake, I delved into the code of phar.phar; the section which adds/modifies the hashbang is adding '/n' to the line if a new-line is not present; so I can only assume that the release was built on a windows machine and the
/usr/bin/env php
line at the top ofstub.php
had the wrong line ending?The text was updated successfully, but these errors were encountered: