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

Error: "failed to open stream" #278

Closed
ScarletPonytail opened this issue May 30, 2017 · 16 comments
Closed

Error: "failed to open stream" #278

ScarletPonytail opened this issue May 30, 2017 · 16 comments

Comments

@ScarletPonytail
Copy link

ScarletPonytail commented May 30, 2017

Hello All,

I am getting the following error after following the instructions:

Warning: require_once(wp_bootstrap_navwalker.php): failed to open stream: No such file or directory in D:\sites\aim-hire\wp-content\themes\aim-hire\functions.php on line 375

I can confirm that the 'wp_bootstrap_navwalker.php' is in the root of the theme folder along with the 'functions.php' file.

I am developing locally at the moment, hence the local file path.

Any ideas?

Thanks,
Lisa

@pattonwebz
Copy link
Member

Hey Lisa,

I'm not sure why it can't find the file if it is inside the root of the theme folder. It should be able to see it. Is there maybe a file permissions issue? It's been a very long time since I've developed locally on a windows system so I'm sure exactly the best way to check the permissions on the file however the it should be readable by the user that runs the php process (honestly this might not make sense on a windows system... not sure???).

If your still having this issue come back and let me know and I'll think about other ways to help you diagnose and fix the issue. But also if you found the solution please come back and post it to help others that might have the same problem.

@ImShuvo
Copy link

ImShuvo commented Jul 28, 2017

Same problem here any solution
Warning: require_once(wp_bootstrap_navwalker.php): failed to open stream: No such file or directory in C:\xampp\htdocs\zermatt\wp-content\themes\mytheme\functions.php on line 6

@jurasjo
Copy link

jurasjo commented Jul 28, 2017

Maybe it should be defined like:
require_once(wp-bootstrap-navwalker.php)?

@ImShuvo
Copy link

ImShuvo commented Jul 28, 2017

Still not working & I didn't get any solution yet
That's why i'm now using this way require get_template_directory()

@mavriik
Copy link

mavriik commented Aug 2, 2017

Hey, I am having a similar issue and have been looking all over the place for a solution and still haven't found one. What I have found is that it is a growing issue in which no one has seemed to have posted a repeatable solution.

Fatal error: Class 'WP_Bootstrap_Navwalker' not found in /Applications/XAMPP/xamppfiles/apps/wordpress/htdocs/wp-content/themes/wpbootstrap/header.php on line 35

@pattonwebz
Copy link
Member

Hi everyone, I am seeing a trend here and that all (or many at least) of you seem to be on Windows systems. On windows the paths used in php sound like sometimes they may behave in what looks like a slightly unpredictably way with regards to case sensitivity. The workaround of using get_template_directory() probably grabs the correct path by examining he filesystem but when it relies on environment variable for PATH it may have case sensitivity problems.

If someone who has this error could possibly post the error message they see vs the output of get_template_directory() to see if they have are at all different.

Also trying a require like this might also fix things:

require_once  dirname(__FILE__) . '/wp-bootstrap-navwalker.php';

@pattonwebz
Copy link
Member

Anyone able to confirm for me if there is a difference between the directory shown in the error for them and the directory output by get_template_directory() or dirname(FILE)?

You could add this code to get those recorded in your error logs:

error_log( 'template: ' . get_template_directory(), 0 );
error_log( 'dir: ' . dirname(__FILE__), 0 );
require_once 'wp-bootstrap-navwalker.php';

The 3 values should be in your error log file directly next to each other. If they are different then I will have an avenue to investigate to fix this error, if they are the same then I will have to look for another reason this is not working for you.

@ScarletPonytail
Copy link
Author

Anyone managed to get this working yet?

@pattonwebz
Copy link
Member

Hey @lisawedge,

I think it will work for you if you require the file like this:

require_once get_template_directory() . 'wp-bootstrap-navwalker.php';

It would also be extremely helpful in finally figuring out the root cause of this if you could let me know what values are output from these commands are:

error_log( 'template: ' . get_template_directory(), 0 );
error_log( 'dir: ' . dirname(__FILE__), 0 );

Hope this fixes if for you :)

@ScarletPonytail
Copy link
Author

ScarletPonytail commented Aug 25, 2017

I have made some progress. I am playing with an underscores theme with Bootstrap v4 css and js being called via cdn. Previously I was using Bootstrap v3, perhaps this is a variable? Perhaps not.

But now I'm getting an 'Add a menu' link instead of my menu. Maybe I've referenced the menu incorrectly?

I have a menu called 'main', with the 'Primary' box ticked.

@pattonwebz
Copy link
Member

pattonwebz commented Aug 25, 2017

ohhh that is good progress!! That link comes from the fallback function in the walker so the file is definitely being included now :)

If you click the link you should be able to create a menu and add it to the nav menu you stated in the wp_nav_menu call.

As for using this with bootstrap v4 sadly the master version doesn't work for v4. I've been working on an updated version though that does work for v4: https://github.com/wp-bootstrap/wp-bootstrap-navwalker/tree/v4

Note that the filename has changed in the v4 branch and that the readme may not be fully updated yet to account for any changed classnames.

EDIT: These lines here are how I included it in one of my themes, you should be able to copy any changes from there into your themes code to make them work the same. https://github.com/pattonwebz/best-reloaded-bootstrap-theme/blob/master/header.php#L23-L55

@puertoagp
Copy link

puertoagp commented Aug 30, 2017

I was following the installation instructions from https://wp-bootstrap.github.io/wp-bootstrap-navwalker/ and it turns out they have this line require_once('wp_bootstrap_navwalker.php'); while the actual file name is wp-bootstrap-navwalker.php that's why people like me got this error. I have seen other tutorials with the same mistake so maybe wp_bootstrap_navwalker.php was renamed to wp-bootstrap-navwalker.php at some point in time.

@ScarletPonytail
Copy link
Author

@puertoagp Wow! So simple! I feel silly for not spotting such a simple mistake!

@pattonwebz
Copy link
Member

Yes I too feel very silly for not spotting this... 😆

I completely forgot that instructions page existed and it has not had a real update for anywhere between 3-5 years!

Since a resolution to this issue has been found I will close up this one and open a new one about updating the github pages repo. At least I learned some new things about nuances of php on Windows systems... not that I needed to know about that but... gotta be a silver lining here somewhere, right? :p

@ScarletPonytail
Copy link
Author

Damn! Seems I had already corrected this. Back to the drawing board - still not working for me.

@pattonwebz
Copy link
Member

With no progress posted for a long time I am going to close this issue again for now but as always if you are still having this problem feel free to reopen it or start a new issue and I will do my best to help you out if I can.

Things like error logs and stack traces would be very helpful to figure out what is causing this if it's still a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants