Can not change update-alternatives mvn

8,006

I had modified the ~/.profile PATH variable, so the only thing I had to do is to comment out the line and log in again.

.profile

...
#export PATH=/opt/maven/apache-maven-3.3.9/bin:$PATH
...
Share:
8,006

Related videos on Youtube

Joe
Author by

Joe

Updated on September 18, 2022

Comments

  • Joe
    Joe almost 2 years

    Ubuntu 14.04

    After installing and changing the version of mvn via `update-alternatives, the configuration remains unchanged.

    Steps

    1. Install new version mvn

      sudo update-alternatives --install /usr/bin/mvn mvn /opt/maven/apache-maven-3.5.0/bin/mvn 100
      
    2. Check alternatives

      $ sudo update-alternatives --config mvn
      There are 2 choices for the alternative mvn (providing /usr/bin/mvn).
      
        Selection    Path                                   Priority   Status
      ------------------------------------------------------------
      * 0            /opt/maven/apache-maven-3.3.9/bin/mvn   100       auto mode
        1            /opt/maven/apache-maven-3.3.9/bin/mvn   100       manual mode
        2            /opt/maven/apache-maven-3.5.0/bin/mvn   10        manual mode
      
      Press enter to keep the current choice[*], or type selection number: 2
      update-alternatives: using /opt/maven/apache-maven-3.5.0/bin/mvn to provide /usr/bin/mvn (mvn) in manual mode
      
    3. Change alternative to new one

      $ sudo update-alternatives --config mvn
      There are 2 choices for the alternative mvn (providing /usr/bin/mvn).
      
        Selection    Path                                   Priority   Status
      ------------------------------------------------------------
        0            /opt/maven/apache-maven-3.3.9/bin/mvn   100       auto mode
        1            /opt/maven/apache-maven-3.3.9/bin/mvn   100       manual mode
      * 2            /opt/maven/apache-maven-3.5.0/bin/mvn   10        manual mode
      
      Press enter to keep the current choice[*], or type selection number: 2 
      
    4. Check mvn version

      $ mvn --version
      Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
      Maven home: /opt/maven/apache-maven-3.3.9
      Java version: 1.8.0_111, vendor: Oracle Corporation
      Java home: /opt/java/jdk1.8.0_111/jre
      Default locale: ca_ES, platform encoding: UTF-8
      OS name: "linux", version: "3.13.0-116-generic", arch: "amd64", family: "unix"
      

    type command output:

    $ type -a mvn
    mvn is /opt/maven/apache-maven-3.3.9/bin/mvn
    mvn is /usr/bin/mvn
    
    • Admin
      Admin about 7 years
      Add the output of type -a mvn, please.
    • Admin
      Admin about 7 years
      @muru I added it to the question
    • Admin
      Admin about 7 years
      Your PATH probably has /opt/maven/apache-maven-3.3.9/bin in it. Remove it and try again.
    • Admin
      Admin about 7 years
      It seems to be this, but I commented with # in .profile but it is still apearing in env and set, I'll try rebooting
    • Admin
      Admin about 7 years
      you might have to login again.
    • Admin
      Admin about 7 years
      Yes, that was the problem!
    • Admin
      Admin about 7 years
      You can post what you edited from your .profile as an answer.
    • Admin
      Admin over 5 years
      This question solved my problem :D Thanks for the very detailed question ;)