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

shared folder problem #351

Closed
till opened this Issue May 4, 2011 · 26 comments

Comments

Projects
None yet
@till
Contributor

till commented May 4, 2011

We've run into weird inconsistency issues with shared folders.

This is the configuration in Vagrantfile:

config.vm.share_folder("v-data", "/vagrant_data", "~/project")

When I edit a file on the share -- either by vagrant ssh into the VM and editing directly, or on the host system -- I can see the change done to a file when I cat foo, etc.. However, it gets tricky when this file is a static asset served by nginx. So no matter what I do, the state of the file is not refreshed and the content delivered is the same as when I started the VM (vagrant up). To refresh the file I have to either rename it permanently, or vagrant destroy && vagrant up.

My nginx configuration is pretty generic. The reason why I rule out nginx is, that I ran into someone with the same issue, and he's using a share_folder in Vagrant as well.

I found this issue in 0.6.9 and also 0.7.3.

Supposedly this works better when an NFS export is used. I'm testing this next.

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh May 12, 2011

Member

This same thing has happened to me. OH GOD, this is so frustrating.

I'm going to ask a co-worker how we fixed this tomorrow (if we even did). This was so dumb.

Member

mitchellh commented May 12, 2011

This same thing has happened to me. OH GOD, this is so frustrating.

I'm going to ask a co-worker how we fixed this tomorrow (if we even did). This was so dumb.

@till

This comment has been minimized.

Show comment
Hide comment
@till

till May 12, 2011

Contributor

We fixed it using NFS.

On Ubuntu: aptitude install nfs-common

This has to be done both on the host and in your box. Since you can't do it via provisioning, you may have to re-package the box.

Contributor

till commented May 12, 2011

We fixed it using NFS.

On Ubuntu: aptitude install nfs-common

This has to be done both on the host and in your box. Since you can't do it via provisioning, you may have to re-package the box.

@till

This comment has been minimized.

Show comment
Hide comment
@till

till May 20, 2011

Contributor

@mitchellh Any idea yet?

Contributor

till commented May 20, 2011

@mitchellh Any idea yet?

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Jun 10, 2011

Member

@till:

Yes, this has been solved. This is due to a bug/issue with the sendfile syscall that servers typically use to serve static files. The easiest thing to do is add this configuration option to Apache:

EnableSendfile Off

Or if you use nginx:

sendfile off;

Yay!

Member

mitchellh commented Jun 10, 2011

@till:

Yes, this has been solved. This is due to a bug/issue with the sendfile syscall that servers typically use to serve static files. The easiest thing to do is add this configuration option to Apache:

EnableSendfile Off

Or if you use nginx:

sendfile off;

Yay!

@mitchellh mitchellh closed this Jun 10, 2011

@till

This comment has been minimized.

Show comment
Hide comment
@till

till Jun 10, 2011

Contributor

Ah, is this solvable in vagrant too, or is this something virtualbox has to fix?

Contributor

till commented Jun 10, 2011

Ah, is this solvable in vagrant too, or is this something virtualbox has to fix?

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Jun 13, 2011

Member

This is something VirtualBox has to fix, unfortunately. For now, please use the proper configuration option for your servers.

Member

mitchellh commented Jun 13, 2011

This is something VirtualBox has to fix, unfortunately. For now, please use the proper configuration option for your servers.

@till

This comment has been minimized.

Show comment
Hide comment
@till

till Jun 13, 2011

Contributor

Ok, just wanted to be sure.

Sorry to keep asking questions, but any idea if they are tracking this?

Contributor

till commented Jun 13, 2011

Ok, just wanted to be sure.

Sorry to keep asking questions, but any idea if they are tracking this?

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Jun 13, 2011

Member

till,

I wasn't able to find any tickets...

Mitchell

Member

mitchellh commented Jun 13, 2011

till,

I wasn't able to find any tickets...

Mitchell

@till

This comment has been minimized.

Show comment
Hide comment
@till

till Jun 13, 2011

Contributor

Adding a link for completeness: http://www.virtualbox.org/ticket/9069

Contributor

till commented Jun 13, 2011

Adding a link for completeness: http://www.virtualbox.org/ticket/9069

@markjaquith

This comment has been minimized.

Show comment
Hide comment
@markjaquith

markjaquith Sep 25, 2012

Contributor

I lost a ████ing hour and a half to this nonsense. Any thoughts on how this could be automatically detected? A scan of /etc/nginx.conf for sendfile on; (and the same for Apache), resulting in a warning on vagrant up?

