Getting "File does not exist" for sqlFile that DOES exist

This is baffling me. I have been using liquibase for the past couple of years, and nothing like this has ever happened before. I have a changeset that uses a sqlFile; all of a sudden it (and similar changesets) won’t work - it fails with “File does not exist”. But the file DOES exist.
Eg see screenshot

Also if I knock up a simple Java program:
.filter(path->path.getFileName().toString().endsWith(“sql”)).forEach(path -> System.out.println(path + “>>” + path.toFile().canRead()));
I get the output


I cannot see what the liquibase source code is doing here. But I already spent half a day on this yesterday and it’s driving me mad. I need to figure out what’s causing it.

What version of Liquibase are you using when you see this happen?

I’ve seen it happen when we change versions of Liquibase (we’re running with the Maven plugin). We can have code that runs fine and all the files are found, then we change the version, and those same files are no longer found. I’m wondering if maybe you’re running into the same thing.

I haven’t changed the version, but in any case it’s 3.5.3.


Sorry, I thought maybe that could explain it, but obviously not if you’ve run nothing but 3.5.3 - which has always been stable from our use when it comes to finding files. Not sure what’s messing with the path Liquibase is looking for the files in.

Do you let Liquibase find the files in the classpath, or do you set relativeToChangelogFile to true for these changeSets?

I set relativeToChangeLog=“true”

<sqlFile encoding="utf8"

I can hardly believe this is happening - I’ve just spent another hour or so fiddling around, changing file names etc (eg test.sql without an enclosing directory), and nothing I do can make liquibase not fail with the same exception every time:

Caused by: File does not exist: ‘test1.sql’", “at liquibase.change.core.SQLFileChange.openSqlStream(”, "at liquibase.change.AbstractSQLChange.generateCheckSum(

I have tried looking at/for that source code online but what I found did not help in anyway to explain the mystery. I suppose it must be in a jar somewhere on my classpath so maybe that’s the next place to look.

This makes no sense.

This is the way it’s behaved for us when we’ve seen it happen - always use relativeToChangeLog=true, & if Liquibase couldn’t find the file, there was nothing we could do to get it to find the file, & we could never understand why. We’d just go back to the version of Liquibase that worked.

Sorry I couldn’t be more help, other than I’ve been there.

Your sample changeset references a file called functions/f_bet_search_without_tz.sql but the error is referencing a file called test1.sql

Are you looking at the right changeset?

On the contrary Selena, thanks for letting me know that you’ve seen such a thing yourself before.

That (test1.sql) was just me trying a different file name. Of course I changed the file in the changeset accordingly.
Strange thing is (in case I didn’t mention it before) none of my team members has the same issue.

Something I think I didn’t mention before: I created the original changeset, and when I had been struggling for an hour to get it to work, I asked my boss to check out my commit, and to try to run it, and he said it ran fine. Then I asked another team member, and she said it ran fine for her. And nobody else in the backend team has reported the same issue.
I have even completely deleted the containing repo and cloned it again from git, and the issue still persists.

Just a quick update on this - I’ve figured out why liquibase can’t see the files: it’s because of file permissions. There’s a script that pulls files from a git repo into the directory that liquibase is reading. For some reason it started creating files with 600 permissions (rw- --- ---). I cannot figure out why - I’m looking at umask and it’s set to 0002 or 022 depending on whether the user is sudo or not. AFAIK it would take a 077 umask to create files with 600 permissions. But anyway clearly the reason why liquibase can’t see the files is because of permissions. For now, I’m just executing a
sudo chmod -R 644 *
in the containing directory and that has allowed the liquibase script to complete successfully.
Thanks for your time.

1 Like