Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Bug]: herd isolate-node ignores --site and writes .nvmrc into the current folder

Abierto Apto para principiantes
#1,774 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php, shell
Área
backend, cli

Línea de trabajo

Empieza por cli/app.php:1592 y cli/Valet/Site.php:1303-1306 para rastrear cómo --site selecciona la ruta de destino; compáralo con el manejo de unisolate-node en cli/app.php:1619. Inspecciona también bin/herd:148, donde el hook de shell comprueba si está --site=. Se considera terminado cuando el aislamiento escribe .nvmrc en la carpeta del sitio indicado, un sitio desconocido devuelve un error y el hook maneja el orden de argumentos documentado sin cambiar la versión de Node de la carpeta actual.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

macOS
Platform

macOS

Operating system version

macOS 27.0.1 (26A434)

System architecture

ARM64 (M1, M2, etc)

Herd Version

2.0.2 (Build: 71)

PHP Version

n/a (Node 26.12.0 through Herd's nvm; global PHP is 8.5.10)

Bug description

herd isolate-node 26 --site=example ignores --site. The docs show this form for sites whose name doesn't match their folder, but the .nvmrc lands in the current folder instead of the site's, overwriting any .nvmrc already there. It still says "The site is now using Node 26." and exits 0, even for a site that doesn't exist.

herd unisolate-node --site=example does look in the site's folder, so it says it worked and leaves the stray .nvmrc behind.

Because nvm and Herd's shell hook pick up .nvmrc from parent folders, running it from ~/Herd would switch Node for every site below it without its own .nvmrc (I saw the hook switch after a cd into a subfolder). From the hook's code it would also nvm install a missing version; I didn't test that.

Expected: the .nvmrc goes into the site's folder, and an unknown site name gives an error.

Cause (herd.phar 2.0.2): isolate-node always passes getcwd() to Site::isolateNode() (cli/app.php:1592), which uses that path whenever it's set (cli/Valet/Site.php:1303-1305), so the site lookup at :1306 never runs. unisolate-node passes no path (app.php:1619), so it finds the site.

Possible fix: pass null instead of getcwd() when --site is set (app.php:1592, and :1580 for the form without a version).

Also: bin/herd:148 only checks $2 for --site=, so with the docs' argument order (and for --help) it runs nvm use in the current folder as well.

Thanks for the quick fixes on #1770 and #1771.

Steps to reproduce
  1. Herd 2.0.2 with any installed Node version (26 here) and a linked or parked site example that has no .nvmrc.
  2. From a folder that isn't a site: mkdir ~/herd-test && cd ~/herd-test, then herd isolate-node 26 --site=example.
  3. ls -A ~/herd-test ~/Herd/example: the .nvmrc is in ~/herd-test, not in the site's folder, and herd isolated-node doesn't list the site.
  4. herd unisolate-node --site=example: it says it worked, but ~/herd-test/.nvmrc is still there.
  5. Clean up with rm ~/herd-test/.nvmrc.
Relevant log output
# Paths changed for privacy. For the linked-site part I ran herd.phar against a copy of my Herd config, so my real setup stayed untouched.
# Same behaviour with a stock .zshrc (only Herd's own lines) and with no shell config at all.

$ cd ~/herd-test
$ herd isolate-node --site=example 26
The site is now using Node 26.
$ ls -A ~/herd-test
.nvmrc
$ cat ~/herd-test/.nvmrc
26
$ ls -A ~/Herd/example
$ herd isolated-node
+------+--------------+
| Path | Node Version |
+------+--------------+
$ herd unisolate-node --site=example
The site is now using the default Node version.
$ ls -A ~/herd-test
.nvmrc

# The docs' argument order, with a site name that doesn't exist:
$ cd ~/herd-test2
$ herd isolate-node 26 --site=nosuchsite
The site is now using Node 26.
Found '~/herd-test2/.nvmrc' with version <26>
Now using node v26.12.0 (npm v11.20.0)
$ echo $?
0
Lenguaje dominante
Sin datos de lenguaje
Estrellas
124
Forks
1
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de beyondcode/herd-community

Todos los issues de beyondcode/herd-community

Issues similares

Más issues de Backend & API Design

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.