Repository: gohugoio/hugo (language: go)

Issue:
Panic when importing a jekyll site
### What version of Hugo are you using (`hugo version`)?

<pre>
$ hugo version
hugo v0.97.3-078053a43d746a26aa3d48cf1ec7122ae78a9bb4 linux/amd64 BuildDate=2022-04-18T17:22:19Z VendorInfo=gohugoio
</pre>

### Does this issue reproduce with the latest release?

Yes

---

Trying to import my current blog from jekyll to hugo is causing a panic, and regardless of what pathing I try (absolute, relative, etc), it always occurs.

```
hugo import jekyll ../projects/pondidum.github.io/ ./blog
panic: workingDir is too short

goroutine 1 [running]:
github.com/gohugoio/hugo/hugofs.newFs({0x2554120, 0x35b5940}, {0x2554120?, 0x35b5940}, {0x25547c0, 0xc000964c00})
	/root/project/hugo/hugofs/fs.go:101 +0x4ee
github.com/gohugoio/hugo/hugofs.NewDefault(...)
	/root/project/hugo/hugofs/fs.go:68
github.com/gohugoio/hugo/deps.New({{0x2555a98, 0xc00052c750}, 0x0, 0xc000964c00, {0x0, 0x0}, {0x25547c0, 0xc000964b00}, {0xc00020b000, 0x21, ...}, ...})
	/root/project/hugo/deps/deps.go:226 +0xf8
github.com/gohugoio/hugo/hugolib.configLoader.applyDeps({{0x0, 0x0}, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}}, ...)
	/root/project/hugo/hugolib/hugo_sites.go:517 +0x31e
github.com/gohugoio/hugo/hugolib.newHugoSites({{0x2555a98, 0xc00052c750}, 0x0, 0x0, {0x0, 0x0}, {0x25547c0, 0xc000964b00}, {0x0, 0x0, ...}, ...}, ...)
	/root/project/hugo/hugolib/hugo_sites.go:404 +0x766
github.com/gohugoio/hugo/hugolib.NewHugoSites({{0x2555a98, 0xc00052c750}, 0x0, 0x0, {0x0, 0x0}, {0x25547c0, 0xc000964b00}, {0x0, 0x0, ...}, ...})
	/root/project/hugo/hugolib/hugo_sites.go:553 +0x11d
github.com/gohugoio/hugo/hugolib.NewSiteForCfg(...)
	/root/project/hugo/hugolib/site.go:643
github.com/gohugoio/hugo/hugolib.newSiteForLang(0xc000964b00, {0x0, 0x0, 0x0})
	/root/project/hugo/hugolib/site.go:636 +0x138
github.com/gohugoio/hugo/hugolib.NewSiteDefaultLang({0x0, 0x0, 0x0})
	/root/project/hugo/hugolib/site.go:608 +0x154
github.com/gohugoio/hugo/commands.(*importCmd).createSiteFromJekyll(0xc000042f30?, {0xc000042f00, 0x2a}, {0xc000042f30, 0x21}, 0xb?, 0x0)
	/root/project/hugo/commands/import_jekyll.go:204 +0x67
github.com/gohugoio/hugo/commands.(*importCmd).importFromJekyll(0x8d58c0?, 0xc0008ffd00?, {0xc000555320, 0x0?, 0x0?})
	/root/project/hugo/commands/import_jekyll.go:108 +0x214
github.com/spf13/cobra.(*Command).execute(0xc000435b80, {0xc0005552c0, 0x2, 0x2})
	/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:856 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0xc000957680)
	/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 +0x3b4
github.com/gohugoio/hugo/commands.Execute({0xc00003a0b0, 0x4, 0x4})
	/root/project/hugo/commands/hugo.go:93 +0xb4
main.main()
	/root/project/hugo/main.go:23 +0x57
```


Discussion / hints:
Just checked and the latest version of hugo I could find in a container worked (0.95)
Confirmed. Problem was introduced in v0.97.0.  Git bisect says d070bdf10f14d233288f7318a4e9f7555f070a65 is the first bad commit.

To reproduce:

```
git clone https://gitlab.com/pages/jekyll
hugo import jekyll jekyll/ hugo/
```

I also observed the same issue with jekyll import in Windows. 

In _fs.go_, in the function _func newFs(source, destination afero.Fs, cfg config.Provider) *Fs_, there is a sanity check failing since the _workingDir_ var is not getting initialized properly. From the new code flow, I am not sure whether the sanity check for _workingDir_ is required or not.
Happening on MacOS as well

`hugo version
hugo v0.98.0+extended darwin/arm64 BuildDate=unknown`

```
hugo import jekyll --log  ~/Projects/jekyll ~/Projects/blog
panic: workingDir is too short

goroutine 1 [running]:
github.com/gohugoio/hugo/hugofs.newFs({0x1049c48d8, 0x105a7a480}, {0x1049c48d8?, 0x105a7a480}, {0x1049c4f78, 0x14000670f00})
	github.com/gohugoio/hugo/hugofs/fs.go:101 +0x488
github.com/gohugoio/hugo/hugofs.NewDefault(...)
	github.com/gohugoio/hugo/hugofs/fs.go:68
github.com/gohugoio/hugo/deps.New({{0x1049c5bf8, 0x14000548540}, 0x0, 0x14000670f00, {0x0, 0x0}, {0x1049c4f78, 0x14000670e00}, {0x1400057c000, 0x21, ...}, ...})
	github.com/gohugoio/hugo/deps/deps.go:226 +0xd4
github.com/gohugoio/hugo/hugolib.configLoader.applyDeps({{0x0, 0x0}, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}}, ...)
	github.com/gohugoio/hugo/hugolib/hugo_sites.go:517 +0x224
github.com/gohugoio/hugo/hugolib.newHugoSites({{0x1049c5bf8, 0x14000548540}, 0x0, 0x0, {0x0, 0x0}, {0x1049c4f78, 0x14000670e00}, {0x0, 0x0, ...}, ...}, ...)
	github.com/gohugoio/hugo/hugolib/hugo_sites.go:404 +0x680
github.com/gohugoio/hugo/hugolib.NewHugoSites({{0x1049c5bf8, 0x14000548540}, 0x0, 0x0, {0x0, 0x0}, {0x1049c4f78, 0x14000670e00}, {0x0, 0x0, ...}, ...})
	github.com/gohugoio/hugo/hugolib/hugo_sites.go:553 +0xe0
github.com/gohugoio/hugo/hugolib.NewSiteForCfg(...)
	github.com/gohugoio/hugo/hugolib/site.go:643
github.com/gohugoio/hugo/hugolib.newSiteForLang(0x14000670e00, {0x0, 0x0, 0x0})
	github.com/gohugoio/hugo/hugolib/site.go:636 +0xd4
github.com/gohugoio/hugo/hugolib.NewSiteDefaultLang({0x0, 0x0, 0x0})
	github.com/gohugoio/hugo/hugolib/site.go:608 +0xf4
github.com/gohugoio/hugo/commands.(*importCmd).createSiteFromJekyll(0x16d71b867?, {0x16d71b831, 0x35}, {0x16d71b867, 0x22}, 0x5?, 0x0)
	github.com/gohugoio/hugo/commands/import_jekyll.go:204 +0x48
github.com/gohugoio/hugo/commands.(*importCmd).importFromJekyll(0x14000223200?, 0x102b51870?, {0x1400052bce0, 0x14000955cb8?, 0x0?})
	github.com/gohugoio/hugo/commands/import_jekyll.go:108 +0x19c
github.com/spf13/cobra.(*Command).execute(0x1400065aa00, {0x1400052bcb0, 0x3, 0x3})
	github.com/spf13/cobra@v1.4.0/command.go:856 +0x4c4
github.com/spf13/cobra.(*Command).ExecuteC(0x1400065d400)
	github.com/spf13/cobra@v1.4.0/command.go:974 +0x354
github.com/gohugoio/hugo/commands.Execute({0x1400003c1f0, 0x5, 0x5})
	github.com/gohugoio/hugo/commands/hugo.go:93 +0x98
main.main()
	github.com/gohugoio/hugo/main.go:23 +0x54
```

Fix patch:
diff --git a/commands/import_jekyll.go b/commands/import_jekyll.go
index 232df519c12..91d5c69fe54 100644
--- a/commands/import_jekyll.go
+++ b/commands/import_jekyll.go
@@ -36,7 +36,6 @@ import (
 	"github.com/gohugoio/hugo/common/maps"
 	"github.com/gohugoio/hugo/helpers"
 	"github.com/gohugoio/hugo/hugofs"
-	"github.com/gohugoio/hugo/hugolib"
 	"github.com/gohugoio/hugo/parser"
 	"github.com/spf13/afero"
 	"github.com/spf13/cobra"
@@ -202,12 +201,7 @@ func (i *importCmd) retrieveJekyllPostDir(fs afero.Fs, dir string) (bool, bool)
 }
 
 func (i *importCmd) createSiteFromJekyll(jekyllRoot, targetDir string, jekyllPostDirs map[string]bool, force bool) error {
-	s, err := hugolib.NewSiteDefaultLang()
-	if err != nil {
-		return err
-	}
-
-	fs := s.Fs.Source
+	fs := &afero.OsFs{}
 	if exists, _ := helpers.Exists(targetDir, fs); exists {
 		if isDir, _ := helpers.IsDir(targetDir, fs); !isDir {
 			return errors.New("target path \"" + targetDir + "\" exists but is not a directory")


Test patch: