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

Schematics : Copy then delete can cause "This should never happen" error.

Abierto
#16,527 0 comentarios 7 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
angular, typescript
Área
tooling

Línea de trabajo

Empieza ejecutando la reproducción mínima de la especificación esquemática del issue, especialmente cuando el Tree es creado por otro Schematic. Después, inspecciona el comportamiento de Copy/Delete de Tree y la regla Move en @angular-devkit/schematics/src/rules. La tarea estará terminada cuando el caso de Copy-then-delete ya no produzca “This should never happen” y la regla Move ya no informe de ENOENT.

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

Descripción

area: @angular-devkit/schematics freq1: low severity3: broken type: bug/fix

🐞 Bug report

Description

Moving files as part of a schematic can cause an error to be thrown:

  Message:
    Error: This should never happen. Path: "/projects/bar".

It seems to happen if those files were created by a previous rule and the move is done by copy and deletion.

(As an aside here, it seems that delete operations are hoisted somehow...whenever they occur in a schematic, the logger output shows them to always happen first, this is not what I'd expect)

I'm aware that there is a move rule in @angular-devkit/schematics/src/rules, but this does not work. Attempting to use this rule to move files from one folder to another results in this error: ENOENT: no such file or directory, rename '<source>' -> '<destination>'

🔬 Minimal Reproduction

export function move(schema: Schema): Rule {
  return (host: Tree, _context: SchematicContext): Tree => {
    const dir = host.getDir(schema.source);
    dir.visit(file => {
      const newPath = file.replace(schema.source, schema.destination);

      const buffer = host.read(file);
      if (buffer === null) {
        return;
      }

      host.create(newPath, buffer);
    });

    host.delete(schema.source);

    return host;
  };
}

See also: https://github.com/jdpearce/move-schematic

NB - this schematic will probably work if run against a pre-existing workspace, but when the tree is set up by another schematic, as in the spec file, that's when the error is thrown.

🌍 Your Environment

Angular CLI: 8.3.21
Node: 13.5.0
OS: darwin x64
Angular: undefined
...

Package Version

@angular-devkit/architect 0.803.21 (cli-only)
@angular-devkit/core 8.3.21
@angular-devkit/schematics 8.3.21
@schematics/angular 8.3.21
@schematics/update 0.803.21 (cli-only)
rxjs 6.5.4
typescript 3.5.3

Lenguaje dominante
TypeScript
Estrellas
27k
Forks
11.8k
Merge medio
17 h 25 min
PR fusionados (30 d)
183

Guía de contribución

Abrir la guía de contribución

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 angular/angular-cli

Todos los issues de angular/angular-cli

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.