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

"jhipster upgrade" not working properly #5883

Closed
jdubois opened this issue Jun 6, 2017 · 34 comments
Closed

"jhipster upgrade" not working properly #5883

jdubois opened this issue Jun 6, 2017 · 34 comments
Milestone

Comments

@jdubois
Copy link
Member

jdubois commented Jun 6, 2017

As we have basically 4 duplicate tickets on the JHipster upgrade sub-generator, I'm closing #5881 #5869 #5811 #5649 in favor of this new "meta ticket".

It's basically all the same issue: on some systems, the upgrade sub-generator cannot update the JHipster version. Typically, this is because it doesn't have the right to do. Then, there are various other issues depending on how it was installed.

This is why this failing for a lot of people, with different error messages depending on their own configuration and how they installed JHipster. And we can't always reproduce as it depends on our own setup.

This was mostly triggered by the use of Yarn: this adds one more installation mechanism, and it depends on how Yarn was installed.

There is also the issue of people upgrading their JHipster version globally, and then the sub-generator gets stuck with that global version.

-> I'm not sure this is true for everyone, so here is how to test this: say you are using JHipster 4.5.1, do a "jhipster upgrade". You will have a commit telling the application was re-generated with JHipster 4.5.1 (in the commit message). Have a look in the commit, if it's in fact generated with JHipster 4.5.2 (you can see it in package.json), then you have the issue of a global JHipster installation that you can't modify

This is so complex, and doing an upgrade isn't such a big deal to do manually, that I'm considering removing this sub-generator (cc @lordlothar99 as you coded this originally).

We just don't have the time to work on this -> would someone be interested in taking this ticket?

@deepu105
Copy link
Member

deepu105 commented Jun 6, 2017

Agree 100% with you. But I would really hate to remove this but then if we cannot maintain it we dont have a choice. Since we now have a CLI we have more freedom now so if someone is interested to fix this or find a simpler solution that would be great. Ofcourse there are many ways in which we can make it work but we just dont have the time to spend on it

@atomfrede
Copy link
Member

Me personally has never used the sub generator (maybe because of my development setup). I always do the update manually, so removing it would be totally ok for me.

@mraible
Copy link
Contributor

mraible commented Jun 6, 2017

I've used this sub generator quite a bit and it's made it easy for me to easily maintain tutorials over several months, rather than having to re-write them for the latest release.

I haven't experienced an issue where the JHipster version can't be upgraded. Does that only happen on particular operating systems? I haven't seen it on macOS Sierra.

@jdubois
Copy link
Member Author

jdubois commented Jun 7, 2017

Another (related) issue comes from the CLI:

  • Now the upgrade sub-generator uses the CLI, but for older versions it didn't exist
  • So if someone upgrades his generator to the latest version, and then runs it to upgrade an older version (a bad idea, of course), it won't work

@mraible
Copy link
Contributor

mraible commented Jun 9, 2017

I'm able to confirm that this sub generator did NOT work for me when trying to upgrade from 4.5.2 to 4.5.3.

@tan9
Copy link
Contributor

tan9 commented Jun 11, 2017

The upgrade sub-generator helped me a lot aligning to the latest jhipter.

I stuck at JHipster 4.5.1 on my Windows and Linux machine for more than one week, and following the clues @jdubois provided, I can reproduce the issue as:

  1. yarn global add generator-jhipster
  2. perform jhipster upgrade
  3. found commit Generated with JHipster 4.5.1 in jhipster_upgrade branch is identical to the following commit Generated with JHipster 4.5.3, all code generated in both commits were generated by the global Jhipster 4.5.3. Hence nothing different to be merged into master!

Then I tried to downgrade the global jhipster:

  1. yarn global remove generator-jhipster & yarn globa add [email protected]
  2. perform jhipster upgrade
  3. found both commits in jhipster_upgrade were all generated using JHipster 4.5.1. Still failed to generate diff to be take to master.

To prevent the global jhipster dominate the local code generation, I found a workaround:

  1. yarn global remove generator-jhipster
  2. alias jhipster=./node_modules/.bin/jhipster or export PATH=$(npm bin):$PATH
  3. jhipster upgrade , then things finally goes well as expected!

@mraible
Copy link
Contributor

mraible commented Jun 12, 2017

I just tried the steps you outlined in 3: remove generator-jhipster from yarn global install, export PATH=$(npm bin):$PATH, then running yo jhipster:upgrade.

It seemed to work, but in the end, the only change made on my master branch is versions changed in yarn.lock.

± which jhipster
/Users/mraible/dev/21-points/node_modules/.bin/jhipster
[mraible:~/dev/21-points] master ± yo jhipster:upgrade
Welcome to the JHipster Upgrade Sub-Generator
This will upgrade your current application codebase to the latest JHipster version
Looking for latest generator-jhipster version...
New generator-jhipster version found: 4.5.3
Git repository detected
Created branch jhipster_upgrade
Cleaned up directory
Installing JHipster 4.5.2 locally
Installed [email protected]
Regenerating app with jhipster 4.5.2...
Successfully regenerated app with jhipster 4.5.2
Committed with message "Generated with JHipster 4.5.2"
Checked out branch "master"
Current code recorded as generated with version 4.5.2
Updating generator-jhipster to 4.5.3 . This might take some time...
Updated generator-jhipster to version 4.5.3
Checked out branch "jhipster_upgrade"
Cleaned up directory
Regenerating app with jhipster 4.5.3...
Successfully regenerated app with jhipster 4.5.3
Committed with message "Generated with JHipster 4.5.3"
Checked out branch "master"
Merging changes back to master...
Merge done!
Installing dependencies, please wait...

Upgraded successfully. Please now fix conflicts if any, and commit!
[mraible:~/dev/21-points] master(+12/-26,4) 4m52s ± git status
On branch master
Your branch is ahead of 'origin/master' by 4 commits.
  (use "git push" to publish your local commits)
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   yarn.lock

no changes added to commit (use "git add" and/or "git commit -a")

@tan9
Copy link
Contributor

tan9 commented Jun 13, 2017

@mraible Would you please start over again with jhipster upgrade instead of yo jhipster:upgrade?

And you can check the content of package.json at commit "Generated with JHipster 4.5.2" and "Generated with JHipster 4.5.3".

@mraible
Copy link
Contributor

mraible commented Jun 14, 2017

@tan9 I tried using jhipster upgrade and it does work. I believe yo jhipster:upgrade might've too because I had the same yarn.lock issue as above.

@mraible
Copy link
Contributor

mraible commented Jun 14, 2017

Yep, just confirmed that yo jhipster:upgrade did indeed work on macOS Sierra 10.12.5. I upgraded from 4.5.2 to 4.5.3.

@henri-tremblay
Copy link
Contributor

henri-tremblay commented Jun 16, 2017

On my side, I tried 4.5.2 to 4.5.3 and failed. With jhipster upgrade. This happens

Welcome to the JHipster Upgrade Sub-Generator
This will upgrade your current application codebase to the latest JHipster version
Looking for latest generator-jhipster version...
New generator-jhipster version found: 4.5.3
Git repository detected
Updating generator-jhipster to 4.5.3 . This might take some time...
Updated generator-jhipster to version 4.5.3
events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: ERROR! Unable to checkout branch jhipster_upgrade:
error: Your local changes to the following files would be overwritten by checkout:
	package.json
Please commit your changes or stash them before you switch branches.
Aborting

    at Environment.error (node_modules/yeoman-environment/lib/environment.js:89:38)
    at constructor.error (node_modules/generator-jhipster/generators/generator-base.js:1514:18)
    at gitExec (node_modules/generator-jhipster/generators/upgrade/index.js:60:34)
    at node_modules/shelljs/src/exec.js:204:9
    at ChildProcess.exithandler (child_process.js:259:5)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:887:16)
    at Socket.stream.socket.on (internal/child_process.js:340:11)
    at emitOne (events.js:115:13)

