google / docsy

A set of Hugo doc templates for launching open source content.
https://docsy.dev
Apache License 2.0
2.61k stars 899 forks source link

Using Hugo module, File to import not found or unreadable: ../vendor/bootstrap/scss/bootstrap #919

Closed sawp-d closed 2 years ago

sawp-d commented 2 years ago

Hello!

Very excited that you just released a Hugo module for docsy! I have spun up a simple demo project using the following steps:

  1. Create new Hugo project using hugo new site
  2. Add in module in config.toml:
[[module.imports]]
path = 'github.com/google/docsy'
  1. Ran hugo mod init -u then hugo server -D/--minify and ran into this error:
hugo v0.93.1+extended {...}
WARNING: calling IsSet with unsupported type "invalid" (<nil>) will always return false.
WARN 2022/03/07 15:39:39 .File.UniqueID on zero object. Wrap it in if or with: {{ with .File }}{{ .UniqueID }}{{ end }}
WARN 2022/03/07 15:39:39 .Path when the page is backed by a file is deprecated and will be removed in a future release. We plan to use Path for a canonical source path and you probably want to check the source is a file. To get the current behaviour, you can use a construct similar to the one below:

  {{ $path := "" }}
  {{ with .File }}
        {{ $path = .Path }}
  {{ else }}
        {{ $path = .Path }}
  {{ end }}

Re-run Hugo with the flag --panicOnWarning to get a better error message.
Error: Error building site: TOCSS: failed to transform "scss/main.scss" (text/x-scss): SCSS processing failed: file "stdin", line 6, col 1: File to import not found or unreadable: ../vendor/bootstrap/scss/bootstrap.

I see that there are related PRs for vendor/bootstrap, but is there anything I can do to fix this in my project or do I need to return to submodules and wait for a bit?

deining commented 2 years ago

To set a new site up from scratch, please follow the instructions given here.

You wrote:

2. Add in module in config.toml:
[[module.imports]]
path = 'github.com/google/docsy'

This is not enough. You have to add github.com/google/docsy/dependencies to your config.toml, too. For a proper setup, you have to specify inside your config.toml:

[[module.imports]]
  path = "github.com/google/docsy"
[[module.imports]]
  path = "github.com/google/docsy/dependencies"

With this in place, you may check your proper setup with the following command:

$ hugo mod graph

This should result in an output of:

$ hugo mod graph
hugo: collected modules in 1008 ms
github.com/me/my-new-site github.com/google/docsy@v0.2.0-pre
github.com/me/my-new-site github.com/google/docsy/dependencies@v0.2.0-pre
github.com/google/docsy/dependencies@v0.2.0-pre github.com/twbs/bootstrap@v4.6.1+incompatible
github.com/google/docsy/dependencies@v0.2.0-pre github.com/FortAwesome/Font-Awesome@v0.0.0-20210804190922-7d3d774145ac

With this output, your site will start up without problems.

Please let me know if this cures your problem.

sawp-d commented 2 years ago

Thanks for the quick reply, @deining! Looks like that fixed it, and helpful instructions! Excited to use this theme!