Skip to content

Conversation

@ehmicky
Copy link
Contributor

@ehmicky ehmicky commented Jun 24, 2020

As described in #859, this improves how the project root is resolved, by moving the findRoot logic to @netlify/config instead.

Note: this PR is a WIP since it requires netlify/build#1579 and netlify/build#1580 to be merged first. This is why the tests are currently failing.

@ehmicky ehmicky added the type: chore work needed to keep the product and development running smoothly label Jun 24, 2020
@ehmicky ehmicky requested review from RaeesBhatti and erezrokah June 24, 2020 22:58
@ehmicky ehmicky self-assigned this Jun 24, 2020
@ehmicky ehmicky force-pushed the chore/improve-project-root branch from 01ac9dd to 5d28949 Compare June 25, 2020 15:55
@ehmicky
Copy link
Contributor Author

ehmicky commented Jun 25, 2020

I have updated this PR based on #859 (comment).

@ehmicky
Copy link
Contributor Author

ehmicky commented Jun 25, 2020

There seem to be still be some issues, debugging right now.

@ehmicky ehmicky marked this pull request as draft June 25, 2020 18:25
@ehmicky ehmicky force-pushed the chore/improve-project-root branch 2 times, most recently from 92f4157 to e427be3 Compare June 25, 2020 19:02
@ehmicky ehmicky force-pushed the chore/improve-project-root branch from e427be3 to ceee950 Compare June 25, 2020 19:23
@ehmicky ehmicky marked this pull request as ready for review June 25, 2020 19:24
@ehmicky
Copy link
Contributor Author

ehmicky commented Jun 25, 2020

Problems fixed! Ready for testing.

@erezrokah
Copy link
Contributor

Tested and the fix works.
Also - the code looks much simpler now, thanks @ehmicky!

@ehmicky ehmicky merged commit 7f8a61b into master Jun 30, 2020
@ehmicky ehmicky deleted the chore/improve-project-root branch June 30, 2020 14:15
@JamesMcMahon
Copy link

JamesMcMahon commented Jul 15, 2020

Does this change result in breaking existing configuration?

My configuration, which was:

[build]
  publish = "build"

Broke post netlify cli upgrade, (went from 2.51.0 to 2.58.0).

The behavior I see is that the CLI is no longer is checking for build relative to where I am running the deploy command. It now expects build to be off of the repo root. To be more specific, I cd in my frontend directory and run npm build and then run the deploy command. Worked in 2.51.0, but in 2.58.0, it is now looking for repo-root/build instead of repo-root/frontend/build.

Not sure if this was the change that broke it, but looking at the changes it looked like the most likely culprit.

@ehmicky
Copy link
Contributor Author

ehmicky commented Jul 15, 2020

Hi @JamesMcMahon,

Could you please print (except for confidential values):

  • Your logs when running the Netlify CLI (with the proper current directory), with the environment variable NETLIFY_BUILD_DEBUG set to true
  • The output of netlify --version and ./node_modules/.bin/netlify-config --version.
  • Your full netlify.toml
  • Any build settings you might have set in the Netlify app UI

Thanks!

@FinnWoelm
Copy link
Contributor

FinnWoelm commented Jul 19, 2020

@JamesMcMahon, I ran into the same issue. I solved it by creating an empty .git directory in my subdirectory. For some reason, that worked.

My files:

+ .git/
+ node_modules/
+ package.json
+ file1.js
+ file2.js
+ subdirectory/
  + .git/    <-- completely empty directory
  + package.json
  + netlify.toml
  + publish/
  + ...

My netlify.toml configuration:

[build]
  publish = "publish"

My subdirectory package.json:

{
  "name": "test",
  "scripts": {
    "deploy": "../node_modules/.bin/netlify deploy"
  }
}

Perhaps it helps someone 😊

FinnWoelm added a commit to netlify/next-on-netlify that referenced this pull request Jul 19, 2020
This is a workaround to netlify-cli's new way to resolve the project
directory. By creating an empty .git folder in the build directory,
netlify-cli deploys files relative to that directory (rather than
project root).

See: netlify/cli#953 (comment)
@JamesMcMahon
Copy link

Just to clarify, I had no problems fixing the issue. I was reporting it hear because it was a breaking change that got bundled into a seem-lying innocuous minor release.

In my case, I fixed it by changing

[build]
publish = "build"

To:

[build]
publish = "frontend/build"

This is maybe the wrong place to report this, also maybe kind of pointless given that release has already happened. I wanted to record the change for posterity sake.

@ehmicky If you still need any of that information let me know.

@ehmicky
Copy link
Contributor Author

ehmicky commented Jul 20, 2020

@JamesMcMahon If you could post any of the information listed above, this could fix this problem for other users without them having to modify their netlify.toml nor add a .git directory. Otherwise, I'm glad your problem is solved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: chore work needed to keep the product and development running smoothly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants