Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching between pnpm and npm is broken on first try when cleaning the project #11177

Closed
pleku opened this issue Jun 8, 2021 · 4 comments · Fixed by #14259
Closed

Switching between pnpm and npm is broken on first try when cleaning the project #11177

pleku opened this issue Jun 8, 2021 · 4 comments · Fixed by #14259

Comments

@pleku
Copy link
Contributor

pleku commented Jun 8, 2021

To reproduce:

  1. take a v20 Vaadin Spring Boot project, test that it works
  2. swap to npm by adding vaadin.pnpm.enable =false to application.properties
  3. clean the project with mvn clean
  4. rerun the project.
    Steps 3+4 can be combined with mvn clean spring-boot:run.

Expected: project works

Actual: npm/pnpm install fails due to missing target/flow-frontend/package.json

Rerunning the project will work.

It seems that there is some broken logic in

  1. https://github.com/vaadin/flow/blob/master/vaadin-dev-server/src/main/java/com/vaadin/base/devserver/startup/DevModeInitializer.java#L351
  2. https://github.com/vaadin/flow/blob/master/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskGeneratePackageJson.java#L68

but neither of these are a problem because they just make the TaskGeneratePackgeJson always create the file, but in the end something is still removing it, - investigation to be continued.

@pleku pleku added this to Needs triage in OLD Vaadin Flow bugs & maintenance (Vaadin 10+) via automation Jun 8, 2021
@pleku pleku changed the title Switching between pnpm and npm is broken Switching between pnpm and npm is broken on first try when cleaning the project Jun 8, 2021
@pleku pleku moved this from Needs triage to New P2 in OLD Vaadin Flow bugs & maintenance (Vaadin 10+) Jun 8, 2021
@pleku
Copy link
Contributor Author

pleku commented Jun 8, 2021

The issue is with TaskRunNpnInstall which deletes /node_modules folder when it detects that it has pnpm-related files. For deleting the folder, it uses commons-io FileUtils.forceDelete(packageUpdater.nodeModulesFolder); which is broken for Windows, as it should not follow into deleting symlinks, but there is some bug that makes it not see symlink folders (at least in this case) as symlinks. And thus it will delete the just created /target/flow-frontend/ folder which will cause the npm install to fail.

To be tested with commons-io 2.9.0 if it fixes the issue, as flow is using 2.8.0 at the moment.

And for some reason, I was not able to anymore get the project to fail when going from npm -> pnpm.

@pleku
Copy link
Contributor Author

pleku commented Jun 8, 2021

commons-io version 2.9.0 has the same issue, the folder is not recognized as symbolic link and gets deleted

WindowsFileAttributes-Symlink-issue

@mshabarov
Copy link
Contributor

Needs a re-check because commons-io has been upgraded in Flow to 2.11.0, so this issue might be fixed by this upgrade.

@mshabarov mshabarov self-assigned this Oct 11, 2021
@pleku
Copy link
Contributor Author

pleku commented Nov 24, 2021

This is still broken in commons-io 2.11.0 and Vaadin 22.0.0.rc1

[qtp64797628-30] ERROR com.vaadin.flow.server.DefaultErrorHandler -
java.lang.IllegalStateException: com.vaadin.flow.server.ExecutionFailedException: Couldn't remove C:\Users\Pekka\workspaces\flow\skeleton-starter-flow\node_modules directory
        at com.vaadin.base.devserver.AbstractDevServerRunner.getCause(AbstractDevServerRunner.java:772)
        at com.vaadin.base.devserver.AbstractDevServerRunner.getCause(AbstractDevServerRunner.java:768)
        at com.vaadin.base.devserver.AbstractDevServerRunner.handleRequest(AbstractDevServerRunner.java:634)
        at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1567)
        at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:299)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:791)
        at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1626)
        at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:228)
        at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
        at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:602)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1435)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:191)
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.Server.handle(Server.java:516)
        at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
        at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
        at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:773)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:905)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.vaadin.flow.server.ExecutionFailedException: Couldn't remove C:\Users\Pekka\workspaces\flow\skeleton-starter-flow\node_modules directory
        at com.vaadin.flow.server.frontend.TaskRunNpmInstall.runNpmInstall(TaskRunNpmInstall.java:315)
        at com.vaadin.flow.server.frontend.TaskRunNpmInstall.execute(TaskRunNpmInstall.java:153)
        at com.vaadin.flow.server.frontend.NodeTasks.execute(NodeTasks.java:913)
        at com.vaadin.base.devserver.startup.DevModeInitializer.runNodeTasks(DevModeInitializer.java:397)
        at com.vaadin.base.devserver.startup.DevModeInitializer.lambda$initDevModeHandler$0(DevModeInitializer.java:326)
        at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)
        at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.io.IOException: Cannot delete file: C:\Users\Pekka\workspaces\flow\skeleton-starter-flow\node_modules
        at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1344)
        at com.vaadin.flow.server.frontend.TaskRunNpmInstall.cleanUp(TaskRunNpmInstall.java:548)
        at com.vaadin.flow.server.frontend.TaskRunNpmInstall.runNpmInstall(TaskRunNpmInstall.java:313)
        ... 11 more
Caused by: java.nio.file.NoSuchFileException: C:\Users\Pekka\workspaces\flow\skeleton-starter-flow\node_modules\.pnpm\@babel\core@7.16.0\node_modules\@babel\code-frame
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:86)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:523)
        at java.base/java.nio.file.Files.newDirectoryStream(Files.java:472)
        at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:300)
        at java.base/java.nio.file.FileTreeWalker.next(FileTreeWalker.java:373)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2761)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2797)
        at org.apache.commons.io.file.PathUtils.visitFileTree(PathUtils.java:971)
        at org.apache.commons.io.file.PathUtils.deleteDirectory(PathUtils.java:434)
        at org.apache.commons.io.file.PathUtils.delete(PathUtils.java:391)
        at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1341)
        ... 13 more
[WARNING] handleException / java.io.IOException: Cannot delete file: C:\Users\Pekka\workspaces\flow\skeleton-starter-flow\node_modules
[qtp64797628-28] ERROR com.vaadin.flow.server.DefaultErrorHandler -
java.lang.IllegalStateException: com.vaadin.flow.server.ExecutionFailedException: Couldn't remove C:\Users\Pekka\workspaces\flow\skeleton-starter-flow\node_modules directory
        at com.vaadin.base.devserver.AbstractDevServerRunner.getCause(AbstractDevServerRunner.java:772)
        at com.vaadin.base.devserver.AbstractDevServerRunner.getCause(AbstractDevServerRunner.java:768)
        at com.vaadin.base.devserver.AbstractDevServerRunner.handleRequest(AbstractDevServerRunner.java:634)
        at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1567)
        at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:299)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:791)
        at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1626)
        at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:228)
        at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
        at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:602)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1435)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:191)
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.Server.handle(Server.java:516)
        at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
        at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
        at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:773)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:905)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.vaadin.flow.server.ExecutionFailedException: Couldn't remove C:\Users\Pekka\workspaces\flow\skeleton-starter-flow\node_modules directory
        at com.vaadin.flow.server.frontend.TaskRunNpmInstall.runNpmInstall(TaskRunNpmInstall.java:315)
        at com.vaadin.flow.server.frontend.TaskRunNpmInstall.execute(TaskRunNpmInstall.java:153)
        at com.vaadin.flow.server.frontend.NodeTasks.execute(NodeTasks.java:913)
        at com.vaadin.base.devserver.startup.DevModeInitializer.runNodeTasks(DevModeInitializer.java:397)
        at com.vaadin.base.devserver.startup.DevModeInitializer.lambda$initDevModeHandler$0(DevModeInitializer.java:326)
        at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)
        at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.io.IOException: Cannot delete file: C:\Users\Pekka\workspaces\flow\skeleton-starter-flow\node_modules
        at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1344)
        at com.vaadin.flow.server.frontend.TaskRunNpmInstall.cleanUp(TaskRunNpmInstall.java:548)
        at com.vaadin.flow.server.frontend.TaskRunNpmInstall.runNpmInstall(TaskRunNpmInstall.java:313)
        ... 11 more
Caused by: java.nio.file.NoSuchFileException: C:\Users\Pekka\workspaces\flow\skeleton-starter-flow\node_modules\.pnpm\@babel\core@7.16.0\node_modules\@babel\code-frame
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:86)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:523)
        at java.base/java.nio.file.Files.newDirectoryStream(Files.java:472)
        at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:300)
        at java.base/java.nio.file.FileTreeWalker.next(FileTreeWalker.java:373)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2761)
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2797)
        at org.apache.commons.io.file.PathUtils.visitFileTree(PathUtils.java:971)
        at org.apache.commons.io.file.PathUtils.deleteDirectory(PathUtils.java:434)
        at org.apache.commons.io.file.PathUtils.delete(PathUtils.java:391)
        at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1341)
        ... 13 more
[WARNING] handleException /sw.js java.io.IOException: Cannot delete file: C:\Users\Pekka\workspaces\flow\skeleton-starter-flow\node_modules

OLD Vaadin Flow bugs & maintenance (Vaadin 10+) automation moved this from New P2 to Closed Aug 8, 2022
vaadin-bot pushed a commit that referenced this issue Aug 8, 2022
Fix removal of node_modules so that
symlink and Windows junction directory
contents are not deleted also.

Fixes #14138
Closes #11177
vaadin-bot pushed a commit that referenced this issue Aug 8, 2022
Fix removal of node_modules so that
symlink and Windows junction directory
contents are not deleted also.

Fixes #14138
Closes #11177
mshabarov pushed a commit that referenced this issue Aug 8, 2022
Fix removal of node_modules so that
symlink and Windows junction directory
contents are not deleted also.

Fixes #14138
Closes #11177

Co-authored-by: caalador <mikael.grankvist@vaadin.com>
caalador added a commit that referenced this issue Aug 9, 2022
Fix removal of node_modules so that
symlink and Windows junction directory
contents are not deleted also.

Fixes #14138
Closes #11177
# Conflicts:
#	flow-server/src/test/java/com/vaadin/flow/server/frontend/FrontendUtilsTest.java
caalador added a commit that referenced this issue Aug 9, 2022
Fix removal of node_modules so that
symlink and Windows junction directory
contents are not deleted also.

Fixes #14138
Closes #11177
taefi pushed a commit that referenced this issue Aug 9, 2022
Fix removal of node_modules so that
symlink and Windows junction directory
contents are not deleted also.

Fixes #14138
Closes #11177
taefi pushed a commit that referenced this issue Aug 9, 2022
Fix removal of node_modules so that
symlink and Windows junction directory
contents are not deleted also.

Fixes #14138
Closes #11177
taefi pushed a commit that referenced this issue Aug 9, 2022
Fix removal of node_modules so that
symlink and Windows junction directory
contents are not deleted also.

Fixes #14138
Closes #11177

Co-authored-by: caalador <mikael.grankvist@vaadin.com>
vaadin-bot pushed a commit that referenced this issue Aug 9, 2022
Fix removal of node_modules so that
symlink and Windows junction directory
contents are not deleted also.

Fixes #14138
Closes #11177
mcollovati pushed a commit that referenced this issue Aug 9, 2022
Fix removal of node_modules so that
symlink and Windows junction directory
contents are not deleted also.

Fixes #14138
Closes #11177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants