Varnish include can't find file in the same directory

2.2k views Asked by At

In my varnish default.vcl i have the following code:

include "vars.vcl";

When i try to start my varnish i get this error message:

Message from VCC-compiler:
Cannot read file 'vars.vcl': No such file or directory
('input' Line 6 Pos 9)
include "vars.vcl";
--------##########-

Running VCC-compiler failed, exited with 2

VCL compilation failed

The file 'vars.vcl' is in the directory /etc/varnish/ where also the default.vcl is stored. it is a symlink to the actual vars.vcl.

I have no idea why the include won't work, could it be that varnish can't work with symlinks? Why can't it find the file?

3

There are 3 answers

0
Francisco J. Velázquez-G. On

You have to pass the parameter vcl_dir to varnishd. You can test it with:

varnishd -p vcl_dir=/path/to/vars.vcl -C -f default.vcl
0
Thomasleveil On

I had the same issue when upgrading from Varnish 6.5 to 6.6. It is solved with

include "./vars.vcl";
0
RAVI SINGH On

As @francisv mention you have to pass the directory location with -p(parameter)

vcl_dir is deprecated in 6.1.0 version so you have to use vcl_path instead

varnishd -p vcl_path=/path/to/vars.vcl -C -f default.vcl

Just make sure path name should start from / other wise it won't work