Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn fails and doesn't provide information when running inside Docker #1460

Closed
felixsanz opened this issue Oct 25, 2016 · 5 comments
Closed

Comments

@felixsanz
Copy link

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

An unexpected error occured, please open a bug report with the information provided in "/usr/src/app/yarn-error.log".

If the current behavior is a bug, please provide the steps to reproduce.

I don't know, I can't check the error :)

What is the expected behavior?

It should print errors directly to stdout/stderr. I'm trying to build a Docker image and it fails. But since this happens inside the container (and destroyed on the error step), I can't check that yarn-error.log because it doesn't exist anymore.

Please mention your node.js, yarn and operating system version.

Yarn 0.16.1 using Docker

@Daniel15
Copy link
Member

Daniel15 commented Oct 26, 2016

Hi @felixsanz! Is that happening when you run yarn install in the Docker container? You could try cat the log file when the error occurs, and see what it contains. I recently wrote some end-to-end tests for Yarn using Docker (#1391) and this is what I did via a fail_with_log utility function:

#!/bin/bash
# Executed within a fresh Docker container to test execution of Yarn.
# Should be executed after Yarn has been installed.
set -ex

fail_with_log() {
  # Include the yarn-error.log file in the output, if available
  exitcode=$?
  if [ -s yarn-error.log ]; then
    cat yarn-error.log
  fi;
  exit $exitcode
}

cd /tmp
mkdir yarntest
cd yarntest
yarn add react || fail_with_log

Is your container running Ubuntu by any chance? If so, you'll need to install the ca-certificates package in order for TLS/SSL to work from Node.js. That's the issue I encountered when trying to run Yarn in Docker 😄

@Daniel15
Copy link
Member

The other alternative is to mount a directory (-v flag to docker run) and run Yarn in that directory. Then you'll be able to look at the log file on your host machine.

@felixsanz
Copy link
Author

I'm gonna close this because deleting the yarn.lock file fixed the issue and i don't get the error anymore. Probably it was messed up while i was trying builds. If happens again i'll try your suggestions and comment here again. Thanks!

@JoshuaKGoldberg
Copy link

JoshuaKGoldberg commented Apr 13, 2018

I'm in a similar situation with VSTS build machines. @Daniel15 your suggested steps are great 😊 thanks!

I resolved the problem by adding a cmd task that runs if a previous task has failed and prints the contents of yarn-error.log if it exists:

if exist yarn-error.log echo "Found error output in yarn-error.log:" && type yarn-error.log && del yarn-error.log

Edit: ...and a PowerShell equivalent:

$yarnErrorFile = "yarn-error.log"

if (Test-Path $yarnErrorFile)
{
    Write-Output "Found error output in $yarnErrorFile"
    Get-Content $yarnErrorFile | Write-Output
    Remove-Item $yarnErrorFile
}

@nkalinov
Copy link

Fast forwarding to 2022 and Yarn 2+ that's what helped me debug the issue: yarn install --inline-builds https://yarnpkg.com/cli/install#options-inline-builds

@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Mar 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants