简体   繁体   中英

Installing yarn on docker file: gpg: [don't know]: partial length invalid for packet type 63

I'm having more trouble installing Yarn. Install yarn global on Docker file

In my last question, I found the steps to run after the image is first built but running it fails.

Dockerfile

FROM ruby:2.7.2
SHELL ["/bin/bash", "-c"]

RUN apt-get update -qq && \
  apt-get install -y nodejs libvips-tools libsodium-dev

# We need Chromedriver.
# RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
#   echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list && \
#   apt-get install -y google-chrome-stable && \
#   CHROMEVER=$(google-chrome --product-version | grep -o "[^\.]*\.[^\.]*\.[^\.]*") && \
#   DRIVERVER=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROMEVER") && \
#   wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$DRIVERVER/chromedriver_linux64.zip" && \
#   unzip /chromedriver/chromedriver* -d /chromedriver

# Install all gems first.
# This hits the warm cache if unchanged so bundling is faster.
COPY Gemfile* /tmp/
WORKDIR /tmp
RUN bundle install

WORKDIR /sapco
COPY . /sapco

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - # This line fails
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn
RUN yarn global add mjml

The error output is:

------
#13 0.362 Warning: apt-key output should not be parsed (stdout is not a terminal)
#13 0.377 gpg: [don't know]: partial length invalid for packet type 63
#13 0.377 gpg: read_block: read error: Invalid packet
#13 0.377 gpg: import from '-' failed: Invalid keyring
------

I was able to run so I don't think it's too related to gpg not working.

RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add ```

For future visitors, if your issue is similar to what Python Steve 's comment describes, you can fix it by converting your key-file to ASCII text encoding.

Use file command to check this:

> file gpg_key.asc
gpg_key.asc: Little-endian UTF-16 Unicode text, with CRLF line terminators

Use following command to correct it:

> iconv -f UTF-16 -t US-ASCII gpg_key.asc -o gpg_key_output.asc

Note: Somehow, -o option might not be available. So, you can replace -o with > symbol in above command to indicate that you want to save output in the mentioned file.

If you retry the file command:

> file gpg_key_output.asc
gpg_key_output.asc: ASCII text, with CRLF line terminators

Now, you can import your keys.

I borrowed this answer from another answer. You can see the source answer in more detail here .


In my case, this happened to me because I attached my gpg keys to .kdbx key entry in KeePass software. And, when I tried to reuse my keys by retrieving them from .kdbx storage, I faced this issue. Here's the exact error:

gpg: [don't know]: partial length invalid for packet type 63
gpg: read_block: read error: Invalid packet
gpg: import from 'gpg_key.asc' failed: Invalid keyring
gpg: Total number processed: 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM