Bug #44000
Flow CLI on Windows does not work anymore
Status: | Resolved | Start date: | 2012-12-14 | |
---|---|---|---|---|
Priority: | Must have | Due date: | ||
Assigned To: | Bastian Waidelich | % Done: | 100% |
|
Category: | Cli | |||
Target version: | - | |||
PHP Version: | Complexity: | |||
Has patch: | No | Affected Flow version: | Git master |
Description
when calling flow
on Windows (on the native cmd
shell), the following occurs:
Flow: Invalid root path. (Error #1248964375) "/" does not lead to "C:/Users/afoeder/PhpstormProjects/acme/Distribution/Packages/Framework/TYPO3.Flow/"
Related issues
Associated revisions
[BUGFIX] Flow CLI again works for Windows command prompt
Probably introduced with Ibd70e2dc8ff3a958a33ad0eb422060dc0fd8b799,
the Flow CLI call via the provided .bat file didn't work anymore
because the used ``$_SERVER['PHP_SELF']`` will behave differently
for the flow shell and the flow.bat file: in case of the shell,
the actual ``Scripts/flow.php`` file will be included, while in
case of the .bat file, the ``Scripts/flow.php`` file is immediately
called with PHP. This results in a different PHP_SELF value.
The ``FLOW_ROOTPATH`` value which has to be determined, now is built
manually in case of a ``DIRECTORY_SEPARATOR`` equaling a
Windows one.
Additionally, in order to still allow calling the flow executable
from arbitrary locations also for Windows, the flow.bat file
is adjusted a bit in order to not rely on being at the root
path when calling the file.
Change-Id: Icc55e90ba4aff11efab1e2b8307fdbbe41b35735
Fixes: #44000
Related: #31642
Releases: master, 2.0
[BUGFIX] Flow CLI again works for Windows command prompt
Probably introduced with Ibd70e2dc8ff3a958a33ad0eb422060dc0fd8b799,
the Flow CLI call via the provided .bat file didn't work anymore
because the used ``$_SERVER['PHP_SELF']`` will behave differently
for the flow shell and the flow.bat file: in case of the shell,
the actual ``Scripts/flow.php`` file will be included, while in
case of the .bat file, the ``Scripts/flow.php`` file is immediately
called with PHP. This results in a different PHP_SELF value.
The ``FLOW_ROOTPATH`` value which has to be determined, now is built
manually in case of a ``DIRECTORY_SEPARATOR`` equaling a
Windows one.
Additionally, in order to still allow calling the flow executable
from arbitrary locations also for Windows, the flow.bat file
is adjusted a bit in order to not rely on being at the root
path when calling the file.
Change-Id: Icc55e90ba4aff11efab1e2b8307fdbbe41b35735
Fixes: #44000
Related: #31642
Releases: master, 2.0
[BUGFIX] Flow CLI again works for Windows command prompt
Probably introduced with Ibd70e2dc8ff3a958a33ad0eb422060dc0fd8b799,
the Flow CLI call via the provided .bat file didn't work anymore
because the used ``$_SERVER['PHP_SELF']`` will behave differently
for the flow shell and the flow.bat file: in case of the shell,
the actual ``Scripts/flow.php`` file will be included, while in
case of the .bat file, the ``Scripts/flow.php`` file is immediately
called with PHP. This results in a different PHP_SELF value.
The ``FLOW_ROOTPATH`` value which has to be determined, now is built
manually in case of a ``DIRECTORY_SEPARATOR`` equaling a
Windows one.
Additionally, in order to still allow calling the flow executable
from arbitrary locations also for Windows, the flow.bat file
is adjusted a bit in order to not rely on being at the root
path when calling the file.
Change-Id: Icc55e90ba4aff11efab1e2b8307fdbbe41b35735
Fixes: #44000
Related: #31642
Releases: master, 2.0
History
#1 Updated by Hartmann Andreas over 2 years ago
I happened to get that error right after cloning and doing a composer install, too. In my case the problem was solved after browsing to the flow/welcome page and executing the commands shown there in step 1.
Example:
set FLOW_ROOTPATH=D:\xampp\htdocs\vhostrootdir\Base
#2 Updated by Alexander Berl over 2 years ago
I dug deeper into the cause of this problem (this didn't happen in 1.1) and found the following:
In the Packages\Framework\TYPO3.Flow\Scripts\flow.php file the server variable FLOW_ROOTPATH is set to the dir of the current script unless the FLOW_ROOTPATH environment variable is set:
$_SERVER['FLOW_ROOTPATH'] = trim(getenv('FLOW_ROOTPATH'), '"\' ') ?: dirname($_SERVER['PHP_SELF']);
and since in the bootstrap defineConstants "x/Packages/Framework/TYPO3.Flow/Scripts" (the path of the script) is different from the expected path "x" the exception is thrown.
Solutions:
Change the flow.php line back to pre 2.0 way (not sure of the implications as I don't know why it was changed), ie:
$_SERVER['FLOW_ROOTPATH'] = trim(getenv('FLOW_ROOTPATH'), '"\' ') ?: '';
OR
use the same default as is expected in bootstrap (You must start TYPO3 Flow from the root directory or set the environment variable FLOW_ROOTPATH correctly.), i.e. the cwd:
$_SERVER['FLOW_ROOTPATH'] = trim(getenv('FLOW_ROOTPATH'), '"\' ') ?: getcwd();
#3 Updated by Adrian Föder over 2 years ago
- Status changed from New to Needs Feedback
- Assigned To changed from Adrian Föder to Bastian Waidelich
very good catch Alex, obviously this was introduced exactly with Ibd70e2dc8ff3a958a33ad0eb422060dc0fd8b799 (https://review.typo3.org/#/c/17069/) but has the side effect we encounter here.
Bastian, any ideas for improvements? (I assigned you so far in order to get you notified)
#4 Updated by Adrian Föder over 2 years ago
ahhh too bad; the problematic variable is, as already mentioned, the dirname($_SERVER['PHP_SELF'])
.
I realized that, with "shell use" (i.e. ./flow), $_SERVER['PHP_SELF'] equals "./flow" because the shell file includes the Scripts/flow.php
file.
However, the windows use, flow.bat, just calls the Scripts/flow.php file directly, hence $_SERVER['PHP_SELF'] in that case equals "Packages/Framework/TYPO3.Flow/Scripts/flow.php".
Would there be a way to set some (env variable) in the batch file?
#5 Updated by Adrian Föder over 2 years ago
- Status changed from Needs Feedback to Under Review
Patch set at https://review.typo3.org/#/c/17595/
#6 Updated by Gerrit Code Review over 2 years ago
Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/17595
#7 Updated by Simon Schaufelberger over 2 years ago
looks like people don't test changes properly in windows as well since it had worked as Alexander wrote before.
#8 Updated by Adrian Föder over 2 years ago
Simon, even I, working exclusively via Windows with Flow, didn't realize this stopper for a couple of time; so I would say it actually is tested properly and constantly on Windows; but this exactly well has just been a bad bug ;)
#9 Updated by Gerrit Code Review over 2 years ago
Patch set 5 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/17595
#10 Updated by Gerrit Code Review over 2 years ago
Patch set 6 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/17595
#11 Updated by Gerrit Code Review over 2 years ago
Patch set 7 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/17595
#12 Updated by Adrian Föder over 2 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 6a4c6dfbb624a10fc4c73e37a0c53a63e60979bd.
#13 Updated by Gerrit Code Review over 2 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/19083
#14 Updated by Gerrit Code Review over 2 years ago
Patch set 1 for branch composer has been pushed to the review server.
It is available at https://review.typo3.org/19350
#15 Updated by Adrian Föder over 2 years ago
- Status changed from Under Review to Resolved
Applied in changeset d286114db7ea5a04406d478d52d082330208166c.