Category Archives: Linux

Solve git upload file error [rejected] master -> master (fetch first) error: failed to push some refs to ‘

When push is executed, an error will be reported. The error code is as follows:

$ git push -u origin master
To gitee.com:backspacegit/aafdajs.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'gitee.com:backspacegit/aafdajs.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

This problem occurs because the readme.md file in GitHub is not in the local code directory. You can merge the code with the following command

git pull --rebase origin master

Then execute the statement

git push -u origin master

Done!

CentOS 7 composer install error: phpunit/phpunit 4.8.35 requires ext-dom *

Problem:
[[email protected] laravel_demo]# composer install Loading composer repositories with package information

Installing dependencies (including require-dev) from lock file

Your requirements could not be resolved to an installable set of packages.

Problem 1

– phpunit/phpunit 4.8.35 requires ext-dom * -> the requested PHP extension dom is missing from your system.

– phpunit/phpunit 4.8.35 requires ext-dom * -> the requested PHP extension dom is missing from your system.

– Installation request for phpunit/phpunit 4.8.35 -> satisfiable by phpunit/phpunit[4.8.35].

To enable extensions, verify that they are enabled in your .ini files:

– /etc/php.ini

– /etc/php.d/bz2.ini

– /etc/php.d/calendar.ini

– /etc/php.d/ctype.ini

– /etc/php.d/curl.ini

– /etc/php.d/exif.ini

– /etc/php.d/fileinfo.ini

– /etc/php.d/ftp.ini

– /etc/php.d/gd.ini

– /etc/php.d/gettext.ini

– /etc/php.d/gmp.ini

– /etc/php.d/iconv.ini

– /etc/php.d/json.ini

– /etc/php.d/ldap.ini

– /etc/php.d/mbstring.ini

– /etc/php.d/mcrypt.ini

– /etc/php.d/mysqli.ini

– /etc/php.d/pdo.ini

– /etc/php.d/pdo_mysql.ini

– /etc/php.d/pdo_sqlite.ini

– /etc/php.d/phar.ini

– /etc/php.d/shmop.ini

– /etc/php.d/simplexml.ini

– /etc/php.d/sockets.ini

– /etc/php.d/sqlite3.ini

– /etc/php.d/tokenizer.ini

– /etc/php.d/xml.ini

– /etc/php.d/zip.ini

You can also run `php –ini` inside terminal to see which files are used by PHP in CLI mode.

Solution:
[[email protected] ~]# yum search php70w    Check the packages available for installation
[[email protected] ~]# yum -y install php70w-xml.x86_64
[[email protected] ~]# systemctl restart httpd.service restart apache
Test:
[[email protected] ~]# systemctl restart httpd.service
[[email protected] ~]# cd /home/www/laravel_demo/
[[email protected] laravel_demo]# composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 0 installs, 2 updates, 0 removals
– Updating symfony/event-dispatcher (v3.2.4 => v3.2.3): Downloading (100%)
– Updating symfony/yaml (v3.2.4 => v3.2.3): Downloading (100%)
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
Generating optimized class loader

Solved: could not find the task ‘G + + build active file, leetcode algorithm ACM compilation and debugging

Project scenario:

Environment: Ubuntu 20.04

Tool: vscode

Because leetcode can’t debug the code (for members), it’s necessary to configure the local environment to run the code.

Leetcode’s code is to help you configure all the environments. You only need to write the core code, but you need to write all the code yourself during the interview. It’s ACM mode (Baidu ACM). At this time, if you don’t often write all the code, it’s easy to be confused (this is what happened when I was deeply convinced in the online interview)

So it’s necessary to configure the local environment and write the whole process of algorithm implementation, including the compilation process and principle of cpp file, and the debug process can make you more familiar with the code running process.

Reference for compiling environment configuration: https://code.visualstudio.com/docs/cpp/config-linux

No Baidu, no Baidu! Look at the official statement is always the best!!! If you don’t understand English, you can right-click to translate the web page directly.

My task.json configuration: it is automatically generated. The configuration of the computer and the environment is different, so this file may be different.

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C/C++: g++ Generate activity files",
			"command": "/usr/bin/g++",
			"args": ["-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}"],
			"options": {
				"cwd": "${fileDirname}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			},
			"detail": "Compilers: /usr/bin/g++"
		}
	]
}

My launch.json:

{
    "version": "0.2.0",
    "configurations": [
      {
        "name": "g++ build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "setupCommands": [
          {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
          }
        ],
        "preLaunchTask": "g++ build active file",
        "miDebuggerPath": "/usr/bin/gdb"
      }
    ]
  }

Problem Description.
I encountered the following situation when configuring task.json for compiling C++ and debugging configuration file launch.json.


Cause Analysis.
Code encountered problems suggest direct google …
Reference: https://stackoverflow.com/questions/59106732/visual-studio-code-debugger-error-could-not-find-the-task-gcc-build-active-f

In your task.json file, no task is labeled as ‘gcc build active file’ which is required as a preLaunchTask in launch.json file.

So you can either change the label of task or change the content of preLaunchTask to make them match.

The answer is clear: task.json file this configuration

"label": "C/C++: g++ Generate activity files",

This configuration must be the same as launch. JSON

"preLaunchTask": "g++ build active file",

Solution:

Configure task.json as follows:

"label": "C/C++: g++ Generate activity files",

To be amended as follows:

"label": "g++ build active file",

—————————The following can be ignored———————————-

As long as the two values are the same. You can be like this: (yes, that’s what I changed it to.)

"label": "g++ build active file  hahaha",

Ubuntu: rabbitmq reports an error; Solution error: unable to connect to node [email protected] : nodedown

When installing rabbitmq and executing rabbitmqctl status, the errors are as follows:

the first thing is to check the log file and form a good habit here’s my list:

[email protected]:/# cd /var/log/rabbitmq/
[email protected]:/var/log/rabbitmq# ls
[email protected]  [email protected]  startup_err  startup_log
# Afterwards, execute the view
cat [email protected]

As shown in the figure:

my reason is that port 5672 is occupied by other applications, so rabbitmq can’t be used. Just modify the port

[Solved] Ubuntu pyinstaller Error when packaging executable file: … qt.qpa.plugin: Could not find the Qt platform plugin “xcb“ in “…

Ubuntu pyinstaller Error when packaging the executable: … qt.qpa.plugin: Could not find the Qt platform plugin “xcb” in “…
Solution to the problem


Problem
Ubuntu pyinstaller reports an error when packaging the executable: .QFactoryLoader::QFactoryLoader() checking directory path “/home/dyj/CarUI/dist/carmain/platforms” … qt.qpa.plugin: Could not find the Qt platform plugin “xcb” in “” This application failed to start because no Qt platform plugin could be initialized.
Solution
Add the following code to your own main program code.

import os
import PySide2
dirname = os.path.dirname(PySide2.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

Errors encountered when configuring static ip on Ubuntu 18.04

Description:

Because many test environments are installed on this Ubuntu system, but due to the restart or power failure of the virtual server, every time the IP changes, the environment must be updated, so the ip of the environment needs to be configured as static, once and for all.

According to the previous experience of configuring Ubuntu static ip, directly vi /etc/network/interfaces configured static ip under this file, and it did not take effect after resetting the network.

So I checked the ubuntu version, it was 18.04, and Baidu found that “ubuntu has given up the fixed IP configuration in /etc/network/interfaces since 17.10. Even the configuration will not take effect. Instead, it is changed to netplan and the configuration is written In /etc/netplan/01-netcfg.yaml or a yaml file with a similar name”, so I configured according to the method found, but I encountered a lot of errors and almost vomited blood. Write down the errors I encountered here.

1, the beginning of the configuration is as follows: in the implementation apply netplan error message occurs Invalid YAML at //etc/netplan/01-netcfg.yaml line 11 column 11 : mapping values are not allowed in this context

Solution: yaml is a hierarchical structure and needs to be indented. A colon (:) means a dictionary, a hyphen (-) means a list, and there must be a space after the colon.

2. After adding a space after the colon (as shown below), execute netplan apply and report an error: Invalid YAML at //etc/netplan/01-netcfg.yaml line 11 column 6: did not find expected key

Solution: nameservers should be the fourth layer like gateway4, and the addresses after nameservers should be the fifth layer

The correct number of layers is as follows:

The first layer- network:
The second layer-ethernets:
The third layer- ens33:
The fourth layer- addresses: [172.18.0.31/24]
The fourth floor–gateway4: 172.18.0.1
The fourth layer-nameservers:
The fifth layer- addresses: [114.114.114.114, 8.8.8.8]

3. After solving according to the above method, execute netplan apply and report an error as shown below : Error in network definition //etc/netplan/01-netcfg.yaml line 8 column 16: expected scalar

Solution: The address of gateway4 does not have square brackets. After the modification, restart the network service and it will be normal netplan apply )

 

So the correct configuration format should be as follows: In this way, the static ip is successfully configured

 

Errors that I did not encounter:

A similar error appears: line8 column 6:cloud not find expected’:’ #The   prompt is a colon: no space is added after it
A similar error occurred: netplan found character that cannot start any token , #The prompt is that the configuration document is not written according to five levels, and the next level must be one or more empty than the previous level.
In short: here an error is reported when the network is restarted, most of which are incorrect levels, incorrect format, and no spaces

Solve the error report of the find command: paths must precede expression

I want to clear some pdf files in the server /tmp directory, about 10,000 files, when I execute the command

find /tmp -maxdepth 1 -mtime 30 -name *.pdf

An error occurred:

find : paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]

Then I checked it on the Internet, and I found an article. It probably said: When searching for multiple files, you need to add single quotation marks. Double quotation marks have always been used. I didn’t expect to use single quotation marks when looking for multiple files. Well, I learned another trick. After modification:
find ./ -mtime +30 -type f -name’*.php’
so that no more errors will be reported after execution, and a small problem will be solved.
Example explanation:
# Enter the tmp directory Create 4 new text files
# cd /tmp
# touch {1,2,3,4}.txt
# find .-name *.txt
find: paths must precede expression: 2.txt

This prompt appears because the asterisk is expanded to For all files in the current directory, such matching will of course be wrong. Look at this to know:
# echo *
1.txt 2.txt 3.txt 4.txt
# echo’*’
*
# echo \*
*

If you want the asterisk not to be expanded, you need to add parentheses or backslashes to escape , Knowing these we will know how to find
# find. -Name’*.txt’
find.
-Name ‘*.txt’ ./4.txt
./2.txt
./3.txt
./1.txt #Or
use backslash to
 find .-name \*.txt
./4.txt
./2.txt
./3.txt
./1.txt

Nginx Startup Error: “/var/run/nginx/nginx.pid” failed” [How to Solve]

problem:

  After restarting the virtual machine, restarting nginx again will report an error: open() “/var/run/nginx/nginx.pid” failed (2: No such file or directory)

Solution:

  (1) Enter the cd /usr/local/nginx/conf/ directory and edit the configuration file nginx.conf;

  (2) There is a comment in the configuration file: #pid logs/nginx.pid;

 (3) Release the comment and modify it to: pid /usr/local/nginx/logs/nginx.pid;

  (4) Create a logs directory under the /usr/local/nginx directory: mkdir /usr/local/nginx/logs

  (5) Start nginx service: /usr/local/nginx/sbin/nginx

[Solved] Job for network.service failed because the control process exited with error code. See “systemctl st

Job for network.service failed because the control process exited with error code. See “systemctl status network.service” and “journalctl -xe” for details.

1、 The xshell is down and the reconnection failed. First Ping to see if the network is connected. Second, restart the network service and find an error. Third, view the error information according to the prompt. Fourth, solutions. First, check whether the configuration file is wrong. Second, there may be a conflict with the network manager service. Just close the service directly

3. If the two methods 1 and 2 still fail, try to delete all the other irrelevant network card location files under/etc/sysconfig/network scripts to avoid unnecessary influence. 5. Verify the network

Standby for a while, found that xshell connection failed, found that network connection failed, and restart failed.

1、 The xshell is down and the reconnection failed. Ping first to see if the network is connected

[[email protected] ~]# ping www.google.com
ping: www.google.com: Unknown name or service

2、 Restart the network service and find an error

[[email protected] ~]# systemctl restart network
Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.

3、 Check the error information according to the prompt

[[email protected] ~]# systemctl status network.service
● network.service - LSB: Bring up/down networking
   Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since 四 2021-06-03 05:23:42 CST; 23s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8821 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)

6月 03 05:23:42 db01 network[8821]: RTNETLINK answers: File exists
6月 03 05:23:42 db01 network[8821]: RTNETLINK answers: File exists
6月 03 05:23:42 db01 network[8821]: RTNETLINK answers: File exists
6月 03 05:23:42 db01 network[8821]: RTNETLINK answers: File exists
6月 03 05:23:42 db01 network[8821]: RTNETLINK answers: File exists
6月 03 05:23:42 db01 network[8821]: RTNETLINK answers: File exists
6月 03 05:23:42 db01 systemd[1]: network.service: control process exited, code=e...s=1
6月 03 05:23:42 db01 systemd[1]: Failed to start LSB: Bring up/down networking.
6月 03 05:23:42 db01 systemd[1]: Unit network.service entered failed state.
6月 03 05:23:42 db01 systemd[1]: network.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

4、 Solutions

1. Check whether the configuration file is wrong

[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
NAME=ens33
UUID=b5672928-cbbb-4428-a752-8bd9c14098e7
····
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.10.102
PREFIX=24
GATEWAY=192.168.10.2
DNS1=114.114.114.114
DNS2=8.8.8.8
DNS3=119.29.29.29
[[email protected] ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:0c:29:3f:0f:29 brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:3a:15:b7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:3a:15:b7 brd ff:ff:ff:ff:ff:ff

2. There may be a conflict with the NetworkManager service. Just close the service directly

[[email protected] ~]# systemctl stop NetworkManager
[[email protected] ~]# systemctl restart network

3. If both methods 1 and 2 fail after verification, try to delete all other irrelevant network card location files under/etc/sysconfig/network scripts to avoid unnecessary influence

[[email protected] network-scripts]# ls
ifcfg-ens33      ifdown-ipv6      ifdown-tunnel  ifup-isdn    ifup-TeamPort
ifcfg-ens33.bak  ifdown-isdn      ifup           ifup-plip    ifup-tunnel
ifcfg-lo         ifdown-post      ifup-aliases   ifup-plusb   ifup-wireless
ifdown           ifdown-ppp       ifup-bnep      ifup-post    init.ipv6-global
ifdown-bnep      ifdown-routes    ifup-eth       ifup-ppp     network-functions
ifdown-eth       ifdown-sit       ifup-ib        ifup-routes  network-functions-ipv6
ifdown-ib        ifdown-Team      ifup-ippp      ifup-sit
ifdown-ippp      ifdown-TeamPort  ifup-ipv6      ifup-Team

5、 Verification Network

[[email protected] ~]# ping www.google.com
PING www.baidu.com (39.156.66.14) 56(84) bytes of data.
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=1 ttl=128 time=55.8 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=2 ttl=128 time=42.8 ms
^C
--- www.baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 42.825/49.312/55.800/6.491 ms
[[email protected] ~]# 

[Solved] Win10 and Linux address reading format is different (CV2. Error: opencv (4.2.0)/Io/opencv…)

img = cv2.resize(img, (512, 1024))
cv2.error: OpenCV(4.2.0) /io/opencv/modules/imgproc/src/resize. cpp:4045 : error: (-215:Assertion failed) ! ssize.empty() in function ‘resize’

The code can run normally in win10, but the above error is reported in Linux. My analysis is due to the different address reading formats between win10 and Linux.

img   = cv2.imread(item['path'])
#item['path']:'./data/TuSimple/LaneDetection\clips/0313-2/42120/20.jpg'

There is a ‘\’ in the address of item [‘path ‘], which results in an error in Linux operation
so change the’ \ ‘in the address of item [‘path’] to ‘/’

item['path']=item['path'].replace('\\', '/')#Add this code
img   = cv2.imread(item['path'])