Skip to content

Detect Yarn the same way the installer does - #673

Merged
tricknotes merged 1 commit into
mainfrom
unify-yarn-detection
Sep 7, 2026
Merged

Detect Yarn the same way the installer does#673
tricknotes merged 1 commit into
mainfrom
unify-yarn-detection

Conversation

@tricknotes

Copy link
Copy Markdown
Owner

Why

Two implementations answered "does Yarn install this application's dependencies?" and they disagreed.

  • EmberCli::App#yarn_enabled? read the yarn option alone.
  • EmberCli::PathSet#yarn? — which Shell#install reaches through PathSet#yarn — also treated yarn_path as a request for Yarn. PathSet#path_for_executable resolves yarn_path without consulting $PATH, and spec/lib/ember_cli/path_set_spec.rb covers exactly that case.

The Heroku generator asked the first one. An application configured with yarn_path alone therefore installed with Yarn everywhere the gem runs the installer, but got no root yarn.lock from rails generate ember:heroku — so Heroku's NodeJS buildpack, which picks the package manager by the lockfile it finds, fell back to npm for the same project.

What changed

  • EmberCli::PathSet#yarn? is now public and returns a boolean instead of the option value.
  • EmberCli::App#yarn_enabled? is replaced by EmberCli::App#yarn?, delegating to PathSet#yarn?.
  • HerokuGenerator#identify_as_yarn_project asks EmberCli.any?(&:yarn?).

The installer stays the single source of truth; the generator becomes one of its readers.

Compatibility

EmberCli::App#yarn_enabled? is removed rather than aliased — the rename is noted in the CHANGELOG. Its only caller in this repository was the Heroku generator.

Behaviour changes for one configuration: c.app :frontend, yarn_path: "/path/to/yarn" (without yarn: true) now gets a yarn.lock from the generator. That is the configuration the bug describes.

Verification

$ bin/rspec spec/lib spec/generators
141 examples, 1 failure

The one failure is EmberCli::App#test exits with exit status of 0, which fails on main in this container too — ember test reports Launcher Chrome not found, unrelated to this change.

New coverage: PathSet#yarn? for yarn: true, yarn_path alone, and neither; App#yarn? for the same three plus yarn: false.

🤖 Generated with Claude Code

https://claude.ai/code/session_014rAfkAVGVifbaEoTVeT66u


Generated by Claude Code

@tricknotes tricknotes changed the title Ask one question to decide whether Yarn installs the dependencies Detect Yarn the same way the installer does Sep 7, 2026
Two implementations decided whether Yarn installs an application's
dependencies, and they disagreed.
`EmberCli::App#yarn_enabled?` read the `yarn` option alone,
while `EmberCli::PathSet#yarn?` — which `Shell#install` reaches through
`PathSet#yarn` — also treated `yarn_path` as a request for Yarn.

The Heroku generator asked the first one.
An application configured with `yarn_path` alone therefore installed with Yarn
everywhere the gem runs the installer,
but got no root `yarn.lock` from `rails generate ember:heroku`,
so Heroku's NodeJS buildpack — which picks the package manager by the lockfile
it finds — fell back to npm for the same project.

`App#yarn?` now delegates to `PathSet#yarn?`,
leaving the installer as the single source of truth
and the generator as one of its readers.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014rAfkAVGVifbaEoTVeT66u
@tricknotes
tricknotes marked this pull request as ready for review September 7, 2026 12:25
@tricknotes
tricknotes merged commit 00323e1 into main Sep 7, 2026
12 checks passed
@tricknotes
tricknotes deleted the unify-yarn-detection branch September 7, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants