diff --git a/dask/array/ufunc.py b/dask/array/ufunc.py
index c107a2880..90ac357bb 100644
--- a/dask/array/ufunc.py
+++ b/dask/array/ufunc.py
@@ -17,15 +17,16 @@ def __array_wrap__(numpy_ufunc, x, *args, **kwargs):
 def wrap_elemwise(numpy_ufunc, array_wrap=False):
     """ Wrap up numpy function into dask.array """
 
-    def wrapped(x, *args, **kwargs):
-        if hasattr(x, '_elemwise'):
+    def wrapped(*args, **kwargs):
+        dsk = [arg for arg in args if hasattr(arg, '_elemwise')]
+        if len(dsk) > 0:
             if array_wrap:
-                return x._elemwise(__array_wrap__, numpy_ufunc,
-                                   x, *args, **kwargs)
+                return dsk[0]._elemwise(__array_wrap__, numpy_ufunc,
+                                        *args, **kwargs)
             else:
-                return x._elemwise(numpy_ufunc, x, *args, **kwargs)
+                return dsk[0]._elemwise(numpy_ufunc, *args, **kwargs)
         else:
-            return numpy_ufunc(x, *args, **kwargs)
+            return numpy_ufunc(*args, **kwargs)
 
     # functools.wraps cannot wrap ufunc in Python 2.x
     wrapped.__name__ = numpy_ufunc.__name__

BUG: dask.array.maximum can trigger eager evaluation
The failure case seems to be `maximum(scalar, dask_array)`:
```
In [1]: import dask.array as da

In [2]: x = da.ones((3,), chunks=(3,))

In [3]: da.maximum(0, x)
Out[3]: array([ 1.,  1.,  1.])

In [4]: da.maximum(x, 0)
Out[4]: dask.array<maximum..., shape=(3,), dtype=float64, chunksize=(3,)>

In [5]: 0 + x
Out[5]: dask.array<add-5f9..., shape=(3,), dtype=float64, chunksize=(3,)>
```

Pretty sure this was introduced by https://github.com/dask/dask/pull/1669

This is causing the xarray test suite to fail: https://github.com/pydata/xarray/issues/1090

CC @sinhrks
diff --git a/dask/array/tests/test_ufunc.py b/dask/array/tests/test_ufunc.py
index 229c3e8c6..ac85d2cd4 100644
--- a/dask/array/tests/test_ufunc.py
+++ b/dask/array/tests/test_ufunc.py
@@ -75,6 +75,19 @@ def test_ufunc_2args(ufunc):
     assert isinstance(dafunc(arr1, arr2), np.ndarray)
     assert_eq(dafunc(arr1, arr2), npfunc(arr1, arr2))
 
+    # with scalar
+    assert isinstance(dafunc(darr1, 10), da.Array)
+    assert_eq(dafunc(darr1, 10), npfunc(arr1, 10))
+
+    assert isinstance(dafunc(10, darr1), da.Array)
+    assert_eq(dafunc(10, darr1), npfunc(10, arr1))
+
+    assert isinstance(dafunc(arr1, 10), np.ndarray)
+    assert_eq(dafunc(arr1, 10), npfunc(arr1, 10))
+
+    assert isinstance(dafunc(10, arr1), np.ndarray)
+    assert_eq(dafunc(10, arr1), npfunc(10, arr1))
+
 
 @pytest.mark.parametrize('ufunc', ['isreal', 'iscomplex', 'real', 'imag'])
 def test_complex(ufunc):

pip install -e .[complete]
parse_log_pytest
pytest
pytest coverage flake8 moto
apt-get update apt-get install -y graphviz liblzma-dev
3.5
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aiobotocore==2.1.2
aiohttp==3.8.6
aioitertools==0.11.0
aiosignal==1.2.0
async-timeout==4.0.2
asynctest==0.13.0
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
boto3==1.23.10
botocore==1.23.24
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
click==8.0.4
cloudpickle==2.2.1
coverage==6.2
cryptography==40.0.2
-e git+https://github.com/dask/dask.git@7aa13ca969fde27ab4b81ed6926ef72f1358f11b#egg=dask
dataclasses==0.8
distributed==1.14.3
flake8==5.0.4
frozenlist==1.2.0
fsspec==2022.1.0
HeapDict==1.0.1
idna==3.10
idna-ssl==1.1.0
importlib-metadata==4.2.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
Jinja2==3.0.3
jmespath==0.10.0
locket==1.0.0
MarkupSafe==2.0.1
mccabe==0.7.0
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
moto==4.0.13
msgpack-python==0.5.6
multidict==5.2.0
numpy==1.19.5
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
pandas==1.1.5
partd==1.2.0
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
psutil==7.0.0
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
python-dateutil==2.9.0.post0
pytz==2025.2
requests==2.27.1
responses==0.17.0
s3fs==2022.1.0
s3transfer==0.5.2
six==1.17.0
tblib==1.7.0
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
toolz==0.12.0
tornado==6.1
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
urllib3==1.26.20
Werkzeug==2.0.3
wrapt==1.16.0
xmltodict==0.14.2
yarl==1.7.2
zict==2.1.0
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: dask
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - aiobotocore==2.1.2
      - aiohttp==3.8.6
      - aioitertools==0.11.0
      - aiosignal==1.2.0
      - async-timeout==4.0.2
      - asynctest==0.13.0
      - boto3==1.23.10
      - botocore==1.23.24
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - click==8.0.4
      - cloudpickle==2.2.1
      - coverage==6.2
      - cryptography==40.0.2
      - dataclasses==0.8
      - distributed==1.14.3
      - flake8==5.0.4
      - frozenlist==1.2.0
      - fsspec==2022.1.0
      - heapdict==1.0.1
      - idna==3.10
      - idna-ssl==1.1.0
      - importlib-metadata==4.2.0
      - jinja2==3.0.3
      - jmespath==0.10.0
      - locket==1.0.0
      - markupsafe==2.0.1
      - mccabe==0.7.0
      - moto==4.0.13
      - msgpack-python==0.5.6
      - multidict==5.2.0
      - numpy==1.19.5
      - pandas==1.1.5
      - partd==1.2.0
      - psutil==7.0.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - requests==2.27.1
      - responses==0.17.0
      - s3fs==2022.1.0
      - s3transfer==0.5.2
      - six==1.17.0
      - tblib==1.7.0
      - toolz==0.12.0
      - tornado==6.1
      - urllib3==1.26.20
      - werkzeug==2.0.3
      - wrapt==1.16.0
      - xmltodict==0.14.2
      - yarl==1.7.2
      - zict==2.1.0
prefix: /opt/conda/envs/dask

dask/array/tests/test_ufunc.py::test_ufunc_2args[logaddexp] dask/array/tests/test_ufunc.py::test_ufunc_2args[logaddexp2] dask/array/tests/test_ufunc.py::test_ufunc_2args[arctan2] dask/array/tests/test_ufunc.py::test_ufunc_2args[hypot] dask/array/tests/test_ufunc.py::test_ufunc_2args[copysign] dask/array/tests/test_ufunc.py::test_ufunc_2args[nextafter] dask/array/tests/test_ufunc.py::test_ufunc_2args[ldexp] dask/array/tests/test_ufunc.py::test_ufunc_2args[fmod] dask/array/tests/test_ufunc.py::test_ufunc_2args[logical_and] dask/array/tests/test_ufunc.py::test_ufunc_2args[logical_or] dask/array/tests/test_ufunc.py::test_ufunc_2args[logical_xor] dask/array/tests/test_ufunc.py::test_ufunc_2args[maximum] dask/array/tests/test_ufunc.py::test_ufunc_2args[minimum] dask/array/tests/test_ufunc.py::test_ufunc_2args[fmax] dask/array/tests/test_ufunc.py::test_ufunc_2args[fmin]
dask/array/tests/test_ufunc.py::test_complex[isreal] dask/array/tests/test_ufunc.py::test_complex[real] dask/array/tests/test_ufunc.py::test_complex[imag]
dask/array/tests/test_ufunc.py::test_ufunc_meta dask/array/tests/test_ufunc.py::test_ufunc[conj] dask/array/tests/test_ufunc.py::test_ufunc[exp] dask/array/tests/test_ufunc.py::test_ufunc[log] dask/array/tests/test_ufunc.py::test_ufunc[log2] dask/array/tests/test_ufunc.py::test_ufunc[log10] dask/array/tests/test_ufunc.py::test_ufunc[log1p] dask/array/tests/test_ufunc.py::test_ufunc[expm1] dask/array/tests/test_ufunc.py::test_ufunc[sqrt] dask/array/tests/test_ufunc.py::test_ufunc[square] dask/array/tests/test_ufunc.py::test_ufunc[sin] dask/array/tests/test_ufunc.py::test_ufunc[cos] dask/array/tests/test_ufunc.py::test_ufunc[tan] dask/array/tests/test_ufunc.py::test_ufunc[arctan] dask/array/tests/test_ufunc.py::test_ufunc[sinh] dask/array/tests/test_ufunc.py::test_ufunc[cosh] dask/array/tests/test_ufunc.py::test_ufunc[tanh] dask/array/tests/test_ufunc.py::test_ufunc[arcsinh] dask/array/tests/test_ufunc.py::test_ufunc[arccosh] dask/array/tests/test_ufunc.py::test_ufunc[deg2rad] dask/array/tests/test_ufunc.py::test_ufunc[rad2deg] dask/array/tests/test_ufunc.py::test_ufunc[isfinite] dask/array/tests/test_ufunc.py::test_ufunc[isinf] dask/array/tests/test_ufunc.py::test_ufunc[isnan] dask/array/tests/test_ufunc.py::test_ufunc[signbit] dask/array/tests/test_ufunc.py::test_ufunc[degrees] dask/array/tests/test_ufunc.py::test_ufunc[radians] dask/array/tests/test_ufunc.py::test_ufunc[rint] dask/array/tests/test_ufunc.py::test_ufunc[fabs] dask/array/tests/test_ufunc.py::test_ufunc[sign] dask/array/tests/test_ufunc.py::test_ufunc[absolute] dask/array/tests/test_ufunc.py::test_ufunc[floor] dask/array/tests/test_ufunc.py::test_ufunc[ceil] dask/array/tests/test_ufunc.py::test_ufunc[trunc] dask/array/tests/test_ufunc.py::test_ufunc[logical_not] dask/array/tests/test_ufunc.py::test_complex[iscomplex] dask/array/tests/test_ufunc.py::test_ufunc_2results[frexp] dask/array/tests/test_ufunc.py::test_ufunc_2results[modf] dask/array/tests/test_ufunc.py::test_clip
dask/array/ufunc.py
dask/array/ufunc.py