GitLab LFS环境下文件存在仍报File not found错误求助
make test Hey there! Let's walk through figuring out why your LFS-tracked file works locally but throws a "File not found" error when running make test on your GitLab server. Since local tests pass, this is almost definitely related to how Git LFS is set up or initialized on the server side. Here are the steps to check:
First, confirm Git LFS is installed on the GitLab server
SSH into your server and rungit lfs version. If you get a "command not found" error, you'll need to install Git LFS first. For example, on Ubuntu/Debian:sudo apt update && sudo apt install git-lfsOn RHEL/CentOS:
sudo yum install git-lfsAfter installation, run
git lfs installto initialize it system-wide.Pull LFS objects manually on the server
Sometimes when cloning a repo on the server, Git doesn't automatically pull LFS files by default. Navigate to your project directory on the server and run:git lfs pullThis will download all LFS-tracked files to the server. After running this, check if the missing file exists with
ls path/to/your/file.Check your GitLab CI/CD configuration (if using CI to run tests)
If you're using GitLab's CI/CD pipeline to executemake test, you need to ensure the pipeline pulls LFS files before running tests. Add a step in your.gitlab-ci.ymlto handle this:before_script: - git lfs pullAlternatively, use
git lfs cloneinstead of the standardgit clonewhen fetching the repo in your CI script.Verify file path consistency
Double-check that the file path referenced in yourMakefilematches exactly with the path on the server. Operating systems like Linux are case-sensitive, so a path like./assets/MyLargeFile.zipon your local machine might be./assets/mylargefile.zipon the server if there was a case mismatch during commit. Usefind . -name "your-filename.ext"on the server to locate the exact path.Check if LFS objects are properly tracked and downloaded
Rungit lfs ls-filesin your server's project directory. Look for your file—if it shows a-instead of a*next to the filename, that means the LFS object hasn't been downloaded. Re-rungit lfs pullto fetch it, or check if the LFS object exists on your GitLab server (you mentioned it's downloadable, so this is less likely, but worth confirming).
Give these steps a try—chances are one of them will fix the "File not found" error. Let me know if you hit any snags!
内容的提问来源于stack exchange,提问作者kushal