Contributor

markjaquith commented Sep 25, 2012

I lost a ████ing hour and a half to this nonsense. Any thoughts on how this could be automatically detected? A scan of /etc/nginx.conf for sendfile on; (and the same for Apache), resulting in a warning on vagrant up?

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Sep 25, 2012

Member

I'd be a bit worried that Vagrant scanning nginx or apache configs would be doing too much. There are various ways that this could surface, and it really is up to VirtualBox to fix this issue. I realize it is frustrating (I too spent hours until I stumbled upon the answer), but I think that adding this to Vagrant would not be correct.

Member

mitchellh commented Sep 25, 2012

I'd be a bit worried that Vagrant scanning nginx or apache configs would be doing too much. There are various ways that this could surface, and it really is up to VirtualBox to fix this issue. I realize it is frustrating (I too spent hours until I stumbled upon the answer), but I think that adding this to Vagrant would not be correct.

@markjaquith

This comment has been minimized.

Show comment
Hide comment
Contributor

markjaquith commented Sep 25, 2012

Sure, I understand. How about some documentation? Two good places:

http://vagrantup.com/v1/docs/config/vm/share_folder.html
http://vagrantup.com/v1/docs/troubleshooting.html

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Sep 25, 2012

Member

I think the shared folder documentation would be a good place to put a warning. The docs are open source in the docs branch if you'd like to make a pull request, otherwise I can add it when I can get to it.

Member

mitchellh commented Sep 25, 2012

I think the shared folder documentation would be a good place to put a warning. The docs are open source in the docs branch if you'd like to make a pull request, otherwise I can add it when I can get to it.

@markjaquith

This comment has been minimized.

Show comment
Hide comment
@markjaquith

markjaquith Sep 25, 2012

Contributor

PR'd: #1154

Contributor

markjaquith commented Sep 25, 2012

PR'd: #1154

@pesterhazy

This comment has been minimized.

Show comment
Hide comment
@pesterhazy

pesterhazy Dec 5, 2013

The bug in VirtualBox still seems to be present, but in the new documentation for synced_folders the note about sendfile seems to have been dropped.

The bug in VirtualBox still seems to be present, but in the new documentation for synced_folders the note about sendfile seems to have been dropped.

@spencerdeinum

This comment has been minimized.

Show comment
Hide comment
@spencerdeinum

spencerdeinum Dec 18, 2013

@mitchellh Would it be possible to put a blurb about this in the new docs? I noticed it is in the v1 documentation but missing from the new docs.

Just spent a few hours banging my head against the wall here as well.

@mitchellh Would it be possible to put a blurb about this in the new docs? I noticed it is in the v1 documentation but missing from the new docs.

Just spent a few hours banging my head against the wall here as well.

swalkinshaw added a commit to roots/trellis that referenced this issue May 3, 2014

Turn off sendfile in development
Virtualbox has a bug that could cause static files to not update and
seem cached. References:

* http://wiki.nginx.org/Pitfalls (Virtualbox section)
* http://jeremyfelt.com/code/2013/01/08/clear-nginx-cache-in-vagrant/
* hashicorp/vagrant#351 (comment)

pvoznenko added a commit to pvoznenko/Vagrant-CentOS-6.4-Puppet-Base-Repository that referenced this issue May 10, 2014

Added 'sendfile off' to nginx config
because vagrant inherit bug from virtualbox regarding shared folders
in some point it could corrupt files. When you change a file on/in a shared folder,
the change is not seen when through a webserver (e.g. nginx).
for more info: hashicorp/vagrant#351 (comment)
ticket at VB: https://www.virtualbox.org/ticket/9069
@CleanCut

This comment has been minimized.

Show comment
Hide comment
@CleanCut

CleanCut Dec 12, 2014

There is another VirtualBox ticket here for this same issue. It all seems to be being ignored. :-(

https://www.virtualbox.org/ticket/12597

There is another VirtualBox ticket here for this same issue. It all seems to be being ignored. :-(

https://www.virtualbox.org/ticket/12597

@AmazingDreams

This comment has been minimized.

Show comment
Hide comment
@AmazingDreams

AmazingDreams Jan 5, 2015

I had the same issue and tried NFS. NFS possibly corrupted my git index. I had an error similar to this: http://stackoverflow.com/questions/4254389/git-corrupt-loose-object

Not sure where it came from exactly as I just booted up to find that error, though this coincides with the first time I used NFS.

I had the same issue and tried NFS. NFS possibly corrupted my git index. I had an error similar to this: http://stackoverflow.com/questions/4254389/git-corrupt-loose-object

Not sure where it came from exactly as I just booted up to find that error, though this coincides with the first time I used NFS.

@KrunoKnego

This comment has been minimized.

Show comment
Hide comment
@KrunoKnego

KrunoKnego Mar 9, 2015

Please add the information about Virtualbox send file bug on: http://docs.vagrantup.com/v2/synced-folders/nfs.html.

Please add the information about Virtualbox send file bug on: http://docs.vagrantup.com/v2/synced-folders/nfs.html.

@zhangjingjing2020

This comment has been minimized.

Show comment
Hide comment
@lordgiotto

This comment has been minimized.

Show comment
Hide comment
@lordgiotto

lordgiotto Oct 27, 2015

Still no solution for this bug? I need to use x-sendfile module in my project and EnableSendfile on is mandatory :|

Still no solution for this bug? I need to use x-sendfile module in my project and EnableSendfile on is mandatory :|

@TajPelc

This comment has been minimized.

Show comment
Hide comment
@TajPelc

TajPelc Nov 10, 2015

If I add "sendfile off;" to my config the consistency issues are solved, but page loads where a lot of static files are served become extremely slow. They go from 1s to 12s. Has anyone else had the same problem?

TajPelc commented Nov 10, 2015

If I add "sendfile off;" to my config the consistency issues are solved, but page loads where a lot of static files are served become extremely slow. They go from 1s to 12s. Has anyone else had the same problem?

@CleanCut

This comment has been minimized.

Show comment
Hide comment
@CleanCut

CleanCut Nov 10, 2015

sendfile is a feature to speed things up, and it's broken, so it's pretty normal that things slow down (but work correctly) when you turn it off, although it wasn't as extreme a slowdown for me as it was for you. I found it very interesting that performance increased a ton when I upgraded from boot2docker 1.7 to boot2docker 1.8. Boot2docker bundles their own version of VirtualBox, so I'm wondering if there was something changed there that affected things.

sendfile is a feature to speed things up, and it's broken, so it's pretty normal that things slow down (but work correctly) when you turn it off, although it wasn't as extreme a slowdown for me as it was for you. I found it very interesting that performance increased a ton when I upgraded from boot2docker 1.7 to boot2docker 1.8. Boot2docker bundles their own version of VirtualBox, so I'm wondering if there was something changed there that affected things.

goodguyry added a commit to goodguyry/dreambox that referenced this issue May 15, 2016

goodguyry added a commit to goodguyry/dreambox that referenced this issue May 17, 2016

Version 0.1.1
- Added a Dreambox Message of the Day (motd)
- Fixed an issue preventing sites from displaying when accessed via IP address
- Added compiled package files
- Cleaned up documentation (more to come...)
- Disabled Sendfile [hashicorp/vagrant#351 (comment)](hashicorp/vagrant#351 (comment))
- Fixed broken MySQL build script
- Restructured source files and development workflow
- Fixed PROJECT_ROOT variable used by `user_setup`
- Updated broken package source URLs
- Enabled and loaded shared Apache modules
@gnulnx

This comment has been minimized.

Show comment
Hide comment
@gnulnx

gnulnx Feb 12, 2018

I know this is closed, but non of these fixed my issue. Turns out I also had to update gunicorn to not use sendfile.

#7163

gnulnx commented Feb 12, 2018

I know this is closed, but non of these fixed my issue. Turns out I also had to update gunicorn to not use sendfile.

#7163

@criscola

This comment has been minimized.

Show comment
Hide comment
@criscola

criscola Mar 22, 2018

This is far from being a solved issue. I'm running a Golang webserver using Vagrant, modified a .css file but the changes are not visible until doing a vagrant destroy. If a try to do the same action on a vmware virtual machine, everything is working fine. I went crazy for hours because of this problem... I still have to find a working solution as the only solution I found are related to apache or nginx (which I don't use). The weirdest thing is that if I cat my file, I can see them modified, but not if I try to access through the webserver...

This is far from being a solved issue. I'm running a Golang webserver using Vagrant, modified a .css file but the changes are not visible until doing a vagrant destroy. If a try to do the same action on a vmware virtual machine, everything is working fine. I went crazy for hours because of this problem... I still have to find a working solution as the only solution I found are related to apache or nginx (which I don't use). The weirdest thing is that if I cat my file, I can see them modified, but not if I try to access through the webserver...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment