Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 16.x broke the build path resolution #5949

Closed
CamiloTerevinto opened this issue Aug 14, 2023 · 7 comments · Fixed by #5966
Closed

Version 16.x broke the build path resolution #5949

CamiloTerevinto opened this issue Aug 14, 2023 · 7 comments · Fixed by #5966
Labels
area: monorepo type: bug code to address defects in shipped code

Comments

@CamiloTerevinto
Copy link

Describe the bug

I have a GitHub action that does cd ./out && netlify deploy --dir . --site *** --prod --auth ***.

Last week, using 15.x, this gave me a log of:

Deploy path: /home/runner/work/www/www/out

Now, it's giving a log of:

Deploy path: /home/runner/work/www/www

Which, of course, broke my site, as the expected files are in a sub-folder.

Steps to reproduce

Run netlify deploy passing the current directory (.)

Configuration

N/A

Environment

System:
    OS: Linux 5.[15](https://github.com/CamiloTerevinto/www/actions/runs/5860077734/job/15887416498#step:9:16) Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (2) x64 Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz
    Memory: 5.48 GB / 6.77 GB
    Container: Yes
    Shell: 5.1.[16](https://github.com/CamiloTerevinto/www/actions/runs/5860077734/job/15887416498#step:9:17) - /bin/bash
  Binaries:
    Node: 18.[17](https://github.com/CamiloTerevinto/www/actions/runs/5860077734/job/15887416498#step:9:18).0 - /usr/local/bin/node
    Yarn: 1.22.[19](https://github.com/CamiloTerevinto/www/actions/runs/5860077734/job/15887416498#step:9:20) - /usr/local/bin/yarn
    npm: 9.6.7 - /usr/local/bin/npm
  npmGlobalPackages:
    netlify-cli: 16.0.3
@CamiloTerevinto CamiloTerevinto added the type: bug code to address defects in shipped code label Aug 14, 2023
@CamiloTerevinto
Copy link
Author

Note that a simple workaround is to add again the relative path:

netlify deploy --dir ./out --site *** --prod --auth ***

But this is likely going to annoy people.

@lukasholzer
Copy link
Collaborator

Hey @CamiloTerevinto, first of all, sorry that we've broken your workflow, and thank you for raising this issue!

Can you share more details about your repository, or if easily possible, share some reproducible example that helps us fix the issue?

  1. Is it a mono repository (like pnpm workspaces, lerna, etc)
  2. can you describe the folder structure and where you execute the command in the CI (process working directory – e.g. repository root)?
  3. like cwd, etc...
  4. how does your configuration file look like? do you use a netlify.toml?

@jlengstorf
Copy link
Contributor

I ran into this issue as well in an Nx monorepo: https://github.com/learnwithjason/learnwithjason.dev

As of 16.x the Netlify CLI is trying to use the wrong directories to run e.g. ntl dev. Revert to 15.11.0 fixes the problem and the site operates normally.

@CamiloTerevinto
Copy link
Author

Hey @lukasholzer, sorry I missed the notification for your comment.

  1. It's a .NET repo where the static files are generated and stored at the ./out folder (index.html, other HTML files at the root folder, and then assets and other folders). Nothing NodeJs/npm/etc related.
  2. Everything for Netlify is stored inside the ./out folder. The commands run from inside this folder (see code below)
  3. I don't use a config file, I just push the files directly.
- name: Run the ssg tool
  run: ssg --output ${GITHUB_WORKSPACE}/out [other irrelevant params]

- name: Use Node.js 16.x
  uses: actions/setup-node@v3

- name: Install the Netlify CLI
  run: npm install netlify-cli -g

- name: Push to Netlify
  run: netlify deploy --dir ./out --site [obfuscated] --prod --auth ${{secrets.NETLIFY_TOKEN}}

The last step, which worked with the latest 15.x, used to be cd ./out && netlify deploy --dir . --site [obfuscated] --prod --auth ${{secrets.NETLIFY_TOKEN}}

@dfdeagle47
Copy link

dfdeagle47 commented Aug 25, 2023

I also encountered this problem. If I'm not mistaken, I suspect at least this change to be part of the problem:

image

2006b6d#diff-37fc61d924cb730fc441c96ab07140dcf59d85503fdf7e1ce3d9154381eeb76dR78

Because we no longer use the cwd, and instead use the site.root and I'm not quite sure, but perhaps the root is always the repo root:

async function getRepositoryRoot(cwd) {
const res = await findUp('.git', { cwd, type: 'directory' })
if (res) {
return join(res, '..')
}
}

For reference, I encountered this issue in a GitHub Action workflow which is something like this:

# (...other jobs...)
jobs:
  build-and-deploy:
    steps:
      # (...other steps...)
      - name: Deploy to Netlify
        run: |
          npx --yes netlify-cli deploy \
            --auth=$NETLIFY_AUTH_TOKEN \
            --dir=build \
            --prod \
            --site=$NETLIFY_SITE_ID;
        working-directory: ./path/to/subfolder

Where the command should be executed within ./path/to/subfolder because the bundle resides in the ./path/to/subfolder/build/ folder.

@awesomephant
Copy link

Seeing a related (?) issue in an npm monorepo environment: on 16.x netlify dev fails with "Failed running command: npm run start. Please verify 'npm' exists". Downgrading to 15.x and adding the following to my netlify.toml fixes the issue:

[dev]
  framework = "gatsby"
  command = "npm run develop"

@guvengorgun
Copy link

I'm having the same issue, cli log was like this previously (6th Aug CI build log);

❯ Current directory
  /builds/purpose-development/templates/flexiblog/@elegantstack/site

Now, it's like this and failing (31th Aug CI build log);

❯ Current directory
  /builds/purpose-development/templates/flexiblog/@elegantstack

Nothing has changed in the CI/CD code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: monorepo type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants