Hugo + Asciidoc on Windows triggering WARN messages about 'gemrc' not being found

I’ve been successfully using an installation of Hugo on my Mac. I recently replicated the Hugo + Asciidoc configuration on Windows, to get a colleague up and running with the site migration we are working on.

When running the build on the Windows machine, I get several (I’d say one per page) warning messages of this type:

Warning: Failed to create a system wide 'gemrc' file, making Rubygems possibly insecure: no implicit conversion of nil into String

Note that I checked whether the file ‘gemrc’ is where it is expected to be (i.e. C:\ProgramData) and it is. So, it looks like the complaint is somewhat deceiving.

Two questions:

  • Did anybody come across something similar before?
  • In case I don’t find a solution for this, do you know if it’s possible to invoke the Node implementation asciidoctor.js to render the markup, instead of relying on the Ruby gem?

I’d appreciate any pointers in the right direction.

I suspect there’s a Windows environment variable, required by ruby or gem, that Hugo cannot read.

In your site configuration, try this:

[security.exec]
allow = ['^(dart-)?sass(-embedded)?$', '^go$', '^npx$', '^postcss$','^asciidoctor$']
osEnv = ['.*']

The second line gives Hugo access to all OS environment variables.

The default value is:

osEnv = ['(?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG)$']

If the “everything” regex ('.*') works, you could then try to narrow it down to exactly which environment variable(s) Hugo needs.

1 Like

I found it: SYSTEMDRIVE.

Do this in site config:

[security.exec]
allow = ['^(dart-)?sass(-embedded)?$', '^go$', '^npx$', '^postcss$','^asciidoctor$']
osEnv = ['(?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG|SYSTEMDRIVE)$']

Out of curiosity, which Windows version are you installing on?

1 Like

Well, that was it. I was neck-deep in debugging, but blind to the fact that this could be fixed on Hugo’s end (e.g. with a config option).

To answer your question: Windows 10 Enterprise 64-bit (10.0, Build 19045)

Thanks a lot for your help!

1 Like

SYSTEMDRIVE will be added to the default allowlist in the next release.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.