16

I have a few invisible characters (�) that appear at the end of a javascript document that cause the "illegal character" error in FF or Chrome. I saw different topics about this error, but nothing works for me, and i can't see anything wrong in my document (displaying invisible characters, open it with a hexadecimal editor). This is just driving me crazy. I use Vagrant with a nginx web server. The document looks clear in the server too (vi + :set list).

Plus, when I get back a clear document from my Git repository, everything works(normal). But each time I want to edit it (like create a new variable at the top of document), I got this error again.

If someone can helps me, thank you.

Max
  • 774
  • 7
  • 20

2 Answers2

19

If you're using the VirtualBox provider, then VirtualBox shared folders are the default synced folder type. These synced folders use the VirtualBox shared folder system to sync file changes from the guest to the host and vice versa.

There is a VirtualBox bug related to sendfile which can result in corrupted or non-updating files. You should deactivate sendfile in any web servers you may be running.

In Nginx:

sendfile off;

In Apache:

EnableSendfile Off

See vagrant docs: http://docs.vagrantup.com/v2/synced-folders/virtualbox.html

crash
  • 321
  • 2
  • 4
  • 2
    This answer is more related to real origin of a problem. Solution from accepted answer is just escape to another sharing mechanism which is not always accesible (like in my case). Thank you! – oxfn Nov 15 '15 at 19:54
8

It seems that you're using Vagrant.. please take a look at your _Vagrantfile and check the way files are written on the VM filesystem.

cat ~/.vagrant.d/boxes/[YOUR VM NAME]/include/_Vagrantfile

Maybe you are using config.vm.synced_folder try to use NFS:

config.vm.synced_folder "/home/myuser/shared", ".", :nfs => true 
  • 1
    Thanks a lot Guillaume. The problem was with the shared folder. Since I have activated the nfs I don't have any invisible characters anymore. – Max Jun 25 '13 at 21:07
  • 1
    I have tried adding nfs but still no good, is there any other way? – Hoang Lam May 30 '14 at 02:53