oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.24k stars 2.77k forks source link

`error: IsDir` when running `bun install` #168

Closed jamiehaywood closed 2 years ago

jamiehaywood commented 2 years ago

Platform: MacOS 11.6.5

Crash log:

error: IsDir

–––– bun meta ––––
Bun v0.0.82 macOS x64 20.6.0
InstallCommand: 
Elapsed: 1ms | User: 1ms | Sys: 4ms
RSS: 3.06MB | Peak: 3.06MB | Commit: 0.27GB | Faults: 195
–––– bun meta ––––

Ask for #help in https://bun.sh/discord or go to https://bun.sh/issues
Jarred-Sumner commented 2 years ago

Strange - could you paste the package.json as well?

Most likely, this means somewhere a system call that expects a file is being called on a directory, but the question is where/what

jamiehaywood commented 2 years ago

I've removed identifying information in the package.json & also remove a couple of internal packages:

{
  "name": "xxx",
  "version": "2.41.3",
  "description": "xxx",
  "repository": "xxx",
  "author": "xxx",
  "license": "UNLICENSED",
  "engines": {
    "node": "14.19.1"
  },
  "scripts": {
    "start": "concurrently --kill-others --raw \"npm run build:app:watch\" \"npm run serve:app -- --env=$env\"",
    "start:test": "cross-env NODE_OPTIONS=--max_old_space_size=4096 yarn build:app && yarn serve:app:test",
    "debug": "concurrently --kill-others --raw \"npm run build:app:watch\" \"npm run serve:app:debug -- --env=$env\"",
    "build:app": "cross-env NODE_ENV=development webpack --config tools/webpack/webpack.config.dev.babel.js --colors",
    "build:app:watch": "cross-env NODE_ENV=development webpack --config tools/webpack/webpack.config.dev.babel.js --colors --watch",
    "serve:app": "cross-env NODE_ENV=development nodemon build/server/server.js --config config/nodemon.json --delay 1",
    "serve:app:debug": "cross-env NODE_ENV=development nodemon --inspect build/server/server.js --config config/nodemon.json --delay 1",
    "serve:app:test": "cross-env NODE_ENV=test nodemon build/server/server.js --config config/nodemon.json",
    "############ Build ############": "################################################",
    "build:local": "webpack --config config/webpack/local/webpack.local.config.js --colors --progress --watch",
    "build": "cross-env NODE_ENV=production webpack --config tools/webpack/webpack.config.prod.babel.js --colors && yarn install:externals",
    "build:prod:local": "cross-env NODE_ENV=development webpack --config tools/webpack/webpack.config.prod.babel.js --colors --progress",
    "install:externals": "cd build/server && yarn",
    "############ Tests ############": "################################################",
    "test": "jest",
    "test:coverage": "jest --coverage --coverageReporters='text' --no-cache -i",
    "test:ci": "jest --ci --runInBand --coverage",
    "test:dev": "jest --no-cache -i",
    "test:ss": "jest --updateSnapshot",
    "test:watch": "jest --watch -o",
    "sonar": "sonar-scanner",
    "cy:open": "cypress open",
    "cy:run": "cypress run --browser chrome --headless",
    "cy:verify": "cypress verify",
    "cy:info": "cypress info",
    "cy:ci": "start-test 'start:test' http-get://localhost:8000 'yarn cy:run'",
    "############ Miscellaneous ############": "#########################################",
    "generate:webp": "node --loader ts-node/esm webp-converter.ts",
    "commit": "npx git-cz",
    "semantic-release": "HUSKY=0 semantic-release",
    "release:dryrun": "yarn semantic-release --no-ci --dry-run",
    "prepare": "husky install"
  },
  "dependencies": {
    "@loadable/component": "^5.14.1",
    "animejs": "^3.1.0",
    "await-to-js": "^3.0.0",
    "aws-sdk": "^2.802.0",
    "axios": "^0.19.1",
    "body-parser": "^1.19.0",
    "braintree-web": "^3.63.0",
    "check-ie": "^2.0.1",
    "concurrently": "^5.3.0",
    "connect-redis": "^3.3.0",
    "credit-card-type": "^8.3.0",
    "dayjs": "^1.10.7",
    "dd-trace": "^1.0.0",
    "deepmerge": "^4.2.2",
    "express": "^4.17.1",
    "express-fileupload": "^1.2.0",
    "express-session": "^1.17.2",
    "express-static-gzip": "^2.0.7",
    "file-saver": "^2.0.5",
    "file-type": "^16.0.1",
    "formik": "^2.1.4",
    "frameguard": "^3.1.0",
    "gm": "^1.23.1",
    "helmet": "^3.23.3",
    "hoist-non-react-statics": "^3.3.2",
    "iframe-resizer": "^4.2.10",
    "ioredis": "^4.28.5",
    "isomorphic-fetch": "^2.2.1",
    "jose": "^4.5.0",
    "js-cookie": "^2.2.1",
    "js-sha256": "^0.9.0",
    "jsonwebtoken": "^8.5.1",
    "libphonenumber-js": "^1.9.32",
    "lodash": "^4.17.19",
    "mobx": "^6.3.5",
    "mobx-react": "^7.2.1",
    "morgan": "^1.9.1",
    "no-scroll": "^2.1.1",
    "nodemon": "^2.0.15",
    "path": "^0.12.7",
    "plur": "^4.0.0",
    "postcode-validator": "^3.0.0",
    "prettyjson": "^1.2.1",
    "promisescript": "^2.0.0",
    "query-string": "^7.1.1",
    "rc-slider": "^9.2.4",
    "react": "^16.11.0",
    "react-albus": "^2.0.0",
    "react-collapsible": "^2.6.2",
    "react-day-picker": "^7.4.0",
    "react-dom": "16.13.1",
    "react-helmet": "^6.1.0",
    "react-iframe-resizer-super": "^0.2.2",
    "react-input-mask": "^2.0.4",
    "react-measure": "^2.3.0",
    "react-modal": "^3.11.2",
    "react-notification-system": "^0.2.14",
    "react-router": "^3.2.2",
    "react-router-dom": "^5.2.0",
    "react-scrollable-anchor": "^0.6.1",
    "react-slick": "^0.26.1",
    "react-svg-inline": "^2.1.1",
    "react-tabs": "^3.1.0",
    "react-waypoint": "^9.0.3",
    "redis": "^2.7.1",
    "sanitize-filename": "^1.6.3",
    "sitemap-webpack-plugin": "^0.8.1",
    "smoothscroll-polyfill": "^0.4.4",
    "styled-components": "^5.3.3",
    "url-pattern": "^1.0.3",
    "urlsafe-base64": "^1.0.0",
    "uuid": "^8.2.0",
    "velocity-react": "^1.4.3",
    "walk": "^2.3.14",
    "xstate": "^4.20.0",
    "yup": "^0.32.11"
  },
  "devDependencies": {
    "@babel/cli": "^7.10.4",
    "@babel/core": "^7.12.10",
    "@babel/eslint-parser": "^7.17.0",
    "@babel/node": "^7.10.4",
    "@babel/plugin-proposal-class-properties": "^7.10.4",
    "@babel/plugin-proposal-decorators": "^7.10.4",
    "@babel/plugin-proposal-export-default-from": "^7.10.4",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-transform-modules-commonjs": "^7.10.4",
    "@babel/plugin-transform-runtime": "^7.10.4",
    "@babel/polyfill": "^7.10.4",
    "@babel/preset-env": "^7.10.4",
    "@babel/preset-react": "^7.10.4",
    "@babel/preset-typescript": "^7.13.0",
    "@babel/register": "^7.12.10",
    "@babel/runtime": "^7.10.4",
    "@commitlint/cli": "^12.1.4",
    "@commitlint/config-conventional": "^12.1.4",
    "@cypress/code-coverage": "^3.9.5",
    "@cypress/webpack-preprocessor": "^5.5.0",
    "@semantic-release/changelog": "^5.0.1",
    "@semantic-release/commit-analyzer": "^8.0.1",
    "@semantic-release/git": "^9.0.0",
    "@semantic-release/npm": "^7.1.3",
    "@semantic-release/release-notes-generator": "^9.0.3",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^12.0.0",
    "@testing-library/user-event": "^13.2.1",
    "@types/braintree-web": "^3.75.16",
    "@types/enzyme": "^3.10.8",
    "@types/express": "^4.17.13",
    "@types/express-session": "^1.17.4",
    "@types/got": "^9.6.12",
    "@types/imagemin": "^8.0.0",
    "@types/imagemin-webp": "^5.1.2",
    "@types/ioredis": "^4.28.8",
    "@types/jest": "^27.4.1",
    "@types/js-cookie": "^3.0.1",
    "@types/lodash": "^4.14.170",
    "@types/prompts": "^2.0.14",
    "@types/react": "^17.0.3",
    "@types/react-css-modules": "^4.6.2",
    "@types/react-dom": "^17.0.3",
    "@types/react-helmet": "^6.1.2",
    "@types/react-router": "^3.0.8",
    "@types/react-router-dom": "^5.3.3",
    "@types/react-svg-inline": "^2.1.3",
    "@types/react-tabs": "^2.3.4",
    "@types/styled-components": "^5.1.17",
    "@types/uuid": "^8.3.4",
    "@types/yup": "^0.29.11",
    "@typescript-eslint/eslint-plugin": "^5.21.0",
    "@typescript-eslint/parser": "^5.21.0",
    "autoprefixer": "^9.8.6",
    "babel-engine-plugin": "^0.3.0",
    "babel-jest": "^24.9.0",
    "babel-loader": "^8.0.6",
    "babel-plugin-istanbul": "^6.0.0",
    "babel-plugin-jsx-control-statements": "^4.0.0",
    "babel-plugin-module-resolver": "^4.0.0",
    "babel-plugin-preval": "^5.0.0",
    "babel-plugin-react-css-modules": "^5.2.6",
    "babel-polyfill": "^6.26.0",
    "brotli-webpack-plugin": "^1.1.0",
    "case-sensitive-paths-webpack-plugin": "^2.3.0",
    "chalk": "^4.1.0",
    "commitlint": "^12.1.4",
    "compression-webpack-plugin": "^4.0.0",
    "copy-webpack-plugin": "^6.0.3",
    "core-js": "^2.5.7",
    "cross-env": "^7.0.2",
    "css-loader": "^3.4.2",
    "cypress": "^8.4.1",
    "cz-conventional-changelog": "^3.3.0",
    "duplicate-package-checker-webpack-plugin": "^3.0.0",
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.2",
    "enzyme-to-json": "^3.4.3",
    "error-overlay-webpack-plugin": "^0.4.1",
    "eslint": "^8.14.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-config-sonarqube": "^1.0.1",
    "eslint-plugin-cypress": "^2.12.1",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jest": "^26.1.5",
    "eslint-plugin-jsdoc": "^39.2.9",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-jsx-control-statements": "^2.2.1",
    "eslint-plugin-lodash": "^7.4.0",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-promise": "^6.0.0",
    "eslint-plugin-react": "^7.29.4",
    "eslint-plugin-react-hooks": "^4.5.0",
    "eslint-plugin-simple-import-sort": "^7.0.0",
    "eslint-plugin-sonarjs": "^0.13.0",
    "eslint-plugin-unused-imports": "^2.0.0",
    "extract-css-chunks-webpack-plugin": "^4.7.5",
    "file-loader": "^6.0.0",
    "fork-ts-checker-webpack-plugin": "^6.2.0",
    "friendly-errors-webpack-plugin": "^1.7.0",
    "happypack": "^5.0.1",
    "hard-source-webpack-plugin": "^0.13.1",
    "hard-source-webpack-plugin-fixed-hashbug": "^0.13.2",
    "html-es6-template-loader": "^1.0.5",
    "html-loader": "^1.1.0",
    "husky": "^7.0.0",
    "identity-obj-proxy": "^3.0.0",
    "imagemin": "^7.0.1",
    "imagemin-webp": "^6.0.0",
    "ioredis-mock": "^5.2.0",
    "jest": "^27.4.0",
    "jest-canvas-mock": "^2.1.0",
    "jest-trx-results-processor": "^0.0.7",
    "js-cookie": "^2.2.1",
    "lint-staged": "^11.1.2",
    "markdown-loader": "^5.1.0",
    "mkdirp": "1.0.4",
    "npm-run-all": "^4.1.5",
    "nyc": "^15.1.0",
    "postcss-loader": "^3.0.0",
    "postcss-nested": "^4.2.2",
    "postcss-scss": "^2.0.0",
    "prompts": "^2.4.2",
    "prop-types": "^15.7.2",
    "react-hot-loader": "^4.12.21",
    "sass": "^1.49.0",
    "sass-loader": "^9.0.2",
    "sass-resources-loader": "^2.0.1",
    "semantic-release": "^17.4.4",
    "sonar-scanner": "^3.1.0",
    "start-server-and-test": "^1.11.7",
    "stylelint": "^13.6.1",
    "stylelint-config-standard": "^20.0.0",
    "svg-inline-loader": "^0.8.2",
    "tota11y": "^0.1.6",
    "ts-node": "^10.4.0",
    "typescript": "^4.2.3",
    "waait": "^1.0.5",
    "webpack": "^4.42.0",
    "webpack-cli": "^3.3.12",
    "webpack-dev-server": "^3.10.3",
    "webpack-merge": "^4.2.2",
    "webpack-node-externals": "^1.7.2",
    "webpack-visualizer-plugin": "^0.1.11",
    "webpackbar": "^4.0.0"
  }
}
jamiehaywood commented 2 years ago

I also apologise for the obscene amount of deps and devDeps - I've just inherited this project 🤦🏻‍♂️

Jarred-Sumner commented 2 years ago

Thanks. I'll take a look

maheshjag commented 2 years ago

This is the first error that I hit when I ran bun install as well 😢

error: IsDir

–––– bun meta ––––
Bun v0.1.4 macOS Silicon 21.5.0
InstallCommand:
Elapsed: 11ms | User: 5ms | Sys: 3ms
RSS: 5.05MB | Peak: 5.05MB | Commit: 69.22MB | Faults: 2
–––– bun meta ––––
jamiehaywood commented 2 years ago

@Jarred-Sumner - I appreciate you're v. busy with the public release and all. Could you point me in the direction of how I could debug this? I've tried using --verbose but it errors before printing anything.

Jarred-Sumner commented 2 years ago

Can you narrow it down to which package is the cause?

jamiehaywood commented 2 years ago

so here's a couple of steps I went through:

  1. Remove node_modules
  2. Remove yarn.lock
  3. Remove all nesting in src/ (i.e. no src/client src/server etc.)
  4. Remove all packages in package.json
  5. Remove build folder

Still got the same error, except I had a different number of faults. This is odd because when I use bun in a completely fresh node project on the same machine, it works perfectly.

