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

Since 1.2.1: error Could not open cafile: EISDIR: illegal operation on a directory, read #4695

Closed
hexa00 opened this issue Oct 12, 2017 · 10 comments · Fixed by #4700
Closed

Comments

@hexa00
Copy link

hexa00 commented Oct 12, 2017

What is the current behavior?

Using yarn with workspaces while building Theia I now get erros like:

@theia/cli: > yarn run clean && yarn run build
@theia/cli: npm info lifecycle @theia/[email protected]~prepare: @theia/[email protected]
@theia/cli: error Could not open cafile: EISDIR: illegal operation on a directory, read
@theia/cli: error Could not open cafile: EISDIR: illegal operation on a directory, read

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

You can reproduce with;

git clone https://github.com/theia-ide/theia \
&& cd theia \
&& yarn 

What is the expected behavior?

With yarn 1.0.2 I do not get this error.

Please mention your node.js, yarn and operating system version.
npm --version
5.3.0
OS: linux

Note you can also use this Dockerfile to reproduce:

FROM node:8
RUN useradd --create-home theia
WORKDIR /home/theia
RUN rm -rf /opt/yarn && rm -f /usr/local/bin/yarn && rm -f /usr/local/bin/yarnpkg
RUN apt-get update && apt-get install -y npm && npm install -g [email protected]
USER theia
RUN git clone --depth 1 https://github.com/theia-ide/theia && \
    cd theia && \
    yarn
EXPOSE 3000
WORKDIR /home/theia/theia/examples/browser
CMD yarn run start

You will see the error while doing a docker build -t theia .

@rally25rs
Copy link
Contributor

Closing as a duplicate #4336

@rally25rs
Copy link
Contributor

Oops, my fault... I saw 2 bugs with ESIDIR errors filed less than an hour apart and assumed they were the same. I'll re-open. I started trying to reproduce your case above but I get different errors:

