Plugin "@netlify/plugin-emails" internal error Error: NETLIFY_EMAILS_DIRECTORY must be set

Hello! Here I am having issues deploying with the emial plugin enabled. I have configured everything with SendGrid and chose to set the API key in the Email UI. Everything is ready to go just blocked by the deployment step. I Appreciate the email plugin is still in experimental mode.


12:03:15 PM: build-image version: d7b3813f01c06610bc1723ff1b22446513ee7941 (focal)
12:03:15 PM: build-image tag: v4.14.3
12:03:15 PM: buildbot version: 4f669c94b322d52f143cdcbb17e55d40094aa06d
12:03:15 PM: Building without cache
12:03:15 PM: Starting to prepare the repo for build
12:03:16 PM: No cached dependencies found. Cloning fresh repo
12:03:16 PM: git clone https://github.com/smks/blog
12:03:22 PM: Preparing Git Reference refs/heads/main
12:03:23 PM: Parsing package.json dependencies
12:03:25 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
12:03:25 PM: Section completed: initializing
12:03:25 PM: Starting build script
12:03:25 PM: Installing dependencies
12:03:25 PM: Python version set to 2.7
12:03:25 PM: Downloading and installing node v16.18.1...
12:03:26 PM: Downloading https://nodejs.org/dist/v16.18.1/node-v16.18.1-linux-x64.tar.xz...
12:03:26 PM: Computing checksum with sha256sum
12:03:26 PM: Checksums matched!
12:03:28 PM: Now using node v16.18.1 (npm v8.19.2)
12:03:28 PM: Enabling node corepack
12:03:28 PM: Started restoring cached build plugins
12:03:28 PM: Finished restoring cached build plugins
12:03:28 PM: Attempting ruby version 2.7.2, read from environment
12:03:29 PM: Using ruby version 2.7.2
12:03:29 PM: Using PHP version 8.0
12:03:29 PM: No npm workspaces detected
12:03:29 PM: Started restoring cached node modules
12:03:29 PM: Finished restoring cached node modules
12:03:30 PM: Installing NPM modules using NPM version 8.19.2
12:03:38 PM: added 184 packages, and audited 185 packages in 8s
12:03:38 PM: 83 packages are looking for funding
12:03:38 PM:   run `npm fund` for details
12:03:38 PM: found 0 vulnerabilities
12:03:38 PM: NPM modules installed
12:03:38 PM: Creating package sha
12:03:38 PM: Started restoring cached go cache
12:03:38 PM: Finished restoring cached go cache
12:03:38 PM: Installing Go version 1.17 (requested 1.17)
12:03:43 PM: unset GOOS;
12:03:43 PM: unset GOARCH;
12:03:43 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
12:03:43 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
12:03:43 PM: go version >&2;
12:03:43 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
12:03:43 PM: go version go1.17 linux/amd64
12:03:43 PM: Detected 1 framework(s)
12:03:43 PM: "next" at version "13.0.3"
12:03:43 PM: Installing missing commands
12:03:43 PM: Verify run directory
12:03:45 PM: ​
12:03:45 PM: ────────────────────────────────────────────────────────────────
12:03:45 PM:   Netlify Build                                                 
12:03:45 PM: ────────────────────────────────────────────────────────────────
12:03:45 PM: ​
12:03:45 PM: ❯ Version
12:03:45 PM:   @netlify/build 28.1.13
12:03:45 PM: ​
12:03:45 PM: ❯ Flags
12:03:45 PM:   baseRelDir: true
12:03:45 PM:   buildId: 637a1781ea25702bf01539a9
12:03:45 PM:   deployId: 637a1781ea25702bf01539ab
12:03:45 PM: ​
12:03:45 PM: ❯ Current directory
12:03:45 PM:   /opt/build/repo
12:03:45 PM: ​
12:03:45 PM: ❯ Config file
12:03:45 PM:   No config file was defined: using default values.
12:03:45 PM: ​
12:03:45 PM: ❯ Context
12:03:45 PM:   production
12:03:45 PM: ​
12:03:45 PM: ❯ Installing plugins
12:03:45 PM:    - @netlify/plugin-emails@0.0.23
12:03:48 PM: ​
12:03:48 PM: ❯ Loading plugins
12:03:48 PM:    - @netlify/plugin-emails@0.0.23 from Netlify app
12:03:49 PM: ​
12:03:49 PM: ────────────────────────────────────────────────────────────────
12:03:49 PM:   1. @netlify/plugin-emails (onPreBuild event)                  
12:03:49 PM: ────────────────────────────────────────────────────────────────
12:03:49 PM: ​
12:03:49 PM: ​
12:03:49 PM: ────────────────────────────────────────────────────────────────
12:03:49 PM:   Plugin "@netlify/plugin-emails" internal error                
12:03:49 PM: ────────────────────────────────────────────────────────────────
12:03:49 PM: ​
12:03:49 PM:   Error message
12:03:49 PM:   Error: NETLIFY_EMAILS_DIRECTORY must be set
12:03:49 PM: ​
12:03:49 PM:   Plugin details
12:03:49 PM:   Package:        @netlify/plugin-emails
12:03:49 PM:   Version:        0.0.23
12:03:49 PM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-emails
12:03:49 PM: ​
12:03:49 PM:   Error location
12:03:49 PM:   In "onPreBuild" event in "@netlify/plugin-emails" from Netlify app
12:03:49 PM:       at onPreBuild (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-emails/lib/index.js:13:15)
12:03:49 PM:       at Object.run (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/plugins/child/run.js:14:11)
12:03:49 PM:       at handleEvent (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/plugins/child/main.js:28:65)
12:03:49 PM:       at file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/plugins/child/main.js:23:63
12:03:49 PM:       at process.<anonymous> (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/plugins/ipc.js:91:30)
12:03:49 PM:       at process.emit (node:events:513:28)
12:03:49 PM:       at process.emit (node:domain:489:12)
12:03:49 PM:       at emit (node:internal/child_process:946:14)
12:03:49 PM:       at processTicksAndRejections (node:internal/process/task_queues:84:21)
12:03:49 PM: ​
12:03:49 PM:   Resolved config
12:03:49 PM:   build:
12:03:49 PM:     base: /opt/build/repo
12:03:49 PM:     command: npm run build
12:03:49 PM:     commandOrigin: ui
12:03:49 PM:     environment:
12:03:49 PM:       - NETLIFY_GRAPH_TOKEN
12:03:49 PM:       - ONEGRAPH_AUTHLIFY_TOKEN
12:03:49 PM:     publish: /opt/build/repo/out
12:03:49 PM:     publishOrigin: ui
12:03:49 PM:   plugins:
12:03:49 PM:     - inputs: {}
12:03:49 PM:       origin: ui
12:03:49 PM:       package: '@netlify/plugin-emails'
12:03:50 PM: Caching artifacts
12:03:50 PM: Started saving node modules
12:03:50 PM: Finished saving node modules
12:03:51 PM: Creating deploy upload records
12:03:50 PM: Started saving build plugins
12:03:50 PM: Finished saving build plugins
12:03:50 PM: Started saving pip cache
12:03:50 PM: Finished saving pip cache
12:03:50 PM: Started saving emacs cask dependencies
12:03:51 PM: Failed during stage 'building site': Build script returned non-zero exit code: 3 (https://ntl.fyi/exit-code-3)
12:03:50 PM: Finished saving emacs cask dependencies
12:03:50 PM: Started saving maven dependencies
12:03:50 PM: Finished saving maven dependencies
12:03:50 PM: Started saving boot dependencies
12:03:50 PM: Finished saving boot dependencies
12:03:50 PM: Started saving rust rustup cache
12:03:50 PM: Finished saving rust rustup cache
12:03:50 PM: Started saving go dependencies
12:03:50 PM: Finished saving go dependencies
12:03:51 PM: Build failed due to a plugin error: Build script returned non-zero exit code: 3
12:03:51 PM: Failing build: Failed to build site
12:03:51 PM: Finished processing build request in 36.04177315s
1 Like

Hi @smks,

Thank you for sharing. We’ve passed this on to the devs to investigate.

Hi @smks,

As confirmed with the devs, the docs are currently incorrect. You need to manually set an environment variable to point to the correct directory.

I ran into the same issue. I had to also make some changes that are defined in this documentation:

To test it all out, ran the a build locally to test it out as well. (netlify build)

Hi all, just as a follow up note, we’ve updated the Netlify Email Integration documentation to note that the NETLIFY_EMAILS_DIRECTORY environment variable is mandatory. Thank you for reporting your concerns.

1 Like

That’s great thank you very much

1 Like