1

I am facing an issue so strange in Xubuntu 18.04... I ran the following command after sudo apt update :

sudo apt upgrade

But it leads to an error :

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 linux-image-5.0.0-36-generic : Depends: linux-modules-5.0.0-36-generic but it is not going to be installed
E: Broken packages

I assume that I must install linux-modules-5.0.0-36-generic, but I am not sure and I would do bad things... I am just a beginner in Linux environment.

Some details :

uname -a
>>Linux mistapopo-Aspire-A515-52G 5.0.0-37-generic #40~18.04.1-Ubuntu SMP Thu Nov 14 12:06:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

When I run the following commands

sudo apt update 
sudo apt dist-upgrade

I get the following log :

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
  libllvm8
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
5 not fully installed or removed.
Need to get 0 B/8 426 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up linux-image-unsigned-5.3.1-050301-generic (5.3.1-050301.201909210632) ...
Setting up linux-image-5.3.0-28-generic (5.3.0-28.30~18.04.1) ...
Setting up linux-image-5.3.0-26-generic (5.3.0-26.28~18.04.1) ...
Setting up linux-image-unsigned-5.3.1-050301-lowlatency (5.3.1-050301.201909210632) ...
Processing triggers for linux-image-unsigned-5.3.1-050301-generic (5.3.1-050301.201909210632) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.3.1-050301-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.3.1-050301-lowlatency
Found initrd image: /boot/initrd.img-5.3.1-050301-lowlatency
Found linux image: /boot/vmlinuz-5.3.1-050301-generic
Found initrd image: /boot/initrd.img-5.3.1-050301-generic
Found linux image: /boot/vmlinuz-5.3.0-28-generic
Found initrd image: /boot/initrd.img-5.3.0-28-generic
Found linux image: /boot/vmlinuz-5.3.0-26-generic
Found initrd image: /boot/initrd.img-5.3.0-26-generic
Found linux image: /boot/vmlinuz-5.0.0-37-generic
Found initrd image: /boot/initrd.img-5.0.0-37-generic
Found linux image: /boot/vmlinuz-5.0.0-36-generic
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
/usr/sbin/grub-mkconfig: 295: /usr/sbin/grub-mkconfig: /usr/bin/grub-script-check: not found
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-unsigned-5.3.1-050301-generic (--configure):
 installed linux-image-unsigned-5.3.1-050301-generic package post-installation script subprocess returned error exit status 1
Processing triggers for linux-image-5.3.0-28-generic (5.3.0-28.30~18.04.1) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.3.0-28-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.3.1-050301-lowlatency
Found initrd image: /boot/initrd.img-5.3.1-050301-lowlatency
Found linux image: /boot/vmlinuz-5.3.1-050301-generic
Found initrd image: /boot/initrd.img-5.3.1-050301-generic
Found linux image: /boot/vmlinuz-5.3.0-28-generic
Found initrd image: /boot/initrd.img-5.3.0-28-generic
Found linux image: /boot/vmlinuz-5.3.0-26-generic
Found initrd image: /boot/initrd.img-5.3.0-26-generic
Found linux image: /boot/vmlinuz-5.0.0-37-generic
Found initrd image: /boot/initrd.img-5.0.0-37-generic
Found linux image: /boot/vmlinuz-5.0.0-36-generic
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
/usr/sbin/grub-mkconfig: 295: /usr/sbin/grub-mkconfig: /usr/bin/grub-script-check: not found
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-5.3.0-28-generic (--configure):
 installed linux-image-5.3.0-28-generic package post-installation script subprocess returned error exit status 1
Processing triggers for linux-image-5.3.0-26-generic (5.3.0-26.28~18.04.1) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.3.0-26-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.3.1-050301-lowlatency
Found initrd image: /boot/initrd.img-5.3.1-050301-lowlatency
Found linux image: /boot/vmlinuz-5.3.1-050301-generic
Found initrd image: /boot/initrd.img-5.3.1-050301-generic
Found linux image: /boot/vmlinuz-5.3.0-28-generic
Found initrd image: /boot/initrd.img-5.3.0-28-generic
Found linux image: /boot/vmlinuz-5.3.0-26-generic
Found initrd image: /boot/initrd.img-5.3.0-26-generic
Found linux image: /boot/vmlinuz-5.0.0-37-generic
Found initrd image: /boot/initrd.img-5.0.0-37-generic
Found linux image: /boot/vmlinuz-5.0.0-36-generic
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
/usr/sbin/grub-mkconfig: 295: /usr/sbin/grub-mkconfig: /usr/bin/grub-script-check: not found
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-5.3.0-26-generic (--configure):
 installed linux-image-5.3.0-26-generic package post-installation script subprocess returned error exit status 1
Processing triggers for linux-image-unsigned-5.3.1-050301-lowlatency (5.3.1-050301.201909210632) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.3.1-050301-lowlatency
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.3.1-050301-lowlatency
Found initrd image: /boot/initrd.img-5.3.1-050301-lowlatency
Found linux image: /boot/vmlinuz-5.3.1-050301-generic
Found initrd image: /boot/initrd.img-5.3.1-050301-generic
Found linux image: /boot/vmlinuz-5.3.0-28-generic
Found initrd image: /boot/initrd.img-5.3.0-28-generic
Found linux image: /boot/vmlinuz-5.3.0-26-generic
Found initrd image: /boot/initrd.img-5.3.0-26-generic
Found linux image: /boot/vmlinuz-5.0.0-37-generic
Found initrd image: /boot/initrd.img-5.0.0-37-generic
Found linux image: /boot/vmlinuz-5.0.0-36-generic
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
/usr/sbin/grub-mkconfig: 295: /usr/sbin/grub-mkconfig: /usr/bin/grub-script-check: not found
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-unsigned-5.3.1-050301-lowlatency (--configure):
 installed linux-image-unsigned-5.3.1-050301-lowlatency package post-installation script subprocess returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 linux-image-unsigned-5.3.1-050301-generic
 linux-image-5.3.0-28-generic
 linux-image-5.3.0-26-generic
 linux-image-unsigned-5.3.1-050301-lowlatency
E: Sub-process /usr/bin/dpkg returned an error code (1)
Mistapopo
  • 113

1 Answers1

0

original answer that applies to most users:

When dpkg tries to finish the installation configuration for the kernel it runs grub-script-check when running grub-mkconfig to auto-generate /boot/grub/grub.cfg. If there is a problem with your configuration files, it will return this error. The error says that you have a syntax problem in /etc/default/grub or one of your other grub configuration files in your /etc/default/grub.d directory.

If you recently made changes to any of your grub configuration files like /etc/default/grub or any other file in your /etc/default/grub.d directory, you need to correct or delete the changes made.

After you fix the file or files, run the following command:

sudo dpkg --configure -a

or

sudo apt -f install

See this answer and this detailed example for more information about the grub syntax error.


UPDATE:

Run the following command:

file /usr/bin/grub-script-check

If it returns "no such file or directory" then run:

sudo apt install --reinstall grub-common

Then, run:

sudo dpkg --configure -a

or

sudo apt -f install

Whenever you have a "not found" error you can search for the package name that contains the file at packages.ubuntu.com or you can use the apt-file application but to install apt-file you have to first enable the universe repository: sudo add-apt-repository; sudo apt update.


Here's how I figured it out.

Starting at the end of your output we see two pretty generic errors that doesn't really tell us anything:

E: Sub-process /usr/bin/dpkg returned an error code (1)

and

dpkg: error processing package linux-image-unsigned-5.3.1-050301-lowlatency (--configure):

Now when we scroll up, we see an actual error that tells us something (syntax error):

Syntax errors are detected in generated GRUB config file.

Just above this line, we see exactly when this error occurred:

/usr/sbin/grub-mkconfig: 295: /usr/sbin/grub-mkconfig: /usr/bin/grub-script-check: not found

Now, a file name followed by "not found" usually means a missing file but we also have the syntax error indicating a problem in one of the grub config files.

A number after a file name (/usr/sbin/grub-mkconfig: 295) usually indicates the line number of the file so I looked up the file /usr/sbin/grub-mkconfig and on line 295, it references grub_script_check (/usr/bin/grub-script-check) and later it says to return a syntax error if anything is returned.

In this case, the syntax error wasn't returned by the grub-script-check command, the error was returned by the fact that the grub-script-check command was not found so there was no actual syntax error.

mchid
  • 44,904
  • 8
  • 102
  • 162