在 Ubuntu 20.04 中删除 protobuf 3.13.0 并将 protobuf 3.6.1 设置为默认值

在 Ubuntu 20.04 中删除 protobuf 3.13.0 并将 protobuf 3.6.1 设置为默认值

我最初安装了 protobuf 3.13.0,然后使用 apt remove 将其删除,但它并没有被删除。

我甚至按照这些说明从源代码安装了 protobuf 3.6.1,但仍然使用 3.13.0 https://askubuntu.com/a/1072684/165324

    $ protoc --version
    libprotoc 3.13.0


    $ sudo apt-get install protobuf-compiler libprotobuf-dev
    
    $ sudo apt remove protobuf-compiler libprotobuf-dev
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Package 'libprotobuf-dev' is not installed, so not removed
    Package 'protobuf-compiler' is not installed, so not removed
    The following packages were automatically installed and are no longer required:
      libprotobuf-lite17 libprotoc17 linux-image-5.4.0-58-generic linux-modules-5.4.0-58-generic
      linux-modules-extra-5.4.0-58-generic
    Use 'sudo apt autoremove' to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 27 not upgraded.
$ sudo apt-get install protobuf-compiler libprotobuf-dev

$ sudo apt remove protobuf-compiler libprotobuf-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'libprotobuf-dev' is not installed, so not removed
Package 'protobuf-compiler' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  libprotobuf-lite17 libprotoc17 linux-image-5.4.0-58-generic linux-modules-5.4.0-58-generic
  linux-modules-extra-5.4.0-58-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 27 not upgraded.

使用以下方式安装 3.6.1:

$ wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-all-3.6.1.tar.gz

$ tar -xvzf protobuf-all-3.6.1.tar.gz 

$ cd protobuf-3.6.1/

$ ./configure

$ make

$ make check

$ sudo make install

$ sudo ldconfig

答案1

我注意到我有:

$ which -a protoc
/home/mona/anaconda3/bin/protoc
/usr/local/bin/protoc

我在 ~/.bashrc 中添加了最后一行:

$ tail ~/.bashrc


alias vi='vim'
aa_prompt_defaults

alias bat='batcat'

alias fd='fdfind'

alias protoc=/usr/local/bin/protoc

然后:

$ source ~/.bashrc

现在:

$ protoc --version
libprotoc 3.6.1

相关内容