Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

productionMode not working in RC8 - Windows #207

Open
aoganesi opened this issue Feb 24, 2019 · 6 comments
Open

productionMode not working in RC8 - Windows #207

aoganesi opened this issue Feb 24, 2019 · 6 comments
Labels
windows Windows releated bugs & issues

Comments

@aoganesi
Copy link

Desktop (please complete the following information):

  • OS: Windows
  • JDK version: 8
  • Gradle version: 5.2.1
  • Vaadin Plugin version: 1.0.0.RC8

Describe the bug
I am running into several issues using the "Getting started (no IDE)" sample and turning on productionMode. First, I am following the instructions and I am able to run "gradle jettyRun". Behavior is as expected without any issues. As soon as I specify productionMode = true, I am starting to deal with a cascading set of problems that I will try to describe below

  • All commands below are run using git bash on Windows in myapp folder, but results are exactly same if I run it from Windows command line,

Problem 1.

gradle vaadinTranspileDependencies --info --stacktrace
produces

Execution failed for task ':vaadinTranspileDependencies'.
> java.io.FileNotFoundException: C:\Users\aoganesi\Documents\workspace\myapp\build\frontend\bower_components\webcomponentsjs

In order to proceed, I create the requested folder by hand and re-run the command

Problem 2.

> Task :vaadinTranspileDependencies
Task ':vaadinTranspileDependencies' is not up-to-date because:
  Task has failed previously.
Copying unpacked static resources...
Copying generated styles...
Copying generated templates...
Searching for HTML imports...
Searching for html imports in C:\Users\aoganesi\Documents\workspace\myapp\build\frontend\node_modules
Searching for html imports in C:\Users\aoganesi\Documents\workspace\myapp\build\frontend\bower_components
Searching for html imports in C:\Users\aoganesi\Documents\workspace\myapp\build\webapp-gen\frontend\styles
Searching for resource HTML/JS imports in C:\Users\aoganesi\Documents\workspace\myapp\build\frontend
Using Lumo as base theme...
Filtering 0 theme imports...
Found 0 theme imports
Creating vaadin-flow-bundle-5yvdqvgo0uvvvms2vj8ykueg9.cache.html...
Creating polymer.json...
Creating vaadin-flow-bundle-manifest.json...
Starting process 'command 'C:\Users\aoganesi\Documents\workspace\myapp\.gradle\yarn\yarn-v1.12.3\yarn.cmd''. Working directory: C:\Users\aoganesi\Documents\workspace\myapp\build\frontend Command: C:\Users\aoganesi\Documents\workspace\myapp\.gradle\yarn\yarn-v1.12.3\yarn.cmd --prefer-offline --cwd C:\Users\aoganesi\Documents\workspace\myapp\build\frontend run polymer-bundler --inline-scripts --manifest-out=C:\Users\aoganesi\Documents\workspace\myapp\build\frontend\vaadin-flow-bundle-manifest.json vaadin-flow-bundle-5yvdqvgo0uvvvms2vj8ykueg9.cache.html
Successfully started process 'command 'C:\Users\aoganesi\Documents\workspace\myapp\.gradle\yarn\yarn-v1.12.3\yarn.cmd''
Transpiling...
Starting process 'command 'C:\Users\aoganesi\Documents\workspace\myapp\.gradle\yarn\yarn-v1.12.3\yarn.cmd''. Working directory: C:\Users\aoganesi\Documents\workspace\myapp\build\frontend Command: C:\Users\aoganesi\Documents\workspace\myapp\.gradle\yarn\yarn-v1.12.3\yarn.cmd --prefer-offline --cwd C:\Users\aoganesi\Documents\workspace\myapp\build\frontend run polymer build --npm --module-resolution=node
Successfully started process 'command 'C:\Users\aoganesi\Documents\workspace\myapp\.gradle\yarn\yarn-v1.12.3\yarn.cmd''
Validating transpilation...

> Task :vaadinTranspileDependencies FAILED
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':vaadinTranspileDependencies'.
> Transpile did not generate ES5 result in C:\Users\aoganesi\Documents\workspace\myapp\build\frontend\build\frontend-es5. Run with --info to get more information.

It's not immediately obvious what went wrong here, but some more digging explains that the issue is caused by the plugin throwing the exception when it does not find the frontend-es5 folder that was supposed to be generated by the yarn command. Conveniently the command is available in the console, so, next, I turn my attention to it and attempt to run it manually as follows:

  • cd to the C:\Users\aoganesi\Documents\workspace\myapp\build\frontend as my working directory
  • run "C:\Users\aoganesi\Documents\workspace\myapp\.gradle\yarn\yarn-v1.12.3\yarn.cmd" --prefer-offline --cwd C:\Users\aoganesi\Documents\workspace\myapp\build\frontend run polymer build --npm --module-resolution=node. (Note that I added double quotes around the yarn.cmd to be able to run it from git bash) which results in the following response.
'node' is not recognized as an internal or external command,
operable program or batch file.

This leads me to believe that something is not right with paths to nodejs that was auto-downloaded by Gradle or the plugin (I am a bit out of my depth here, because I don't exactly understand which part of the infrastructure is responsible for downloading and installing nodejs/yarn). I decided that the path of least resistance for me at this point is to download and install both tools manually and make sure that they are available in the path.

  • I install both into c:\DevTools\nodejs and c:\DevTools\Yarn respectively
  • Make sure that the PATH has been appended with C:\DevTools\nodejs;C:\DevTools\Yarn\bin\
  • re-run gradle task -- same exception
  • re-run the yarn.cmd command below and now get a different path-related problem
$ "C:\Users\aoganesi\Documents\workspace\myapp\.gradle\yarn\yarn-v1.12.3\yarn.cmd" --prefer-offline --cwd C:\Users\aoganesi\Documents\workspace\myapp\build\frontend run polymer build --npm --module-resolution=node
yarn run v1.12.3
error Directory "C:\\Users\\aoganesi\\Documents\\workspace\\myapp\\build\\frontend\\UsersaoganesiDocumentsworkspacemyappbuildfrontend" doesn't exist

if I re-run the command adding double-quotes around the path parameter everything works as follows

$ "C:\Users\aoganesi\Documents\workspace\myapp\.gradle\yarn\yarn-v1.12.3\yarn.cmd" --prefer-offline --cwd "C:\Users\aoganesi\Documents\workspace\myapp\build\frontend" run polymer build --npm --module-resolution=node
yarn run v1.12.3
$ C:\Users\aoganesi\Documents\workspace\myapp\.gradle\nodejs\node-v10.14.1-win-x64\node.exe ./node_modules/polymer-cli/bin/polymer.js build --npm --module-resolution=node
info:   Clearing build\ directory...
Done in 3.79s.

At this point I am not really sure how to proceed. The issue seems to be OS/path related (possibly plugin is not calling yarn commands with quotes) or it's possible that I am just missing some simple bit of understanding that would have saved me a ton of grief.

Thank you very much for reading through my issue. I would greatly appreciate any pointers in the right direction!

Tony

@aoganesi aoganesi changed the title productionMode not working in RC8 - WIndows productionMode not working in RC8 - Windows Feb 24, 2019
@johndevs
Copy link
Member

Hi Tony, thanks for the thorough walk trough of the issue!

I tried to reproduce the issue in Windows 10 with both PowerShell and Command Prompt and it seemed to resolve the paths correctly and build the es5/es6 frontend folders.

I also tested git bash and it seemed to work ok as well. However, since it is a emulated environment I would not recommend running in it as I don't know how well Gradle works in that and it might trigger some hard to solve issues where Gradle thinks its running on Unix.

The only advice I can give you is try to run on PowerShell and see if you get the same result?

Since Windows isn't my daily OS maybe I'm missing something obvious as well :)

@aoganesi
Copy link
Author

Hi John,
Thank you very much for looking into this.

  • Unfortunately in my environment it does not work from PowerShell either
  • I also tried to run the task from IntelliJ with same results

It's definitely an OS-specific issue. (My environment is on "Windows Server 2008 R2").

  • Is there anything else I could try before giving up and going with Maven?
  • Is there an option for me to write a custom task that would manually run the yarn commands with double-quotes surrounding the path?

@aoganesi
Copy link
Author

Some more information after further experimentation with git bash vs regular windows command line. I may have mis-interpreted the failure and incorrectly assumed that it had something to do with properly quoted paths. Attached please find the execution result of the following command:
gradle vaadinTranspileDependencies --debug > run.txt
run.txt

In this file it shows that at least one yarn command seems to be executing just fine. What am I missing?

@johndevs johndevs added the windows Windows releated bugs & issues label Feb 25, 2019
@johndevs
Copy link
Member

In this file it shows that at least one yarn command seems to be executing just fine. What am I missing?

It is not really Yarn that is failing for you, it is the polymer CLI command:

C:\Users\aoganesi\Documents\workspace\myapp.gradle\nodejs\node-v10.14.1-win-x64\node.exe ./node_modules/polymer-cli/bin/polymer.js build --npm --module-resolution=node

That should create the frontend es5/es6 directories, but it is claiming it succeeded even though it did not do anything. Here is the correct output from it from when it is working:

yarn run v1.12.3
$ ./node_modules/polymer-cli/bin/polymer.js build --npm --module-resolution=node
info:	Clearing build/ directory...
info:	(frontend-es6) Building...
info:	(frontend-es5) Building...
info:	(frontend-es6) Build complete!
info:	(frontend-es5) Build complete!
Done in 42.00s.

The Polymer CLI has this bug where it successfully completes when bundling even though it failed somewhere internally. Usually it has to do with wrong relative paths in the templates (as discovered here #147).

You could try to create a simple app with gradle vaadinCreateProject and check if it works with production mode. Then you can start minimizing your real app to see where the problems are.

Of course it can also be something related to polymer.js not resolving correctly the paths on Windows Server 2008 which starts to be quite old.

@aoganesi
Copy link
Author

The sample run that I am sharing is produced from the myapp generated by vaadinCreateProject. so I think that means that the issue is environment specific on my server. I will try to dig into polymer.js

@johndevs
Copy link
Member

@corinara I split your issue out of this issue into its own issue as it is most likely not related.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
windows Windows releated bugs & issues
Development

No branches or pull requests

2 participants