Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/zpm/src/commands/dlx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ pub async fn install_dependencies(workspace_path: &Path, loose_resolutions: Vec<
project
.run_install(RunInstallOptions {
silent_or_error: quiet,
skip_constraints_check: true,
enforced_resolutions,
..Default::default()
}).await?;
Expand Down
4 changes: 3 additions & 1 deletion packages/zpm/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ pub struct RunInstallOptions {
pub refresh_lockfile: bool,
pub roots: Option<BTreeSet<Ident>>,
pub silent_or_error: bool,
/// Temporary installs have no constraints configuration to check.
pub skip_constraints_check: bool,
pub json: bool,
pub inline_builds: bool,
pub force: bool,
Expand Down Expand Up @@ -1675,7 +1677,7 @@ impl Project {
.with_previous_state(self.install_state.as_ref())
.with_roots(roots)
.with_installed_workspaces(options.roots.clone())
.with_constraints_check(!options.silent_or_error && self.config.settings.enable_constraints_checks.value && options.roots.is_none())
.with_constraints_check(!options.silent_or_error && !options.skip_constraints_check && self.config.settings.enable_constraints_checks.value && options.roots.is_none())
.with_skip_link_step(options.mode == Some(InstallMode::UpdateLockfile))
.with_skip_lockfile_update(options.roots.is_some())
.with_force(options.force)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ describe(`Commands`, () => {
}),
);

test(
`it should skip the caller's constraints for temporary installs while checking normal installs`,
makeTemporaryEnv({}, async ({path, run}) => {
await yarn.writeConfiguration(path, {
enableConstraintsChecks: true,
});

await writeFile(`${path}/yarn.config.cjs`, [
`exports.constraints = ({ Yarn }) => {`,
` for (const workspace of Yarn.workspaces()) {`,
` workspace.set('foo', 'bar');`,
` }`,
`};`,
].join(`\n`));

await expect(run(`dlx`, `has-bin-entries`)).resolves.toBeDefined();

await expect(run(`install`)).rejects.toThrow(/Constraint check failed; run yarn constraints for more details/);
}),
);

test(
`it shouldn't warn on unused package extensions in projects created by dlx (dependencies)`,
makeTemporaryEnv(
Expand Down
Loading