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

Problem when upgrading to 4.6.12 on Windows #1083

Closed
skuzzle opened this issue Dec 31, 2017 · 14 comments
Closed

Problem when upgrading to 4.6.12 on Windows #1083

skuzzle opened this issue Dec 31, 2017 · 14 comments
Assignees
Labels
bug Verified and replicated bugs and issues. fixed Bugs that are fixed (in a coming release).
Milestone

Comments

@skuzzle
Copy link
Contributor

skuzzle commented Dec 31, 2017

I am running Firefly III version 4.6.11.1 on Windows Server with nginx and php 7.1

Description of my issue:

I was trying to upgrade to the latest version 4.6.12 but encountered an error during the compoer create-project step. It seems like it does not download all the required files:

C:\nginx-1.12.0\html>php C:\php-7.1.10-nts-Win32-VC14-x64\composer.phar create-project grumpydictator/firefly-iii --no-dev --prefer-dist firefly-updated 4.6.12
Installing grumpydictator/firefly-iii (4.6.12)
  - Installing grumpydictator/firefly-iii (4.6.12): Downloading (100%)
Created project in firefly-updated
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
> if [ -z ${DYNO+x} ]; then echo Not in Heroku environment.; else php -r "file_exists('.env') || copy('.env.heroku', '.env');"; fi
Script if [ -z ${DYNO+x} ]; then echo Not in Heroku environment.; else php -r "file_exists('.env') || copy('.env.heroku', '.env');"; fi handling the pre-install
-cmd event returned with error code 1

The subsequent artisan calls fail with messages similar to this:

C:\nginx-1.12.0\html\firefly-updated>php artisan migrate --env=production
PHP Warning:  require(C:\nginx-1.12.0\html\firefly-updated/vendor/autoload.php):
 failed to open stream: No such file or directory in C:\nginx-1.12.0\html\firefly-updated\artisan on line 18
PHP Fatal error:  require(): Failed opening required 'C:\nginx-1.12.0\html\firefly-updated/vendor/autoload.php' (include_path='.;C:\php\pear') in C:\nginx-1.12.0\html\firefly-updated\artisan on line 18

The vendor folder is completely missing in the filrefly-update directory. Any ideas on this one?

@JC5
Copy link
Member

JC5 commented Dec 31, 2017

There is a command in the composer file that is Linux only. I suggest you remove line 102 from composer.json (starts with "if [ -z ${DYNO+x) and try again. Then, it should work.

@skuzzle
Copy link
Contributor Author

skuzzle commented Dec 31, 2017

Great, that worked. Thanks for the fast support (as always!)
It would be nice though if the build-process were platform independent again as it was before.

@JC5
Copy link
Member

JC5 commented Dec 31, 2017

Yep. I had not realized people use Windows. I'll see what I can do. I can either break A or break B and I need to find a middle road.

@JC5 JC5 self-assigned this Dec 31, 2017
@JC5 JC5 added the bug Verified and replicated bugs and issues. label Dec 31, 2017
@JC5 JC5 added this to the 4.7.0 milestone Dec 31, 2017
@JC5 JC5 changed the title Problem when upgrading to 4.6.12 Problem when upgrading to 4.6.12 on Windows Dec 31, 2017
@JC5
Copy link
Member

JC5 commented Jan 2, 2018

Could you execute this on your windows machine, see what happens?

php -r 'if (!(getenv("DYNO"))===false){echo "dyno";}else{echo "no dyno\n";}'

@pkoziol
Copy link
Contributor

pkoziol commented Jan 2, 2018

I've tried out of curiosity on my system (Win 10) although I don't run Firefly III on it:

C:\Users\koziolek>"C:\Program Files (x86)\PHP-7.1\php.exe" -v
PHP 7.1.8 (cli) (built: Aug  1 2017 21:10:46) ( ZTS MSVC14 (Visual C++ 2015) x86 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

C:\Users\koziolek>"C:\Program Files (x86)\PHP-7.1\php.exe" -r 'if (!(getenv("DYNO"))===false){echo "dyno";}else{echo "no dyno\n";}'
PHP Parse error:  syntax error, unexpected ''if' (T_ENCAPSED_AND_WHITESPACE), expecting end of file in Command line code on line 1

Parse error: syntax error, unexpected ''if' (T_ENCAPSED_AND_WHITESPACE), expecting end of file in Command line code on line 1

C:\Users\koziolek>"C:\Program Files (x86)\PHP-7.1\php.exe" -r "if (!(getenv('DYNO'))===false){echo 'dyno';}else{echo 'no dyno\n';}"
no dyno\n
C:\Users\koziolek>"C:\Program Files (x86)\PHP-7.1\php.exe" -r "if (!(getenv('PATH'))===false){echo 'dyno';}else{echo 'no dyno\n';}"
dyno

@JC5
Copy link
Member

JC5 commented Jan 3, 2018

OK, strange since Laravel's composer file uses this structure as well.

If you have the time, could you try to see what happens when you update composer.json with this?

"pre-install-cmd": [
      "@php -r \"if (!(getenv('DYNO'))===false){file_exists('.env') || copy('.env.heroku', '.env');}else{echo 'Not in Heroku environment\n';}\""
    ],

This is the same format as Laravel uses and I would expect it to work.

@pkoziol
Copy link
Contributor

pkoziol commented Jan 3, 2018

I'm not sure if you noticed that I'm not the original reporter 😉

Also I'm not sure why you think that this is strange. Original command didn't work, because Windows doesn't understand apostrophes ('). I've replaced them with quotes (") and it correctly printed no dyno\n, because I don't have DYNO variable set. Finally I've tried with some existing variable (PATH) and it printed dyno.

I don't have composer on Windows, so I've executed pre-install-cmd manually and it works as you expect.

Setup:

...\firefly-iii>set PATH=C:\Program Files (x86)\PHP-7.1\;%PATH%

...\firefly-iii>php -v
PHP 7.1.8 (cli) (built: Aug  1 2017 21:10:46) ( ZTS MSVC14 (Visual C++ 2015) x86 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

...\firefly-iii>"C:\Program Files\Git\usr\bin\md5sum.exe" .env*
ac82c1848fab9093cad1e4f3f0b9590d *.env.docker
9ed1773e359632280d30dad6e6aae414 *.env.example
520119aa2969c46fecc3b22cc23a9888 *.env.heroku
4c154d9f7a6a5c54581697a61dd07769 *.env.sandstorm
fcd9b32a172cc765497879f60f4f95fc *.env.testing

It displays message when DYNO is not set:

...\firefly-iii>echo %DYNO%
%DYNO%

...\firefly-iii>php -r "if (!(getenv('DYNO'))===false){file_exists('.env') || copy('.env.heroku', '.env');}else{echo 'Not in Heroku environment\n';}"
Not in Heroku environment\n

It copies file when DYNO is set:

...\firefly-iii>set DYNO=true

...\firefly-iii>echo %DYNO%
true

...\firefly-iii>php -r "if (!(getenv('DYNO'))===false){file_exists('.env') || copy('.env.heroku', '.env');}else{echo 'Not in Heroku environment\n';}"

...\firefly-iii>"C:\Program Files\Git\usr\bin\md5sum.exe" .env*
520119aa2969c46fecc3b22cc23a9888 *.env
ac82c1848fab9093cad1e4f3f0b9590d *.env.docker
9ed1773e359632280d30dad6e6aae414 *.env.example
520119aa2969c46fecc3b22cc23a9888 *.env.heroku
4c154d9f7a6a5c54581697a61dd07769 *.env.sandstorm
fcd9b32a172cc765497879f60f4f95fc *.env.testing

It doesn't overwrite file when it exists:

...\firefly-iii>echo 123 > .env

...\firefly-iii>"C:\Program Files\Git\usr\bin\md5sum.exe" .env*
2e8f90f6e2e0fed54f709294e814b804 *.env
ac82c1848fab9093cad1e4f3f0b9590d *.env.docker
9ed1773e359632280d30dad6e6aae414 *.env.example
520119aa2969c46fecc3b22cc23a9888 *.env.heroku
4c154d9f7a6a5c54581697a61dd07769 *.env.sandstorm
fcd9b32a172cc765497879f60f4f95fc *.env.testing

...\firefly-iii>php -r "if (!(getenv('DYNO'))===false){file_exists('.env') || copy('.env.heroku', '.env');}else{echo 'Not in Heroku environment\n';}"

...\firefly-iii>"C:\Program Files\Git\usr\bin\md5sum.exe" .env*
2e8f90f6e2e0fed54f709294e814b804 *.env
ac82c1848fab9093cad1e4f3f0b9590d *.env.docker
9ed1773e359632280d30dad6e6aae414 *.env.example
520119aa2969c46fecc3b22cc23a9888 *.env.heroku
4c154d9f7a6a5c54581697a61dd07769 *.env.sandstorm
fcd9b32a172cc765497879f60f4f95fc *.env.testing

@JC5
Copy link
Member

JC5 commented Jan 3, 2018

Yes, I noticed. I was hoping that @skuzzle would reply as well. As far as I can see the script works as expected. I just hope the format when used from composer.json works as well.

@skuzzle
Copy link
Contributor Author

skuzzle commented Jan 3, 2018

I've tried it now but unfortunately it still seems flawed. I added the pre-install-cmd into the composer.jso excatly as you stated and ran composer install. Still produces the following output on Windows Server 2012 R2:

C:\nginx-1.12.0\html\test>php C:\php-7.1.10-nts-Win32-VC14-x64\composer.phar install
> @php -r "if (!(getenv('DYNO'))===false){file_exists('.env') || copy('.env.heroku', '.env');}else{echo 'Not in Heroku environment';}"
Script @php -r "if (!(getenv('DYNO'))===false){file_exists('.env') || copy('.env.heroku', '.env');}else{echo 'Not in Heroku environment';}" handling the pre-install-cmd event returned with error code 1

@JC5
Copy link
Member

JC5 commented Jan 4, 2018

Strange, since the Laravel command is equal. I'll get my hands on a Windows machine and do some tinkering.

@devlearner
Copy link
Contributor

Sorry to chime in.
I'm actually new to Firefly III; and ran into the same problem as well when installing with composer.

From my little experiment on my platform (win 10, php 7.1) seems like it's the line break \n that's offending on windows:

"pre-install-cmd": [
      "php -r \"if (!(getenv('DYNO'))===false){file_exists('.env') || copy('.env.heroku', '.env');}else{echo 'Not in Heroku environment\n';}\""
    ],

replacing \n with PHP_EOL seems to do the trick (on my setup):

"pre-install-cmd": [
      "php -r \"if (!(getenv('DYNO'))===false){file_exists('.env') || copy('.env.heroku', '.env');}else{echo 'Not in Heroku environment',PHP_EOL;}\""
    ],

(Of course I haven't tested this on other platforms (e.g. Windows Server, Linux, or a Heroku setup) so I'm not sure if that's the ultimate cross-platform solution. Just hope it might shed some light.)

// By the way, if I may add
// really awesome work (Firefly III)! Keep up the good work!

@JC5
Copy link
Member

JC5 commented Jan 4, 2018

If it is, then problem solved! Thank you for providing me with the feedback! 😁

@skuzzle and @pkoziol, perhaps you can try as well? I don't particularly need the else-statement so I might drop it completely. The entire line would be come:

    "pre-install-cmd": [
      "@php -r \"if (!(getenv('DYNO'))===false){file_exists('.env') || copy('.env.heroku', '.env');}\""
    ],

@skuzzle
Copy link
Contributor Author

skuzzle commented Jan 4, 2018

That seems to do the trick:

C:\nginx-1.12.0\html\test>php C:\php-7.1.10-nts-Win32-VC14-x64\composer.phar install
> @php -r "if (!(getenv('DYNO'))===false){file_exists('.env') || copy('.env.heroku', '.env');}"
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 96 installs, 0 updates, 0 removals
  - Installing bacon/bacon-qr-code (1.0.3): Loading from cache
[...]

I'm not sure though whether it is correct that the php command is actually printed to the console

@JC5 JC5 added fixed Bugs that are fixed (in a coming release). and removed waiting-for-user labels Jan 6, 2018
@JC5 JC5 modified the milestones: 4.7.0, 4.6.13 Jan 6, 2018
@JC5
Copy link
Member

JC5 commented Jan 7, 2018

Release is live, issue will be closed.

@JC5 JC5 closed this as completed Jan 7, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Verified and replicated bugs and issues. fixed Bugs that are fixed (in a coming release).
Projects
None yet
Development

No branches or pull requests

4 participants