Base directory build setting ignored in netlify.toml

Hello,

I am running into an issue when trying to set the base directory for my site through the netlify.toml file. The publish directory and build commands, however, are being picked up. I am trying to deploy the site through Git, specifically Github. When I walk through the create a new site UI I see the publish directory and build command values coming through but do not see the base directory.

I then click the deploy site and navigate to the “Build and Deploy” tab in site settings. On this page I would expect to see the base directory value populated but instead see “Not Set”.

Screenshot_2020-03-03 Build deploy Settings

I have searched the forums and tried several different configurations to no avail. Here is my netlify.toml file:

# Settings in the [build] context are global and are applied to all contexts
# unless otherwise overridden by more specific contexts.

[build]
  # Directory to change to before starting a build.
  # This is where we will look for package.json/.nvmrc/etc.
  base = "frontend/"

  # Directory (relative to root of your repo) that contains the deploy-ready
  # HTML files and assets generated by the build. If a base directory has
  # been specified, include it in the publish directory path.
  publish = "frontend/build/"

  # Default build command.
  command = "npm run-script build"

# The following redirect is intended for use with most SPAs that handle
# routing internally.
[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

I appreciate the help.

Hi, @tylerben, and welcome to our Netlify community site. :slight_smile:

I do see that both the build command and publish directory are auto-populated from netlify.toml but that the base directory is not.

Are you asking for the base directory to also be auto-populated from netlify.toml?

Hi @luke ,

Thanks for the reply. That is correct. Because I am setting the base key in the netlify.toml file, I would expect that the base directory field would be auto-populated in the settings UI. Is this not supported?

Hmmm… what you’re doing should work if your netlify.toml is in your root directory. Can you please share your Netlify site name and your repo if it’s public? That’ll let us take a closer look at your file structure.

I am experiencing the same issue. The public repo I am trying to deploy is at https://github.com/changelabsio/avl-tips

Heya @robert-bo-davis, can you please share your Netlify URL and say more about what issue you’re experiencing? When I look at your netlify.toml in that repo, I don’t see a base directory configured there. More on that here:

Let us know so can we dig in!

Sorry, we moved that project to lerna so the broken setup is no longer obvious in there. I forgot about this issue.

I set up a minimal test to try to reproduce and finally figured out what the problem for me was.

You can see the example here: https://github.com/interrobangc/netlifyDeployBug

That repo has a non master branch set to the default branch in github. The initial “deploy to netlify” button works, the site is created and bootstrapped, but since the master branch doesn’t have a netlify.toml file, the build fails.

My issue does not appear to be a bug in netlify. I assume that I just needed to set the production deploy context to the non standard branch. I haven’t take the time to test that though.

1 Like

On an unrelated note… plase let me know if I should open another issue somewhere.

In my testing, I did notice that the documentation says that the publish directory setting is relative to the root of the repo, but it appears to be relative to the base setting.

1 Like

You’re right on both counts!

Thanks so much for both coming back to share your process and making that example repo- makes it very easy to see the base vs. publish directory issue and I’m sure will be helpful for others who run into this same problem. I will reach out to our docs team to update that sample config.

Hi Jen,

Sorry for super late reply on this. I am still experiencing the issue I originally described. Here is a link to an example repo that functions similarly to the project I am working on.

The name of my site is example-netlify-toml-not-working and I was not able to successfully deploy the site as the result of the issues noted in my first two posts.

Of note in the deploy log were the following:

Different base path detected, going to use the one specified in the Netlify configuration file: 'frontend/' versus '' in the Netlify UI

And at the very end of the process

failed during stage 'building site': Deploy directory 'frontend/frontend/build' does not exist

So it looks like the base directory (value of “frontend/”) (while not being shown in the Netlify UI) is being read from the netlify.toml file and is being prepended to the publish value in the netfliy.toml (value of “frontend/build/”).

Any ideas as to why the base directory value does not show up in the Netlify UI and why it is being prepended to the publish directory?

Hey @tylerben, it seems like you may have gotten snagged by the same base vs. publish directory described by @robert-bo-davis above… as did I when I told you that your setup looked fine to me! Could you please try keeping your base as-is but making your publish directory “build”, so that your netlify.toml looks like:

# Settings in the [build] context are global and are applied to all contexts
# unless otherwise overridden by more specific contexts.
[build]
  # Directory to change to before starting a build.
  # This is where we will look for package.json/.nvmrc/etc.
  base = "frontend"

  # Directory (relative to root of your repo) that contains the deploy-ready
  # HTML files and assets generated by the build. If a base directory has
  # been specified, include it in the publish directory path.
  publish = "/build"

  # Default build command.
  command = "npm run-script build"

Please let me know if that fixes things for you!

As for the UI, the netlify.toml does take precedence over UI settings, so it makes sense that your values there are the ones that are used for the build. Are you saying that you would expect the netlify.toml values to appear in the UI if they are the ones being used?

Hi Jen,

Thanks for the help on this! Changing the netlify.toml to what you suggested resolved the deploy issue.

Re: Are you saying that you would expect the netlify.toml values to appear in the UI if they are the ones being used? That is correct. As the “Build command” and “Publish directory” fields are populated in the UI based on the values in netlify.toml, I would also expect that the “Base directory” value would be populated in the Netlify UI which it currently isn’t. So maybe not a bug but a improvement for the sake of consistency?

Here is what the build settings block looks like for me currently.

1 Like

Awesome, glad you’re up and running!

And what you’re saying makes sense, thanks for clarifying :slight_smile: I’ve added your comment to an internal GitHub issue about UI around the base directory setting. We’ll update here if we make changes on that front.

Awesome, thanks much!

1 Like