Which seems to be

  1. Upgrade the jhipster version in package.json
  2. Try to change the branch to jhipster_upgrade but fails since package.json is modified locally

No one is having this?

@mraible
Copy link
Contributor

mraible commented Jun 16, 2017

I'd suggest trying to delete your local jhipster_upgrade branch first.

git branch -D jhipster_upgrade

@henri-tremblay
Copy link
Contributor

henri-tremblay commented Jun 16, 2017

Am I now supposed to get it forever to simplify merge?

@henri-tremblay
Copy link
Contributor

But, indeed, deleting the branch worked

@deepu105
Copy link
Member

deepu105 commented Jun 17, 2017 via email

@henri-tremblay
Copy link
Contributor

henri-tremblay commented Jun 17, 2017 via email

@tan9
Copy link
Contributor

tan9 commented Jun 17, 2017

@mraible , @deepu105 I encountered the same issue as @henri-tremblay , and I overcame the issue by just commit the changed package.json or just reset it. And start over the jhipster upgrade without deleting the jhipster_upgrade branch.

As the error message said:

Error: ERROR! Unable to checkout branch jhipster_upgrade:
error: Your local changes to the following files would be overwritten by checkout:
	package.json

What happened actually is the version of ng-jhipster in package.json was updated accidentally in the source branch rather the in the jhipster_upgrade branch.

@henri-tremblay
Copy link
Contributor

henri-tremblay commented Jun 17, 2017 via email

@tan9
Copy link
Contributor

tan9 commented Jun 19, 2017

@henri-tremblay What does "didn't worked" mean?
Is there any error messages, and what's the git branch and status after fail upgrading?

@henri-tremblay
Copy link
Contributor

@tan9 Sorry. I don't remember. It is possible that I've ended up with a modified yarn.lock but no nothing migrated at all. I was in the master branch. I know, this isn't really helpful. It's not in my shell history anymore.

@tan9
Copy link
Contributor

tan9 commented Jun 21, 2017

I can upgrade my project from 4.5.4 to 4.5.5 by executing:

$ export PATH=node_modules/.bin/:$PATH
$ jhipster upgrade --with-entities
$ git commit -a -m "Upgraded JHipster to 4.5.5."
$ jhipster upgrade --with-entities

@henri-tremblay Would you please remove the entire jhipster_upgrade and run again?

@henri-tremblay
Copy link
Contributor

henri-tremblay commented Jun 21, 2017 via email

@TranQuangTienSA
Copy link
Contributor

TranQuangTienSA commented Jun 22, 2017

I created a PR. I fix some issues in _generate function and the sequence of default steps.

I tested upgrade from 4.4.0 and 4.5.2 to 4.5.5.

There is an issue, when you add other dependencies to the project.

Overview of the issue

Test scenario:

  1. Generate new project with jhipster 4.4.0
  2. Add new dependency yarn add ng2-formio and modify some code.
  3. Commit all changes to master.
  4. Run jhipster upgrade

Problem:

Almost thing work well until install step. Because there is conflict in package.json file then yarn command will be failed.

Motivation for or Use Case

Fix this issue, of course.

Reproduce the error
  1. Generate new project with jhipster 4.4.0
  2. Add new dependency yarn add ng2-formio and modify some code.
  3. Commit all changes to master.
  4. Run jhipster upgrade
Related issues

PR #5966

Suggest a Fix

Prompt a warning message and wait until the user resolve the conflict package.json then continue remain steps.

JHipster Version(s)

4.5.3

