Symbolic link in the path to current directory #69

Closed
opened 9 years ago by kirelagin · 2 comments
kirelagin commented 9 years ago (Migrated from github.com)
$ raco pollen render test.html.pm
Rendering /run/user/1000/tmpdir/test/test.html.pm /home/kirrun/tmp/test/test.html.pm
render: test.html.pm
cpu time: 396 real time: 396 gc time: 119
render: test.html.pm
include-at/relative-to/reader: can't open include file (open-input-file: cannot open input file
  path: /home/kirrun/tmp/test/../../.racket/6.1.1/pkgs/pollen/server-extras/fallback.html
  system error: No such file or directory; errno=2)
  at: #<path:/home/kirrun/tmp/test/../../.racket/6.1.1/pkgs/pollen/server-extras/fallback.html>
  in: (include-at/relative-to/reader (file "../../.racket/6.1.1/pkgs/pollen/server-extras/fallback.html") (file "../../.racket/6.1.1/pkgs/pollen/server-extras/fallback.html") (file "../../.racket/6.1.1/pkgs/pollen/server-extras/fallback.html") (let ((xs #f) (...
  context...:
   /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/collects/racket/private/more-scheme.rkt:162:2: select-handler/no-breaks
   /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/collects/racket/include.rkt:13:0
   /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/pkgs/scribble-text-lib/scribble/text/syntax-utils.rkt:72:0
   /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/pkgs/scribble-text-lib/scribble/text/syntax-utils.rkt:121:2: loop
   /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/pkgs/scribble-text-lib/scribble/text/syntax-utils.rkt:148:0
   core225
   render-to-file
   unpack62
   loop
   (submod /home/kirrun/.racket/6.1.1/pkgs/pollen/command.rkt raco): [running body]
   /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/collects/raco/raco.rkt: [running body]
   /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/collects/raco/main.rkt: [running body]

The problem is that it is trying to include the fallback template using a relative path and that fails, because ~/tmp is a symlink:

$ pwd
/home/kirrun/tmp/test

$ readlink -f $(pwd)
/run/user/1000/tmpdir/test

Relative paths should be relative to whatever was used initially to produce those relative paths, and it seems to be relative to the completely dereferenced file name.

``` Console $ raco pollen render test.html.pm Rendering /run/user/1000/tmpdir/test/test.html.pm /home/kirrun/tmp/test/test.html.pm render: test.html.pm cpu time: 396 real time: 396 gc time: 119 render: test.html.pm include-at/relative-to/reader: can't open include file (open-input-file: cannot open input file path: /home/kirrun/tmp/test/../../.racket/6.1.1/pkgs/pollen/server-extras/fallback.html system error: No such file or directory; errno=2) at: #<path:/home/kirrun/tmp/test/../../.racket/6.1.1/pkgs/pollen/server-extras/fallback.html> in: (include-at/relative-to/reader (file "../../.racket/6.1.1/pkgs/pollen/server-extras/fallback.html") (file "../../.racket/6.1.1/pkgs/pollen/server-extras/fallback.html") (file "../../.racket/6.1.1/pkgs/pollen/server-extras/fallback.html") (let ((xs #f) (... context...: /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/collects/racket/private/more-scheme.rkt:162:2: select-handler/no-breaks /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/collects/racket/include.rkt:13:0 /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/pkgs/scribble-text-lib/scribble/text/syntax-utils.rkt:72:0 /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/pkgs/scribble-text-lib/scribble/text/syntax-utils.rkt:121:2: loop /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/pkgs/scribble-text-lib/scribble/text/syntax-utils.rkt:148:0 core225 render-to-file unpack62 loop (submod /home/kirrun/.racket/6.1.1/pkgs/pollen/command.rkt raco): [running body] /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/collects/raco/raco.rkt: [running body] /nix/store/dzk1a00x1qv3pbzg3qway2bi7rzmfy5f-racket-6.1.1/share/racket/collects/raco/main.rkt: [running body] ``` The problem is that it is trying to include the fallback template using a relative path and that fails, because `~/tmp` is a symlink: ``` Console $ pwd /home/kirrun/tmp/test $ readlink -f $(pwd) /run/user/1000/tmpdir/test ``` Relative paths should be relative to whatever was used initially to produce those relative paths, and it seems to be relative to the completely dereferenced file name.
mbutterick commented 9 years ago (Migrated from github.com)

I do see a bug here, though maybe different than what you describe. raco pollen render is trying to render both the deferenced symlink path (/run/user/1000/tmpdir/test/test.html.pm) and the raw symlink path (/home/kirrun/tmp/test/test.html.pm). The first one actually works; the second one fails.

This was because of an off-by-one error in raco pollen render which I’ve now fixed.

I do see a bug here, though maybe different than what you describe. `raco pollen render` is trying to render both the deferenced symlink path (`/run/user/1000/tmpdir/test/test.html.pm`) and the raw symlink path (`/home/kirrun/tmp/test/test.html.pm`). The first one actually works; the second one fails. This was because of an off-by-one error in `raco pollen render` which [I’ve now fixed](https://github.com/mbutterick/pollen/commit/ee059bbc83f10e50248abc60547e8bdba2ffadc0).
kirelagin commented 9 years ago (Migrated from github.com)

Ah, I thought it did output the file name before and after dereferencing for informational purposes.

Now I see that the output is actually produced before it fails. Good to know that it’s fixed now.

Ah, I thought it did output the file name before and after dereferencing for informational purposes. Now I see that the output is actually produced before it fails. Good to know that it’s fixed now.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#69
Loading…
There is no content yet.