cli: Bug: deploy command regression
The netlify deploy command used to deploy one of my sites has stopped working in netlify-cli@2.48.0
The command netlify deploy fails with a “Base directory does not exist” error.
> netlify deploy -p --dir public
Base directory does not exist: /Users/davidwells/David/analytics-project/analytics/site/main/site
Was something changed recently with the netlify deploy command?
This is the site in question: https://github.com/DavidWells/analytics/tree/master/site/main and the previously working deploy script is here: https://github.com/DavidWells/analytics/blob/master/site/main/package.json#L14
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 36 (29 by maintainers)
Commits related to this issue
- added empty yarn.lock for netlify to pickup https://github.com/netlify/cli/issues/859 — committed to cadbox1/very-nested by deleted user 4 years ago
- Redirect flow (#14) * attempted redirect flow currently broken due to a callback_uri mismatch but not sure why * pinned netlify dev version errors with a constructor issue now * implement... — committed to cadbox1/very-nested by cadbox1 4 years ago
- Redirect flow (#14) * attempted redirect flow currently broken due to a callback_uri mismatch but not sure why * pinned netlify dev version errors with a constructor issue now * implement... — committed to cadbox1/very-nested by cadbox1 4 years ago
netlify devis now working for me onnetlify-cli@2.57.0.No need to add a temporary
baseproperty to mynetlify.tomlanymore.Thanks! 👍
@ehmicky Rad! This fix worked for me. Thanks for the quick response!
Seems that the fix to this broke things with my config, when using my monorepo setup. I recently updated past
2.56.0(2.54.0 -> 2.59.1)I feel like I could work around this but I would expect that the CLI would respect the the current working directory, unless I tell the CLI otherwise with
dir.Directory Structure
Debug output
In my case
publishanddeploypath should be<reporoot>/portal-partner/dist.Versions
Config
The following change makes things work, but seems incorrect given other third party tools work correctly within our mono repo setup:
Ran into another example of this.
Base directory does not exist: /Users/xyz/site/frontend/siteerrornetlify-cli@2.40.0the deployment proceeds.These are the logs:
I have added the following issues for the CLI flags problems mentioned above since those are separate from this issue’s problem:
getSitetwice: https://github.com/netlify/cli/issues/958--siteCLI flag to@netlify/config: https://github.com/netlify/cli/issues/959--functionsCLI flag to@netlify/config: https://github.com/netlify/cli/issues/960--dirCLI flag to@netlify/config: https://github.com/netlify/cli/issues/961aliasto context: https://github.com/netlify/cli/issues/962--aliasCLI flag to@netlify/config: https://github.com/netlify/cli/issues/963https://github.com/netlify/build/pull/1581 is merged and released to npm.
@erezrokah Would it be possible for you to test https://github.com/netlify/cli/pull/953 and see whether the problem that you reproduced is now fixed?
First part (
@netlify/configbasebehavior) done in https://github.com/netlify/build/pull/1581 Second and last part done by re-writing https://github.com/netlify/cli/pull/953I am now trying to connect both PRs to see if this works.
We just discussed with @erezrokah and went with the following solution, which should solve this bug:
@netlify/config, ifcwdis a subdirectory ofrepositoryRoot, tries to find if any directory (that is>= cwd && < repositoryRootin the tree structure) that has a.netlifyornetlify.toml. If one exists, this is used asbuild.base, regardless of what base is set in UI build settings.build.baseis used to computebuildDir,@netlify/clican now use thebuildDirreturned by@netlify/configas itsprojectDir/projectRoot/site.rootwhich is used to find.netlify/state.jsonand resolvepublish,functions,.env,_headers,_redirects, etc.repositoryRootflag from@netlify/clito@netlify/config. Instead, let@netlify/configcompute it by looking up.gitfromcwdFor the CLI flags (
--dir,--functions,--site,--alias), I still think those should be fixed to re-use the logic from@netlify/config. They currently do not account for many use cases (properties case-insensitivity, contexts, etc.). We can create separate issues/bugs for each of those, separately from this issue though.@ehmicky that’s is a great analysis and there is some work to be done on consolidation. We would first need to map out different use cases and make sure they are covered by tests.
To be more focused on this issue with the
basedirectory - I would expect that when running from the CLI we would always ignore the UI/config settings forbaseand resolve the build directory using the current working directory.More specifically running
netlify deploy --prod --dir outshould work when invoked fromrepo/siteandnetlify deploy --prod --dir site/outshould work from invoked fromrepo(in the latter the CLI should not ask to link to a site ifsite/.netlifyexists).That should work for multiple sites under the same repo as well (e.g.
netlify deploy --prod --dir site1/out,netlify deploy --prod --dir site2/out).