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

Unable to read config/vite.json file in Windows with Cygwin #309

Closed
2 tasks done
aslam opened this issue Nov 30, 2022 · 3 comments
Closed
2 tasks done

Unable to read config/vite.json file in Windows with Cygwin #309

aslam opened this issue Nov 30, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@aslam
Copy link

aslam commented Nov 30, 2022

  • I have tried upgrading by running bundle update vite_ruby.
  • I have read the troubleshooting section before opening an issue.

Description 📖

I am trying to run the Vite dev server on a Windows system with Cygwin. The issue described in npm/cmd-shim#45 is not the cause since I don't have any special characters in the path.

// package.json
{
  "devDependencies": {
    "sass": "^1.56.1",
    "vite": "^3.2.3",
    "vite-plugin-ruby": "^3.1.2"
  },
  "dependencies": {
    "@ant-design/icons": "^4.8.0",
    "antd": "^5.0.0",
    "axios": "^1.1.3",
    "i18n-iso-countries": "^7.5.0",
    "localforage": "^1.10.0",
    "match-sorter": "^6.3.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.4.3",
    "sort-by": "^1.2.0"
  }
}
❯ node -v
v18.12.1

Reproduction 🐞

The dev server fails to start with throwing the following error:

error when starting dev server:
Error: ENOENT: no such file or directory, open '\cygdrive\c\Users\Frank\Document
s\Work\dthub\config\vite.json'
    at Object.openSync (node:fs:600:3)
    at readFileSync (node:fs:468:35)
    at loadJsonConfig (C:\Users\Frank\Documents\Work\dthub\node_modules\vite-plu
gin-ruby\dist\index.cjs:79:48)
    at loadConfiguration (C:\Users\Frank\Documents\Work\dthub\node_modules\vite-
plugin-ruby\dist\index.cjs:133:26)
    at config (C:\Users\Frank\Documents\Work\dthub\node_modules\vite-plugin-ruby
\dist\index.cjs:234:19)
    at runConfigHook (file:///C:/Users/Frank/Documents/Work/dthub/node_modules/v
ite/dist/node/chunks/dep-51c4f80a.js:62865:31)
    at resolveConfig (file:///C:/Users/Frank/Documents/Work/dthub/node_modules/v
ite/dist/node/chunks/dep-51c4f80a.js:62374:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5
)
    at async createServer (file:///C:/Users/Frank/Documents/Work/dthub/node_modu
les/vite/dist/node/chunks/dep-51c4f80a.js:61636:20)
    at async CAC.<anonymous> (file:///C:/Users/Frank/Documents/Work/dthub/node_m
odules/vite/dist/node/cli.js:707:24)
Vite Ruby Info

Run bin/rake vite:info and provide the output:

  OS: Windows 10 10.0.19045
  CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
  Memory: 1.23 GB / 15.81 GB
Binaries:
  Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
  Yarn: 1.22.19 - ~\Documents\Work\dthub\node_modules\.bin\yarn.CMD
  npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
  Edge: Spartan (44.19041.1266.0), Chromium (107.0.1418.56)
  Internet Explorer: 11.0.19041.1566

Logs 📜

If not providing a reproduction:

Output

Run DEBUG=vite-plugin-ruby:* bin/vite dev or DEBUG=vite-plugin-ruby:* bin/vite build and provide the output:

Building with Vite :zap:️
2022-11-29T18:24:50.683Z vite:config bundled config file loaded in 214.08ms
error during build:
Error: ENOENT: no such file or directory, open '\cygdrive\c\Users\Frank\Documents\Work\dthub\config\vite.json'
    at Object.openSync (node:fs:600:3)
    at readFileSync (node:fs:468:35)
    at loadJsonConfig (C:\Users\Frank\Documents\Work\dthub\node_modules\vite-plugin-ruby\dist\index.cjs:79:48)
    at loadConfiguration (C:\Users\Frank\Documents\Work\dthub\node_modules\vite-plugin-ruby\dist\index.cjs:133:26)
    at config (C:\Users\Frank\Documents\Work\dthub\node_modules\vite-plugin-ruby\dist\index.cjs:234:19)
    at runConfigHook (file:///C:/Users/Frank/Documents/Work/dthub/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:62865:31)
    at resolveConfig (file:///C:/Users/Frank/Documents/Work/dthub/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:62374:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async doBuild (file:///C:/Users/Frank/Documents/Work/dthub/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:45244:20)
    at async build (file:///C:/Users/Frank/Documents/Work/dthub/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:45233:16)
pid 1152 exit 1
Build with Vite failed! x

Screenshots 📷

Provide console or browser screenshots of the problem.

@aslam aslam added the bug: pending triage Something doesn't seem to be working, but hasn't been verified label Nov 30, 2022
@ElMassimo
Copy link
Owner

Probably related to the use of join.

Would you try editing vite-plugin-ruby to use resolve instead of join and checking if that fixes the issue?

PRs are welcome!

@ElMassimo ElMassimo changed the title Vite dev server unable to find vite.json file Unable to read config/vite.json file in Windows with Cygwin Nov 30, 2022
@ElMassimo ElMassimo added bug Something isn't working and removed bug: pending triage Something doesn't seem to be working, but hasn't been verified labels Nov 30, 2022
@aslam
Copy link
Author

aslam commented Nov 30, 2022

I tried change all uses of join to resolve but doesn't seem to be resolving the issue.

The rabbit hole led me to setting env. variables in Cygwin:

The PATH environment variable is used by Cygwin applications as a list of directories to search for executable files to run. This environment variable is converted from Windows format (e.g. C:\Windows\system32;C:\Windows) to UNIX format (e.g., /cygdrive/c/Windows/system32:/cygdrive/c/Windows) when a Cygwin process first starts. Set it so that it contains at least the x:\cygwin\bin directory where "x:\cygwin is the "root" of your cygwin installation if you wish to use cygwin tools outside of bash. This is usually done by the batch file you're starting your shell with.

I don't use Windows and remote debugging, esp. with Win., in not very pleasant. Have to setup a VM with Windows to try and reproduce.

@ElMassimo
Copy link
Owner

Closing for now, but if you find the cause is inside this library and not in Vite, pull requests are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants