Base directory build setting ignored in netlify.toml

I am experiencing the same issue. The public repo I am trying to deploy is at GitHub - 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: GitHub - 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.

https://github.com/tylerben/example-netlify-toml-not-working

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?

1 Like

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

Hi @jen,

Just wanted to flag that the File based configuration help page still seems to say

If a base directory has been specified, include it in the publish directory path.

Just got caught by this issue again, so I thought I’d let you all know. :slight_smile:

1 Like

Hey @polybuildr,
Nooo, I’m sorry to hear that and very glad you found this thread! The reason those docs haven’t been updated yet is not due to lack of interest/urgency, but due to the fact that we want to make sure to fully document all of the impacts that setting a base directory can have. To point you to one public issue (there are also some private internal ones) where we’re discussing this:

We will be sure to update here once those updates have rolled out, and please continue to let us know how we can help in the meantime.

1 Like

Wanted to share a small update here, which is that we did change the wording in the sample configuration file:

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

  # Directory that contains the deploy-ready HTML files and assets generated by
  # the build. This is relative to the base directory if one has been set, or the
  # root directory if a base has not been set. This sample publishes the
  # directory located at the absolute path "root/project/build-output"
  publish = "build-output/"
...

Thanks for the nudge @polybuildr :slight_smile:

Thanks, @jen! All clear now! :slight_smile:

Hi folks, I’m running into the same (or a very similar) problem.
I have a repo that has a directory called docs that contains the site I want to build (it’s documentation for a small package). I figured I could make a netlify.toml file in the repo root that looks like this:

[build]
  base = "docs/"
  publish = "_site/"
  command = "jekyll build"

…But unfortunately that doesn’t work. The netlify feedback says that that site is successfully published, but the url returns a 404. You can see an example here: Netlify App
It’s showing some stuff that looks…wrong, like No build command found, continuing to publishing and Starting to deploy site from '' but I’m not sure how to debug those apart from the steps in this thread (which I’ve tried, and tried variations of). You can see my last several attempts to get it working in this rather embarrassing commit history: Commits · murmurcreative/module-drawer · GitHub

If you need any more debug information, please let me know!

Hey @alwaysblank,

Do you need to set them in a netlify.toml? If not, you can just add them in the UI :slight_smile:

Otherwise, your netlify.toml must reside in the root directory.

Does _site contain all of your HTML files, redirects, et cetera? Because that’s what the publish folder specifies.

Definitions are here. Happy to help further.

Hey Netlify folks,

I just got snagged by this issue - It seems the admin UI prepends the Base directory to the Publish directory.

Example:

  • Base dir: ./sapper
  • Publish dir: ./sapper/__sapper__/export

Admin UI

Figured out what was going on after a bit of trial and error! But I’m guessing that the prepended base dir needs to be removed? (unless I’m misunderstanding something?)

Hey there,
Sorry for the slow response here! Yeah, there are indeed a few confusing pieces in that view when it comes to the base directory. Are you saying that you manually deleted the extra sapper/ in order to get your build to work? Thanks!

hey @jen, I assumed the base dir was being prepended as the ui shows (red highlight) so didn’t include it in the publish dir. It seems this is not the case. The base dir is not in reality added so it needed the extra ./sapper.

The screenshot above is showing the working settings with the incorrectly added base dir (which isn’t editable, it sits before the input field in the ui).

Hi @slowrush,

Based on your update, it looks like your issue is related to Issues with base build directory during deploys - #2 by jen and that our engineers are aware of it and are working towards a bugfix. I don’t have an ETA on when it’ll get resolved but we’ll likely update on the post that I linked to.

Let us know if you have any questions in the meantime.