jamiehaywood commented 2 years ago

ok, I've isolated it to the .env folder that we have in our repo.

jamiehaywood commented 2 years ago

so on install, bun looks for a plaintext .env file - https://github.com/oven-sh/bun/blob/c3bf97002d6f0b117060dabf2aa281eedd85b7fd/src/env_loader.zig and then tries to parse it. If .env is a folder, it will fall over.

As a quick fix to this, perhaps there should be a check in here to make sure it's a file not a folder, and then throw an error if it's a folder.

A more robust solution would be to do a folder check and then parse the .env files inside the folder

Jarred-Sumner commented 2 years ago

Are .env folders a thing? Can you link me to read about it somewhere? I have not seen this before

At the very least, it will no longer panic https://github.com/oven-sh/bun/commit/d8f40e080da54ce2cd91eb40898cb86ef22a58a5

jamiehaywood commented 2 years ago

hi @Jarred-Sumner - I don't think commit https://github.com/oven-sh/bun/commit/d8f40e080da54ce2cd91eb40898cb86ef22a58a5 fixed this. Am still getting this:

error: IsDir

----- bun meta -----
Bun v0.1.11 (c7874ed3) macOS x64 21.6.0
InstallCommand: 
Elapsed: 3ms | User: 5ms | Sys: 7ms
RSS: 4.09MB | Peak: 4.09MB | Commit: 69.21MB | Faults: 0
----- bun meta -----
bluet commented 1 year ago

I'm still getting this. The issue still exists in bun 0.5.9

$ bun install

error: IsDir

----- bun meta -----
Bun v0.5.9 (f3ab445c) Linux x64 #77-Ubuntu SMP Tue Mar 21 14:02:37 UTC 2023
InstallCommand: 
Elapsed: 1ms | User: 0ms | Sys: 4ms
RSS: 34.61MB | Peak: 10.31MB | Commit: 34.61MB | Faults: 0
----- bun meta -----

0   0x555b15fa6a2b

Crash report saved to:
  ~/.bun/.bun-crash/v0.5.9-1682727515780.crash

Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord

$ bun -v
0.5.9

Thanks to this thread, I've located the problem is due to the existence of a .env/ folder in the project root.

Renaming .env/ to something else solved the problem.

jamiehaywood commented 1 year ago

request to reopen?