JHipster configuration
JHipster configuration, a .yo-rc.json file generated in the root folder
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.example.jhipster",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "4.4.0",
    "baseName": "jhipster",
    "packageName": "com.example.jhipster",
    "packageFolder": "com/example/jhipster",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "hibernateCache": "ehcache",
    "clusteredHttpSession": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "jwtSecretKey": "3c212f5b83b803075e927d1032f4a74e54db6898",
    "clientFramework": "angular2",
    "useSass": false,
    "clientPackageManager": "yarn",
    "applicationType": "monolith",
    "testFrameworks": [
      "cucumber"
    ],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en",
      "vi"
    ]
  }
}
Entity configuration(s) entityName.json files generated in the .jhipster directory

ls: no such file or directory: .jhipster/*.json

Browsers and Operating System

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

git version 2.13.1

node: v8.1.2

npm: 5.0.3

bower: 1.8.0

gulp:
[10:07:19] CLI version 3.9.1

yeoman: 1.8.5

yarn: 0.24.6

Docker version 17.03.1-ce, build c6d412e

docker-compose version 1.11.2, build dfed245

Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System

Mac OS X Sierra 10.12.5
iTerm 2 + fish shell

  • Checking this box is mandatory (this is just to show you read everything)

@TranQuangTienSA
Copy link
Contributor

@jdubois could you please give me some comments on the above issue.

@oaj
Copy link

oaj commented Jul 26, 2017

I have been working on a project for more than a year with jhipster 3.10.0 and I'm ready to go to production. I tried to upgrade to the latest version. And I too found that it did'nt work. Before I tried to upgrade I zipped the directory with the project. I unzipped and now the project wont even build -

xxxxxxx@x53s-mint ~/projects/colony $ ./gradlew
:cleanResources
:bootBuildInfo
:bower
:nodeSetup SKIPPED
:gulpConstantDev
/home/amfibia/projects/colony/node_modules/node-sass/lib/binding.js:13
throw new Error(errors.unsupportedEnvironment());
^

Error: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (57)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v3.12.2
at module.exports (/home/amfibia/projects/colony/node_modules/node-sass/lib/binding.js:13:13)
at Object. (/home/amfibia/projects/colony/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/home/amfibia/projects/colony/node_modules/gulp-sass/index.js:187:21)
:gulpConstantDev FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':gulpConstantDev'.

Process 'command 'node'' finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

What should I do to save it ?

@TranQuangTienSA
Copy link
Contributor

@oaj could you follow the issue template and give more information. I would like to help.

@pascalgrimaud
Copy link
Member

3.10.0 to 4.6.2 is a big big jump...

@PierreBesson
Copy link
Contributor

@oaj When you zip/unzip files you lose permissions on Linux so that might be the cause of the issue. Try running yarn and yarn add -f node-sass. But please next time use stack overflow for those kind of requests.

@oaj
Copy link

oaj commented Jul 26, 2017

@PierreBesson - You nailed it, now I can build the 3.10.0 again - Thank you very much. Also thanks to @tientq for your willingness to help out.
@pascalgrimaud - I know - I was focused on the coding all the time. I actually spend a few days resolving the merge conflicts - even though the building of the dependencies failed. The two days of works is saved and I think I can us it for a manual upgrade.

@pascalgrimaud
Copy link
Member

pascalgrimaud commented Jul 26, 2017

@oaj : yes, manually upgrade is better, because the 4.0.0 introduced some breaking changes for you:

  • JHipster server side library
  • constructor based injection

See details here: https://jhipster.github.io/2017/02/02/jhipster-release-4.0.0.html

@oaj
Copy link

oaj commented Jul 28, 2017

I did a manual upgrade according to the release notes, without upgrading my entities at first. And I let 'jhipster' overwrite everything. When i ran ./gradlew I got 7 compile errors in the files under /config

`amfibia@x53s-mint ~/projects/colony $ ./gradlew

Task :compileJava
/home/amfibia/projects/colony/src/main/java/net/amfibia/colony/config/SecurityConfiguration.java:67: error: reference to AjaxAuthenticationSuccessHandler is ambiguous
public AjaxAuthenticationSuccessHandler ajaxAuthenticationSuccessHandler() {
^
both class io.github.jhipster.security.AjaxAuthenticationSuccessHandler in io.github.jhipster.security and class net.amfibia.colony.security.AjaxAuthenticationSuccessHandler in net.amfibia.colony.security match
/home/amfibia/projects/colony/src/main/java/net/amfibia/colony/config/SecurityConfiguration.java:72: error: reference to AjaxAuthenticationFailureHandler is ambiguous
public AjaxAuthenticationFailureHandler ajaxAuthenticationFailureHandler() {
^
both class io.github.jhipster.security.AjaxAuthenticationFailureHandler in io.github.jhipster.security and class net.amfibia.colony.security.AjaxAuthenticationFailureHandler in net.amfibia.colony.security match
/home/amfibia/projects/colony/src/main/java/net/amfibia/colony/config/SecurityConfiguration.java:77: error: reference to AjaxLogoutSuccessHandler is ambiguous
public AjaxLogoutSuccessHandler ajaxLogoutSuccessHandler() {
^
both class io.github.jhipster.security.AjaxLogoutSuccessHandler in io.github.jhipster.security and class net.amfibia.colony.security.AjaxLogoutSuccessHandler in net.amfibia.colony.security match
/home/amfibia/projects/colony/src/main/java/net/amfibia/colony/config/SecurityConfiguration.java:82: error: reference to Http401UnauthorizedEntryPoint is ambiguous
public Http401UnauthorizedEntryPoint http401UnauthorizedEntryPoint() {
^
both class io.github.jhipster.security.Http401UnauthorizedEntryPoint in io.github.jhipster.security and class net.amfibia.colony.security.Http401UnauthorizedEntryPoint in net.amfibia.colony.security match
/home/amfibia/projects/colony/src/main/java/net/amfibia/colony/config/apidoc/SwaggerConfiguration.java:32: error: cannot find symbol
@Profile(Constants.SPRING_PROFILE_SWAGGER)
^
symbol: variable SPRING_PROFILE_SWAGGER
location: class Constants
/home/amfibia/projects/colony/src/main/java/net/amfibia/colony/config/apidoc/PageableParameterBuilderPlugin.java:30: error: cannot find symbol
@Profile(Constants.SPRING_PROFILE_SWAGGER)
^
symbol: variable SPRING_PROFILE_SWAGGER
location: class Constants
/home/amfibia/projects/colony/src/main/java/net/amfibia/colony/config/HerokuDatabaseConfiguration.java:15: error: cannot find symbol
@Profile(Constants.SPRING_PROFILE_HEROKU)
^
symbol: variable SPRING_PROFILE_HEROKU
location: class Constants
7 errors
`

@lafalangito
Copy link

Sorry, but i can upgrade my jhipster.... I did this:
first: yarn global remove generator-jhipster
then: yarn global add generator-jhipster,
result==>success Installed "[email protected]" with binaries:
- jhipster
Done in 6.87s.

But when i execute yo jhipster:


JHipster update available: 4.14.3 (current: 4.14.0)

Run yarn global upgrade generator-jhipster to update.


Its making me crazy....

thanks

@gmarziou
Copy link
Contributor

gmarziou commented May 4, 2018

Maybe you have installed generator-jhipster globally with both yarn and npm and your path is pointing to wrong one. Uninstall from both and install only with one. Also you did not give any information on your environment so we can't help you. If you are on Windows run where jhipster otherwise run which jhipster to know which command you execute. Last, don't use yo.

@tvprasad
Copy link

tvprasad commented Jan 8, 2019

I faced the same problem. I tried all tips and nothing worked.

Upgrade smoothly completed once I commented out below line as showing in screenshots ../generator/upgrade/index.js
//this.error('Exiting process');
screenshot from 2019-01-08 12-18-22
screenshot from 2019-01-08 12-18-52

This is not recommend for all but worked for me and aware of other risks.
Hope it helps someone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests