Phinx: Error when trying to run init

Created on 20 Nov 2014  路  27Comments  路  Source: cakephp/phinx

platform: windows8
trying to run: php vendor/bin/phinx init
output result:
SRC_DIR="pwd"
cd "dirname "$0""
cd "../robmorgan/phinx/bin"
BIN_TARGET="pwd/phinx"
cd "$SRC_DIR"
"$BIN_TARGET" "$@"

bug

Most helpful comment

I have the same problem on Windows 8.1, the workaround is to run phinx like this:

php vendor/robmorgan/phinx/bin/phinx init

All 27 comments

anyone?

What is the error?

nothing happens when i run init command. i just get in output content of bin/phinx file...

What happens if you execute phinx bin with php?

php path/to/phinx

In command line:

C:\x\php\trunk\project1>php vendor\binphinx
SRC_DIR="pwd"
cd "dirname "$0""
cd "../robmorgan/phinx/bin"
BIN_TARGET="pwd/phinx"
cd "$SRC_DIR"
"$BIN_TARGET" "$@"

C:\x\php\trunk\project1>

That's very strange, I don't have a Windows machine to test on.

I have the same problem on linux, debian6:

root@tll1-mtsdev-web:/home/x/d.ahmarov/laggrigator# php vendor/bin/phinx init
SRC_DIR="pwd"
cd "dirname "$0""
cd "../robmorgan/phinx/bin"
BIN_TARGET="pwd/phinx"
cd "$SRC_DIR"
"$BIN_TARGET" "$@"
root@tll1-mtsdev-web:/home/x/d.ahmarov/laggrigator

I have the same problem on Windows 8.1, the workaround is to run phinx like this:

php vendor/robmorgan/phinx/bin/phinx init

So the problem is with Composer symlinks? I'm not sure this can be resolved by Phinx.

Is this issue still ongoing, or has it been resolved?

vendor\bin\phinx is the unixy shell script.
vendor\bin\phinx.bat is the windows batch script.

Neither of them are PHP scripts, and so, using PHP is not going to do anything here.

If you run vendor\bin\phinx.bat and then SET BIN_TARGET, what output do you get? I am expecting something like BIN_TARGET=C:\wamp\www\******\vendor\bin\/../robmorgan/phinx/bin/phinx

The BIN_TARGET is the PHP script.

You could therefore try php -d error_reporting=-1 %BIN_TARGET%. This should show the normal help screen. If not, what errors/output?

Alternatively, don't run php vendor\bin\phinx init, just vendor\bin\phinx init.

On windows running vendor\binphinx init will result in the same error result
What i found out was just go to the source instead
vendor\robmorganphinx\binphinx
I am on windows 8 right now this works like a charm and just setup a alias for it so you do not have to write all that every single time you want a new migrations.

@avlastenok, Ideally I'd (and probably everyone else) would like to know why your environment is not working with the default setup.

You shouldn't need to do any aliasing.

Could you try the suggestions I made in https://github.com/robmorgan/phinx/issues/360#issuecomment-68865221?

The output you are seeing in your initial question is the output of the unix shell script. Which, for the command you entered, completely appropriate. You ran the PHP interpreter with the unix script. No php exists in the script, so you get the script content as is. All exactly as expected.

But you also say that when you run vendor\bin\phinx init you get the same error. That is very odd.

Of course, you could have a borked install of phinx. Maybe worth just refreshing it.

It's rare that I work on my windows pc, normally I work on my ubuntu work station, also switched back over to that machine and everything is working as expected there.
But with the command: vendor\binphinx init i do get the shell output even after refreshing the installation.

I'm running into the same issue on OSX with php 5.6.8.

Running php vendor/bin/phinx migrate gives me the same output. I'm not running init as it's a project that has already been setup on another box.

vendor\bin\phinx.bat does not exists for me, so I can not run that as mentioned in comment 68865221.

Here's what I've done:

  • Cloned repo from github
  • Run composer install
  • Updating Phinx yml with new db connections
  • Run phinx using php vendor/bin/phinx migrate

Running just ./vendor/bin/phinx migrate gives me this error
./vendor/bin/phinx: line 7: /Users/jwoodcock/code/Tandum.Api_Domain/vendor/robmorgan/phinx/bin/phinx: Permission denied

@jwoodcock,

The phinx.bat file is JUST for windows. No one else. And not even for unixy shells running on Windows. Just windows.

Try sudo vendor/bin/phinx migrate. You've got a permissions issue with your setup.

@shadowhand Close this one as I don't think there is anything else to add.

change the last line in vendor/bin/phinx:
"php" "$BIN_TARGET" "$@"

then exec the command without "php"
$ ./vendor/bin/phinx init

!/usr/bin/env sh

SRC_DIR="pwd"
cd "dirname "$0""
cd 'vendor/robmorgan/phinx/bin'
BIN_TARGET="pwd/phinx"
cd "$SRC_DIR"
"php" "$BIN_TARGET" "$@"

@jwoodcock hey, (how) did you solve this? I'm getting exactly the same problem on a vagrant ubuntu box (laravel homestead) on an OSX host. I really don't get how this can be explained and I've tried lots of solutions already.

@zhanjh Changing code of the package is out of the question.

@markushausammann I believe I did this:

php vendor/robmorgan/phinx/bin/phinx migrate

This skips the bin build and using the php phinx file directory.

@jwoodcock thanks, I did the same, works.

:+1:

windows uses \ as a directory separator, when unix - /. so, to properly call phinx on windows you must call vendor\bin\phinx and everything would be ok

Could it be the lack of a default shell defined in the environment?

For those having the problem, what is the value of sh for the user running phinx?

@dot5enko It is always a surprise when people don't know the difference between \ and / and how PHP "helps" windows users by allowing \ and /, but not unix users. Almost more hassle than it is worth!

What documentation changes would be recommended here?

Not really a bug? Just documentation needed?

Was this page helpful?
0 / 5 - 0 ratings