$ run prepare
lerna info version 2.2.0
@theia/ext-scripts: > @theia/[email protected] prepare /Users/jvalore/Projects/theia/dev-packages/ext-scripts
@theia/ext-scripts: > echo 'skip'
@theia/cli: > @theia/[email protected] prepare /Users/jvalore/Projects/theia/dev-packages/cli
@theia/cli: > yarn run clean && yarn run build
@theia/ext-scripts: skip
@theia/core: > @theia/[email protected] prepare /Users/jvalore/Projects/theia/packages/core
@theia/core: > yarn run clean && yarn run build
@theia/core: [lint]
@theia/core: [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/messaging/proxy-factory.ts[95, 15]: missing whitespace
@theia/core: [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[69, 15]: missing whitespace
@theia/core: [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[90, 15]: missing whitespace
@theia/core: [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[110, 15]: missing whitespace
@theia/core: [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[130, 15]: missing whitespace
@theia/core: [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[150, 15]: missing whitespace
@theia/core: [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[170, 15]: missing whitespace
@theia/core: [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[190, 15]: missing whitespace
@theia/core: [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[198, 15]: missing whitespace
@theia/core: [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[218, 15]: missing whitespace
@theia/core: [lint]
@theia/core: [lint] theiaext lint exited with code 2
@theia/core: [compile] theiaext compile exited with code 0
@theia/core: error Command failed with exit code 1.
@theia/core: npm ERR! code ELIFECYCLE
@theia/core: npm ERR! errno 1
@theia/core: npm ERR! @theia/[email protected] prepare: `yarn run clean && yarn run build`
@theia/core: npm ERR! Exit status 1
@theia/core: npm ERR!
@theia/core: npm ERR! Failed at the @theia/[email protected] prepare script.
@theia/core: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@theia/core: npm ERR! A complete log of this run can be found in:
@theia/core: npm ERR!     /Users/jvalore/.npm/_logs/2017-10-12T12_05_23_768Z-debug.log
lerna ERR! execute Error: Command failed: npm run prepare
lerna ERR! execute error Command failed with exit code 1.
lerna ERR! execute npm ERR! code ELIFECYCLE
lerna ERR! execute npm ERR! errno 1
lerna ERR! execute npm ERR! @theia/[email protected] prepare: `yarn run clean && yarn run build`
lerna ERR! execute npm ERR! Exit status 1
lerna ERR! execute npm ERR!
lerna ERR! execute npm ERR! Failed at the @theia/[email protected] prepare script.
lerna ERR! execute npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
lerna ERR! execute
lerna ERR! execute npm ERR! A complete log of this run can be found in:
lerna ERR! execute npm ERR!     /Users/jvalore/.npm/_logs/2017-10-12T12_05_23_768Z-debug.log
lerna ERR! execute
lerna ERR! execute
lerna ERR! execute > @theia/[email protected] prepare /Users/jvalore/Projects/theia/packages/core
lerna ERR! execute > yarn run clean && yarn run build
lerna ERR! execute
lerna ERR! execute [lint]
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/messaging/proxy-factory.ts[95, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[69, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[90, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[110, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[130, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[150, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[170, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[190, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[198, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[218, 15]: missing whitespace
lerna ERR! execute [lint]
lerna ERR! execute [lint] theiaext lint exited with code 2
lerna ERR! execute [compile] theiaext compile exited with code 0
lerna ERR! execute
lerna ERR! execute     at Promise.all.then.arr (/Users/jvalore/Projects/theia/node_modules/execa/index.js:236:11)
lerna ERR! execute     at <anonymous>
lerna ERR! execute     at process._tickCallback (internal/process/next_tick.js:188:7)
lerna ERR! execute  callback with error
lerna ERR! execute  { Error: Command failed: npm run prepare
lerna ERR! execute error Command failed with exit code 1.
lerna ERR! execute npm ERR! code ELIFECYCLE
lerna ERR! execute npm ERR! errno 1
lerna ERR! execute npm ERR! @theia/[email protected] prepare: `yarn run clean && yarn run build`
lerna ERR! execute npm ERR! Exit status 1
lerna ERR! execute npm ERR!
lerna ERR! execute npm ERR! Failed at the @theia/[email protected] prepare script.
lerna ERR! execute npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
lerna ERR! execute
lerna ERR! execute npm ERR! A complete log of this run can be found in:
lerna ERR! execute npm ERR!     /Users/jvalore/.npm/_logs/2017-10-12T12_05_23_768Z-debug.log
lerna ERR! execute
lerna ERR! execute
lerna ERR! execute > @theia/[email protected] prepare /Users/jvalore/Projects/theia/packages/core
lerna ERR! execute > yarn run clean && yarn run build
lerna ERR! execute
lerna ERR! execute [lint]
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/messaging/proxy-factory.ts[95, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[69, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[90, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[110, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[130, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[150, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[170, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[190, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[198, 15]: missing whitespace
lerna ERR! execute [lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[218, 15]: missing whitespace
lerna ERR! execute [lint]
lerna ERR! execute [lint] theiaext lint exited with code 2
lerna ERR! execute [compile] theiaext compile exited with code 0
lerna ERR! execute
lerna ERR! execute     at Promise.all.then.arr (/Users/jvalore/Projects/theia/node_modules/execa/index.js:236:11)
lerna ERR! execute     at <anonymous>
lerna ERR! execute     at process._tickCallback (internal/process/next_tick.js:188:7)
lerna ERR! execute   stack: 'Error: Command failed: npm run prepare\nerror Command failed with exit code 1.\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! @theia/[email protected] prepare: `yarn run clean && yarn run build`\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the @theia/[email protected] prepare script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /Users/jvalore/.npm/_logs/2017-10-12T12_05_23_768Z-debug.log\n\n\n> @theia/[email protected] prepare /Users/jvalore/Projects/theia/packages/core\n> yarn run clean && yarn run build\n\n[lint] \n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/messaging/proxy-factory.ts[95, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[69, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[90, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[110, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[130, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[150, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[170, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[190, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[198, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[218, 15]: missing whitespace\n[lint] \n[lint] theiaext lint exited with code 2\n[compile] theiaext compile exited with code 0\n\n    at Promise.all.then.arr (/Users/jvalore/Projects/theia/node_modules/execa/index.js:236:11)\n    at <anonymous>\n    at process._tickCallback (internal/process/next_tick.js:188:7)',
lerna ERR! execute   code: 1,
lerna ERR! execute   killed: false,
lerna ERR! execute   stdout: '\n> @theia/[email protected] prepare /Users/jvalore/Projects/theia/packages/core\n> yarn run clean && yarn run build\n\n[lint] \n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/messaging/proxy-factory.ts[95, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[69, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[90, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[110, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[130, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[150, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[170, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[190, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[198, 15]: missing whitespace\n[lint] ERROR: /Users/jvalore/Projects/theia/packages/core/src/common/logger.ts[218, 15]: missing whitespace\n[lint] \n[lint] theiaext lint exited with code 2\n[compile] theiaext compile exited with code 0\n',
lerna ERR! execute   stderr: 'error Command failed with exit code 1.\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! @theia/[email protected] prepare: `yarn run clean && yarn run build`\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the @theia/[email protected] prepare script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /Users/jvalore/.npm/_logs/2017-10-12T12_05_23_768Z-debug.log\n',
lerna ERR! execute   failed: true,
lerna ERR! execute   signal: null,
lerna ERR! execute   cmd: 'npm run prepare',
lerna ERR! execute   timedOut: false }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

I did a git clone then a yarn install and got the above.

@rally25rs rally25rs reopened this Oct 12, 2017
@hexa00
Copy link
Author

hexa00 commented Oct 12, 2017

This is because you're using yarn < 1.2.1 you need 1.2.1 otherwise you get into #4687 which is fixed in 1.2.1 only.

Actually I deleted my previous comment about the duplicate since I saw in the latter comments in the thread that the while the original issue was a configuration error with 1.0.1. The issue remained without this config error in 1.2.0.

So it still may be a duplicate, this issue however adds a repro-script so we could drop the need-repro from the tag.

@rally25rs
Copy link
Contributor

Ah, good catch. I have multiple yarn builds running around in different directories and ran the primary Yarn command with 1.2.1, but 1.0.2 is in my path still, so the script commands ended up calling 1.0.2.

If I put 1.2.1 in my path, I see the errors:

lerna ERR! execute Error: Command failed: npm run prepare
lerna ERR! execute error Could not open cafile: EISDIR: illegal operation on a directory, read
lerna ERR! execute error Could not open cafile: EISDIR: illegal operation on a directory, read
lerna ERR! execute error Command failed with exit code 1.

@rally25rs
Copy link
Contributor

I added a line to print the "cafile" that it is trying to load:

$ node_modules/.bin/run prepare

lerna info version 2.2.0
@theia/cli: > @theia/[email protected] prepare /Users/me/Projects/theia/dev-packages/cli
@theia/cli: > yarn run clean && yarn run build
@theia/ext-scripts: > @theia/[email protected] prepare /Users/me/Projects/theia/dev-packages/ext-scripts
@theia/ext-scripts: > echo 'skip'
@theia/ext-scripts: skip
@theia/cli: yarn run v1.2.1
@theia/cli: $ rimraf lib
@theia/cli: error Could not open cafile: /Users/me/Projects/theia/dev-packages/cli : EISDIR: illegal operation on a directory, read

Somehow through this chain of build scripts, Yarn is getting dev-packages/cli as the cafile (SSL certificate file). Clearly that is a directory and not a cert file (hence the EISDIR error).

@hexa00
Copy link
Author

hexa00 commented Oct 12, 2017

Do you see something in the recent changes from 1.0.2 to 1.2.1 that would cause that ?

How is yarn usually getting a cafile ?

@rally25rs
Copy link
Contributor

rally25rs commented Oct 12, 2017

Seems to be caused by #4605

Specifically the line: 3178e07#diff-9d9a6cd82f41984872a66a3ab0d440c4R199

Previously an unset cafile would return empty string , now it returns the project home dir.
Later on:

if (opts.cafile != null && opts.cafile != '') {

but the setting is no longer empty string. It tries to load the home directory as a cert file and throws an EISDIR error.


Edit

Also noticing that if you run yarn install then the cafile option is undefined, however when run as a script cafile is empty string, due to an env variable (set by yarn run or npm run setting up the environment):

npm_config_cafile: ''

This being empty string instead of undefined exposes the flaw in the logic above that changes empty string to the full path.


Edit 2

The env var above is not set by Yarn, it is set by NPM. So, this is a result of a command invoking an npm run which sets a npm_config_cafile: '' then invokes a yarn command, and yarn then tries to resolve the path to the full non-relative path.

@jonaskello
Copy link

I'm seeing the same error on yarn run.

rally25rs added a commit to rally25rs/yarn that referenced this issue Oct 12, 2017
arcanis pushed a commit that referenced this issue Oct 16, 2017
* [#4695] Do not convert empty string to cwd path.

* added test file for config.js
@hexa00
Copy link
Author

hexa00 commented Oct 16, 2017

Thanks!

@rattrayalex-stripe
Copy link

rattrayalex-stripe commented Oct 18, 2017

Is there a workaround available in the meantime? eg; a safe value for export npm_config_file=???

EDIT: unset npm_config_file worked for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants