You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to follow the Installation guide from the docs and couldn't get past vendor/bin/phinx init
The Issue I got is:
In Init.php line 146:
The directory "C:\path\to\myrepo" is not writable
init [-f|--format FORMAT] [--] [<path>]
What I tried
After looking at line 146: if (!is_writable($dirname)) {
I separately tested the is_writable() method in php php -r "echo is_writable('C:\\path\\to\\myrepo') ? 'Writable' : 'Not writable';"
and the result was Not writable.
Then I tested creating a file and writing into it with php php -r "if(file_put_contents('C:\\path\\to\\myrepo\\phpwritten.txt','test')) { echo 'Success'; } else { echo 'Error';
and it worked.
After some testing I found out the Onedrive part is making the is_writable() method return false. C:\Users\myuser\OneDrive - company\myrepo
Workaround
After using a path without OneDrive in it everything worked.
Also removing line 146 lead to a successful creation of the phinx.php file
Maybe there is a way to fix this or add a note in the docs like in #116 ?
The text was updated successfully, but these errors were encountered:
Thanks for the report. I think the solution here is to remove the check and then just rely on file_put_contents failing for really deciding if something isn't writable or not, maybe doing something like:
if (file_put_contents($path, $contents) === false) {
thrownewRuntimeException(!is_writable($dirname) ? sprintf(
'The directory "%s" is not writable',
$dirname
) : sprintf(
'The file "%s" could not be written to',
$path
));
}
I doubt there should ever be a case where file_put_contents(...) works while !is_writable($dirname) where we're fine still doing the write regardless. I think having the error message around !is_writable($dirname) is still useful though, hence the ternary within the conditional.
If you want to make a PR, happy to look it over, otherwise I'll try to get something done next week sometime.
Problem
I tried to follow the Installation guide from the docs and couldn't get past
vendor/bin/phinx init
The Issue I got is:
What I tried
After looking at line 146:
if (!is_writable($dirname)) {
I separately tested the is_writable() method in php
php -r "echo is_writable('C:\\path\\to\\myrepo') ? 'Writable' : 'Not writable';"
and the result was Not writable.
Then I tested creating a file and writing into it with php
php -r "if(file_put_contents('C:\\path\\to\\myrepo\\phpwritten.txt','test')) { echo 'Success'; } else { echo 'Error';
and it worked.
After some testing I found out the Onedrive part is making the is_writable() method return false.
C:\Users\myuser\OneDrive - company\myrepo
Workaround
After using a path without OneDrive in it everything worked.
Also removing line 146 lead to a successful creation of the phinx.php file
Maybe there is a way to fix this or add a note in the docs like in #116 ?
The text was updated successfully, but these errors were encountered: