-
Notifications
You must be signed in to change notification settings - Fork 278
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
cue/load: Loader does not ignore irregular files #1672
Comments
Load should skip symlinks and other irregular files. closes cue-lang#1672
I'm curious if this change would impact those who use symlinks in
I wonder if the changes to how |
In my testing, it appears the package loading behavior for cue.mod/pkg/... is different than the module loading behavior for the current module. For example, I don't think this symlink issue occurs if I import a package with a non-existing symlink to a file. I have tried so many variations attempting to find out exactly how to reproduce this error, I've lost track. My initial solution was to ignore a symlink to a file that did not exist. How to handle symlinks is certainly a worthy topic of discussion. But, other irregular files most certainly should be ignored. |
I was somewhat surprised the cue fmt caused the entire module to load. I don't know whether this is justified or not. I also believe this error will happen for eval as well. So, it's not just a fmt issue. Confirmed. Fails on eval also. |
For what it's worth, I know that cue complains about hidden files in some cases. The behavior with this part of the loader however is not consistent. It will gladly reference hidden files, so, actually ignoring hidden files would also be a proper solution to my problem. I would agree that a well-behaved *nix application would honor symlinks, even if I wouldn't use them here. So, perhaps the real issue is that hidden files are not ignored here. cat <<EOF | testscript -
I believe the above mention of "filename starts with a '.'" is just a warning. |
- Ignore symlinks whose targets cannot be stat'd - Ignore sockets, devices, etc. Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 1 Letterman Drive Suite D4700 San Francisco, CA, 94129 Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. closes cue-lang#1672 Signed-off-by: Kevin Burge <kcburge@pm.me>
submitted an alternate implementation that preserves symlink capability |
- Ignore symlinks whose targets cannot be stat'd - Ignore sockets, devices, etc. closes cue-lang#1672 Signed-off-by: Kevin Burge <kcburge@pm.me>
- Ignore missing symlinks, - Fail on symlinks that cannot be stat'd - Only process directories and regular files closes cue-lang#1672 Signed-off-by: Kevin Burge <kcburge@pm.me>
I believe the correct behavior is to only consider files and directories and symlinks to files and directories that exist. If a symlink cannot be stat'd, an error should return, just like directories that cannot be read. Updated my pull request to do this. |
- Ignore missing symlinks, - Fail on symlinks that cannot be stat'd - Only process directories and regular files closes cue-lang#1672 Signed-off-by: Kevin Burge <kcburge@pm.me>
I'm not clear why |
Please can you explain why this is your expectation with respect to symlinks? |
Crucial edit in my previous reply :) |
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
YES
What did you do?
Using Emacs to edit my cue files, running cue fmt on save, I kept getting a file didn't exist error. (Emacs saves a symlink in the working directory to a non-existing file, as a locking mechanism). This was causing cue fmt to fail with "no such file or directory".
It could also be argued that cue should ignore files that are hidden. This symlink was a hidden file, but cue attempted to read it.
What did you expect to see?
I expect that the cue loader would:
What did you see instead?
cue failed loading a symlink to a file that did not exist.
Test
cat <<EOF | testscript -
exec ln -s not-found .link.cue
exec cue fmt in.cue
-- cue.mod/module.cue --
module: "example.org/test"
-- sub/sub.cue --
package sub
-- in.cue --
import "example.org/test/sub"
EOF
The text was updated successfully, but these errors were encountered: