Problem/Motivation
In #2406681: Add an autoload.php in the repo root to control the autoloader of front controllers the syntax for including the Composer Autoloader changed, because of this, when attempting to install Drupal on some Mac systems, you will get an error like this:
Fatal error: Cannot redeclare conf_path() (previously declared in /users/david/sites/test/web/core/includes/bootstrap.inc:143) in /Users/david/sites/test/web/core/includes/bootstrap.inc on line 160
Since /users != /Users the code is being loaded twice.
Proposed resolution
Ensure that the Composer autoloader in ./core/install.php is loaded relative to the current file. Right now it's being loaded relative to the project root which seems to cause this error
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | 2464055_25.patch | 634 bytes | mile23 |
| #5 | redeclare_conf_path-2464055-5.patch | 365 bytes | davidwbarratt |
Comments
Comment #1
afem commentedI am having this same issue: Mac - PHP 5.5.20 & Apache/2.4.10
I just went back and tried drupal 8.0.0-beta7 and I am not getting this issue, so it seems to be a problem with drupal 8.0.0-beta9.
Comment #2
arpieb commentedI'm running into the same thing against 8.0.x HEAD on OSX 10.10, Apache 2.4.10, PHP 5.5.19. Git bisect points to commit 95fe74d57108faea52df0f1f16277a4c4732cbb0 as the culprit, trying to suss through the autoload changes made in that commit.
It appears the redirect from / to /core/install.php is working fine, but that's where it dies. Apparently drush-based installs just work.
Comment #3
arpieb commentedOK, digging a bit more, looks like the same bootstrap.inc file is included using require_once and include_once everywhere, but the paths used to include it are different. Is this possibly causing a problem under certain configurations of PHP?
Comment #4
enginpost commentedI am using Drupal 8 - Beta10 under MAMP (non-pro) on OSX and ran into this issue. To host multiple sites I am manually adding information to my apache vhosts file under MAMP and as well to the hosts file under the OS. Here is something I noticed:
My error says:
PHP Fatal error: Cannot redeclare conf_path() (previously declared in /Users/steve/Documents/Projects/MAMP-sites/epd8.local/core/includes/bootstrap.inc:142) in /Users/steve/Documents/projects/MAMP-sites/epd8.local/core/includes/bootstrap.inc on line 159
Notice what I have bolded above. The word "Project" in the first path has a capital "P" while the second path has a lowercase "p".
My physical path used a lowercase "p"
My apache httpd-vhosts.conf file uses an uppercase "P" when referencing the DocumentRoot and the Directory path.
Editing the physical path to match the path in the vhost file solved the problem. I wonder if the function conf_path (or whatever might replace that function if it is, in fact, being deprecated) could be modified to handle that situation?
Comment #5
davidwbarratt commentedAttached is a patch that should fix the issue for everyone. I'm going to mark this as Major since it prevented me from installing Drupal. Not sure what conditions cause the error and why it doesn't always happen for everyone, but this should fix it for everyone.
Comment #6
davidwbarratt commentedIt looks like this error is specific to Mac OS X. I'm using the built-in Apache/PHP, but it looks like everyone on this thread is using either built-in Apache/PHP or they are using MAMP.
It looks like the work-around is to install with drush #2.
Comment #7
cilefen commentedconf_path() is being removed #2384675: Deprecate conf_path(). Can an affected person please test against 8.0.x now?
Comment #8
davidwbarratt commented#7,
The problem still need to be resolved because the path to the autoloader is wrong (see patch in #5)
Comment #9
davidwbarratt commentedI'm on the latest head and I'm still getting the following error:
Comment #10
davidwbarratt commentedBut like I've said, this issue actually has nothing to do with
conf_path()or the error that is being thrown, it has to do with an incorrectrequirepath.Comment #11
davidwbarratt commentedEven if
conf_path()is removed this error will just report a different function until the patch is committed.Comment #12
davidwbarratt commentedComment #13
davidwbarratt commentedThe change in syntax was introduced in #2406681: Add an autoload.php in the repo root to control the autoloader of front controllers
Comment #14
neclimdulWhile I don't see anything technically wrong with this patch, I'm having trouble figuring out how the autoloader is including bootstrap.inc. Is this error the same one that's still happening?
Comment #15
davidwbarratt commented#14,
Before Patch
Error
Path
realpath('autoload.php');After Patch
No Error
Path
realpath(__DIR__ . '/../autoload.php');At least on the system I am using
require_once 'autoload.php'!=require_once __DIR__ . '/../autoload.php'I'm not sure why fixing this in this place would resolve the error, but it does. I admit that this might be a Apache or PHP configuration problem, but I'm not sure what it is.
Comment #16
mile23So installer.php says this:
And then the patch does this:
So basically we have three things:
cdtocore/.core/.So it's not clear which of these steps is important for installation to work, and which is the result of a loooooong patch-based development cycle. :-)
Comment #17
neclimdulI understand what the change does, just I don't have a case insensitive filesystem to test this on so I'm trying to understand how it fixes the problem.
From what I can tell only 2 places that bootstrap gets included during install are in install.core.inc and in DrupalKernel.php. This matches why we see in #3.
One uses:
the other:
So if we assume __DIR__ resolves correctly, both are built from __DIR__ and should have nothing to do with the autoloader. So how does this change their behavior? :-/
Comment #18
davidwbarratt commented#16,
You need to be cd'd into core for many other reasons than loading the autoloader. So the inline comment is not wrong.
If you don't have a system to reproduce the problem, please don't mark it as "Needs Work" when there is no work to be done. Before the patch, install is borken, after the patch, install is fixed. This patch also passes all other automated tests, and it reverts an early unrelated, unnecessary, overlooked change.
#17,
I can only assume that because this does not have
__DIR__, that that is what messed it up. If you look at #2406681: Add an autoload.php in the repo root to control the autoloader of front controllers you'll see there is a__DIR__before it was removed. Drupal worked before that patch, it broke after it.Comment #19
mile23Well, you see, in my opinion, there was work to be done, so therefore, it needed work.
Whether my opinion is correct or not is another story.
As it turns out, yah, I'm not so correct.
__DIR__is not relative tochdir(), and I must have been thinkinginstall.phpwas under/scriptsfor some reason.I'd try to repro but the OP lacks specifics on how to do that. I have a Mac and use MAMP, but I install using install.php all the time with no ill effects.
I can report that install completed under MAMP with PHP 5.5.10, with the patch.
Comment #20
jason ruyle commentedI run on OSX with default Apache running. Using homebrew to install later version of php.
I ran into this issue as well. I used the patch and now it works.
Run this as part of apache setup:
Comment #21
Anonymous (not verified) commentedThe patch works on
OSX Yosemite 10.10.5
PHP 5.6.10
Apache/2.4.16
Comment #22
justin.cherniak commentedI too can confirm that you are unable to run /install.php on Drupal 8 RC2 when running on Mac OS. The included patch indeed did solve the problem.
Configuration
Mac OS 10.11.1
PHP 5.5.29
Apache 2.4.16
Comment #23
kwadz commentedSame problem on RC3, this patch solves it.
Do you know if this patch will be included in the final release ?
Comment #24
davidwbarratt commentedKwadz,
Please change the status to "Reviewed & Tested by the Community" (RTBC). I still can't explain why this fixes the issue, but it seems to fix it without any side effects.
Comment #25
mile23PHP docs say this:
So we're benefitting from the current working directory having an
autoload.phpfile in it. But that's a brittle anti-pattern, since other search paths could have other files namedautoload.phpwhich might have different purposes.Let's get rid of the magic and make an explicit root path, based on
cwd. This should mean that whatever case the path elements may be, they would be stored in the path string.Here's a patch to do that.
Unfortunately I can't repro the problem so someone will have to manually test.
Comment #26
majorrobot commentedRan into this problem with RC4, working with a fresh version of latest XAMPP (5.6.14). Patch from #25 worked for me. Reasoning and code seem sound.
Configuration
Drupal 8.0.0-rc4
Mac OS 10.8.5
PHP 5.6.14
Apache 2.4.17
Comment #27
PMorris commentedThis is still a problem with Drupal 8.02 release. I get the error when installing in /Applications/MAMP/htdocs/drupal8/
I moved the installation to the root directory / and it works fine now.
OS X 10.9.5
Drupal 8.0.2
Php 5.5.10
Running in a local test environment MAMP 3.0.3 free version.
Comment #28
davidwbarratt commented#27,
Could you try moving it back to the original location and applying the patch? If the patch works for you, could you mark this issue RTBC?
Comment #29
mglamanThis fixed the issue for me when trying to reinstall through the UI on my Mac OS X machines.
Comment #30
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!