netlify / netlify/cli

In a monorepo with custom dev command, `ntl dev` runs with root cwd

Open
#6,107 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area: monorepo type: bug
Dominant language
TypeScript
Stars
1.9k
Forks
474
Avg merge
23h 30m
Merged PRs (30d)
53

Description

Describe the bug

In a monorepo with the following structure:

  • package.json
  • packages
    • test
      • package.json
      • netlify.toml
    • vite-project
      • package.json
      • netlify.toml

..running ntl dev always has the cwd as the root of the repo. This happens whether it is run from inside packages/test or at the root, choosing test from the menu. This is confusing behaviour, and is different from the case where the framework is detected.

The only workaround is to add --cwd . to every command.

Steps to reproduce
  1. Clone https://github.com/ascorbic/monorepo-repro
  2. Run pnpm i
  3. cd to packages/test and run ntl dev. Observe pwd output
  4. cd to packages/vite-project and run ntl dev. Observe that it runs correctly: running vite inside packages/vite-project.
  5. Uncomment the command in projects/vite-project/netlify.toml
  6. Run ntl dev again. Observe that build fails
Configuration
[dev]
command = "vite"
Environment

System:
OS: macOS 13.4.1
CPU: (8) arm64 Apple M1
Memory: 115.97 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
pnpm: 8.9.0 - ~/Library/pnpm/pnpm
npmGlobalPackages:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the ntl dev command with the monorepo reproduction and compare behavior from packages/test and packages/vite-project. Inspect how the command in each netlify.toml is executed; done means custom dev commands use the selected project directory without requiring --cwd ., while framework-detected commands continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.