Hello Nigko. I believe that it is natural to think local-file were the right procedure to use, and it could be used with relative path. Your work-around puts in an absolute path, which perhaps really is what we should put in the cookbook and guile-channel and blog post.
If a relative path is bad, we should warn against `local-file' with relative paths in the manual and cookbook, and not just change the example. Or yet rather make a change to `local-file' so calling it with "../.." relative paths is treated right in all cases. Your diff makes it right in more cases. I believe `local-file' already is symlink-resolving in most cases: Nigko Yerden <nigko.yer...@gmail.com> writes: > pelzflorian (Florian Pelz) wrote: >> But then again, the current current-source-directory >> already does follow symlinks in nearly all cases, even in configuration >> files > Don't see it neither in the code nor in our examples. 'syntax-source' doesn't > do this. The second branch of 'if' in 'absolute-dirname' bringing in > 'canonicalize-path' is never executed in the examples (remember, the original > patch didn't work because of this). > >> but actually I do not know why `local-file', when >> calling `absolute-dirname', takes this case of `if'. > Only the first branch of 'if' is executed in all practical cases I can > imagine. While processing guile-package.scm, (search-path %load-path "guile-package.scm") returns an absolute path if and only if guile-package.scm is in the load-path, like when using it from a channel. Then, your diff makes it resolve symlinks. If the configuration or package file is not in the load-path, guile-package.scm is returned, absolute-dirname’s other `if' branch calls `canonicalize-path' on all but the basename and directory symlinks already got resolved. Do I misunderstand? I think symlinks are followed by design here. (I wonder if such non-channel evaluation might cause problems when a non-channel scheme file has the same name as a file in a channel. This might be a rationale for never using local-file with relative paths.) In a guix repl evaluating a file at a path with symlinks, containing a call to the built-in pk procedure on (current-source-directory), (let ((f (open-input-file "/tmp/a/b/c/a/b/c/d.scm"))) (eval (read f) (interaction-environment)) (eval (read f) (interaction-environment)) (eval (read f) (interaction-environment)) (eval (read f) (interaction-environment)) ) all unnecessary path components remain, no symlinks are resolved and absolute-dirname is not called at all. This weird usage is unlike guix home/system reconfigure or what normal people do. >> Why does current-source-directory use syntax-source? > What can it use instead? Related syntaxes such as > 'current-source-location' and 'current-filename' are all using > 'syntax-source' under the hood. `current-module' from your work-around does not use syntax-source, but outside modules cannot replace more powerful current-source-directory. Regards, Florian