Repository: gohugoio/hugo (language: go)

Issue:
readDir broken in 0.93.2 when directories are symlinks/Linux AR>M64
<!-- Please answer these questions before submitting your issue. Thanks! -->

### What version of Hugo are you using (`hugo version`)?

<pre>
$ hugo version 0.93.2
works with 0.93.1 !
</pre>

### Does this issue reproduce with the latest release?
YES

---

Dev on Windows is fine.
Prod on Linux breaks, can not find file or directory

path is assets/etc/apache2   with some copied conf files from /etc
should find apache2.conf 

index.md
```
+++
date        = "2018-11-12T11:50:21+01:00"
description = "Konfiguration Apache2"
title       = "Apache2"
draft       = false
chapter     = 1002
+++

## Apache
{{< linux/shortlist path="apache2" type="conf" >}}

### conf-enabled
{{< linux/shortlist path="apache2/conf-enabled" type="conf">}}

### mods-enabled
{{< linux/shortlist path="apache2/mods-enabled" type="conf">}}

### sites-enabled
{{< linux/shortlist path="apache2/sites-enabled" type="conf">}}

## Let's Encrypt Apache 
{{< linux/shortlist path="letsencrypt/" type="conf">}}

```

shortcode is

```
{{ $path     := .Get "path" }}
{{ $filepath := printf "/assets/etc/%s" $path }}
{{ $files    := readDir $filepath }}
{{ $ext := default "-" (.Get "type" )}}
{{ if (fileExists $filepath)}}
<div class="pa2 mh4 ba">
{{- range $files }}
	{{ if (and (ne (substr .Name 0 1) "_") (not .IsDir)) }}{{ $f := resources.Get (printf "etc/%s/%s" $path .Name)}}
		{{ $e := findRE "\\w+$" .Name }}
		{{ if (or ( eq $ext "-") (in $e $ext) )}}
			<a class="w-auto pr2" href={{$f.Permalink }} type=text/plain rel=nofollow download>{{ .Name }}</a>
		{{end}}
	{{end}}
{{- end }}
</div>
{{end}}

```






Discussion / hints:
@gj52 these files, do they live below the `theme` directory?
The shortcode is in the theme directory.  Theme extract is [here](https://github.com/gj52/HugoSample).
The listed files are in <project dir>/<asset dir>/etc/

If you need to look in my complete activ repo, send me a PM.



@gj52 what I need is something that ... fails, does the "theme extract" fail for you?
Sample does not fail ... mmh I have an idea about  - copied some lines

assets/etc is a symbolic link to /etc  - I want to dokument my production server
all used files have attribute R for everyone, so the user generating the websites can read it all

```
hugo@pi4:~/spielwiese $ cd assets
hugo@pi4:~/spielwiese/assets $ cd etc
hugo@pi4:~/spielwiese/assets/etc $ cd apache2/
hugo@pi4:~/spielwiese/assets/etc/apache2 $ cd conf-enabled/
hugo@pi4:~/spielwiese/assets/etc/apache2/conf-enabled $ ll
total 0
lrwxrwxrwx 1 root root 30 Feb  4 13:42 charset.conf -> ../conf-available/charset.conf
lrwxrwxrwx 1 root root 28 Feb  4 13:57 hints.conf -> ../conf-available/hints.conf
lrwxrwxrwx 1 root root 44 Feb  4 13:42 localized-error-pages.conf -> ../conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root 46 Feb  4 13:42 other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root 31 Feb  4 13:42 security.conf -> ../conf-available/security.conf

hugo@pi4:~/spielwiese/assets/etc/apache2/conf-enabled $ cat charset.conf
# Read the documentation before enabling AddDefaultCharset.
# In general, it is only a good idea if you know that all your files
# have this encoding. It will override any encoding given in the files
# in meta http-equiv or xml encoding tags.

#AddDefaultCharset UTF-8

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
hugo@pi4:~/spielwiese/assets/etc/apache2/conf-enabled $


## ERROR message:

Error: Error building site: "/home/hugo/spielwiese/content/intern/1002_Apache2/index.md:13:1": failed to render shortcode "linux/shortlist": failed to process shortcode: "/home/hugo/spielwiese/themes/photon/layouts/shortcodes/linux/shortlist.html:3:16": execute of template failed: template: shortcodes/linux/shortlist.html:3:16: executing "shortcodes/linux/shortlist.html" at <readDir $filepath>: error calling readDir: failed to read directory "/assets/etc/apache2/conf-enabled": decorate: lstat /assets: no such file or directory
```

maybe the links don't work here

HTH
OK, now I actually understand what's happening. Thanks for the detailed explanation.
OK, I have tried, but I'm not able to reproduce this error. I assume the issue is related to symlinks, but the devil is in the detail, I'm afraid.
OK,

can depend from the specific OS-runtime 

I'm on Linux pi4 5.10.92-v8+ #1514 SMP PREEMPT ...  aarch64 GNU/Linux

Ask, if you need more information.


Fix patch:
diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go
index 04648c25f07..2e32932c66b 100644
--- a/hugolib/filesystems/basefs.go
+++ b/hugolib/filesystems/basefs.go
@@ -68,7 +68,7 @@ type BaseFs struct {
 	// This usually maps to /my-project/public.
 	PublishFs afero.Fs
 
-	// A read-only filesystem from the project workDir (no theme here).
+	// A read-only filesystem starting from the project workDir.
 	WorkDir afero.Fs
 
 	theBigFs *filesystemsCollector
@@ -438,7 +438,9 @@ func NewBase(p *paths.Paths, logger loggers.Logger, options ...func(*BaseFs) err
 
 	publishFs := hugofs.NewBaseFileDecorator(afero.NewBasePathFs(fs.Destination, p.AbsPublishDir))
 	sourceFs := hugofs.NewBaseFileDecorator(afero.NewBasePathFs(fs.Source, p.WorkingDir))
-	workDir := hugofs.NewBaseFileDecorator(afero.NewBasePathFs(afero.NewReadOnlyFs(fs.Source), p.WorkingDir))
+
+	// Same as sourceFs, but no decoration. This is what's used by os.ReadDir etc.
+	workDir := afero.NewBasePathFs(afero.NewReadOnlyFs(fs.Source), p.WorkingDir)
 
 	b := &BaseFs{
 		SourceFs:  sourceFs,


Test patch: