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

Studio startup doesn't work (ENOENT) #415

Closed
Cretezy opened this issue May 9, 2020 · 15 comments
Closed

Studio startup doesn't work (ENOENT) #415

Cretezy opened this issue May 9, 2020 · 15 comments
Assignees
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. topic: basic functionality
Milestone

Comments

@Cretezy
Copy link

Cretezy commented May 9, 2020

When starting the studio with prisma studio --experimental, it can't find @prisma/cli/index.js:

➜  rm -rf /home/charles/.cache/prisma
➜  yarn prisma --experimental studio 
yarn run v1.22.4
$ prisma --experimental studio
Generating Prisma Client ... Failed to generate Prisma Client: GeneratorError: Error: ENOENT: no such file or directory, copyfile '/home/charles/code/socialux/api/node_modules/@prisma/cli/index.js' -> '/home/charles/.cache/prisma/studio/home-charles-code-socialux-api/index.js'
    at GeneratorProcess.handleResponse (/home/charles/code/socialux/api/node_modules/@prisma/cli/build/index.js:2:2807165)
    at LineStream.<anonymous> (/home/charles/code/socialux/api/node_modules/@prisma/cli/build/index.js:2:2806803)
    at LineStream.emit (events.js:310:20)
    at LineStream.EventEmitter.emit (domain.js:482:12)
    at addChunk (_stream_readable.js:286:12)
    at readableAddChunk (_stream_readable.js:268:9)
    at LineStream.Readable.push (_stream_readable.js:209:10)
    at LineStream.Transform.push (_stream_transform.js:152:32)
    at LineStream._pushBuffer (/home/charles/code/socialux/api/node_modules/@prisma/cli/build/index.js:2:2979140)
    at LineStream._transform (/home/charles/code/socialux/api/node_modules/@prisma/cli/build/index.js:2:2978959) {
  code: -32000,
  data: null
}

Using 2.0.0-beta.4

Edit: Tried 2.0.0-alpha.1199, but gives: Error: listen EADDRINUSE: address already in use :::5555

@ubmit
Copy link

ubmit commented May 10, 2020

Facing the exact same issue here. I can run prisma generate just fine, but running prisma studio --experimental will give me the same error

yarn run v1.22.4
$ /Users/guilherme/workspace/personal/valorant-plays/server/node_modules/.bin/prisma studio --experimental
Environment variables loaded from ./prisma/.env
Generating Prisma Client ... Failed to generate Prisma Client: GeneratorError: Error: ENOENT: no such file or directory, copyfile '/Users/guilherme/workspace/personal/valorant-plays/server/node_modules/@prisma/cli/index.js' -> '/Users/guilherme/.cache/prisma/studio/Users-guilherme-workspace-personal-valorant-plays-server/index.js'
    at GeneratorProcess.handleResponse (/Users/guilherme/workspace/personal/valorant-plays/server/node_modules/@prisma/cli/build/index.js:2:2807165)
    at LineStream.<anonymous> (/Users/guilherme/workspace/personal/valorant-plays/server/node_modules/@prisma/cli/build/index.js:2:2806803)
    at LineStream.emit (events.js:321:20)
    at LineStream.EventEmitter.emit (domain.js:485:12)
    at addChunk (_stream_readable.js:305:12)
    at readableAddChunk (_stream_readable.js:280:11)
    at LineStream.Readable.push (_stream_readable.js:214:10)
    at LineStream.Transform.push (_stream_transform.js:152:32)
    at LineStream._pushBuffer (/Users/guilherme/workspace/personal/valorant-plays/server/node_modules/@prisma/cli/build/index.js:2:2979140)
    at LineStream._transform (/Users/guilherme/workspace/personal/valorant-plays/server/node_modules/@prisma/cli/build/index.js:2:2978959) {
  code: -32000,
  data: null
}

Using "@prisma/cli": "^2.0.0-beta.4" and "@prisma/client": "^2.0.0-beta.4"

@e2goon
Copy link

e2goon commented May 10, 2020

$ prisma studio --browser "Google Chrome" --experimental
Environment variables loaded from ./prisma/.env
Generating Prisma Client ... Failed to generate Prisma Client: GeneratorError: Error: ENOENT: no such file or directory, copyfile 'C:\Users\onemon\Documents\workspace\gamecamp-server\node_modules\@prisma\cli\index.js' -> 'C:\Users\onemon\AppData\Roaming\Prisma\Studio\-Users-onemon-Documents-workspace-gamecamp-server\index.js'
    at GeneratorProcess.handleResponse (C:\Users\onemon\Documents\workspace\gamecamp-server\node_modules\@prisma\cli\build\index.js:2:2807165)
    at LineStream.<anonymous> (C:\Users\onemon\Documents\workspace\gamecamp-server\node_modules\@prisma\cli\build\index.js:2:2806803)
    at LineStream.emit (events.js:311:20)
    at LineStream.EventEmitter.emit (domain.js:482:12)
    at addChunk (_stream_readable.js:294:12)
    at readableAddChunk (_stream_readable.js:275:11)
    at LineStream.Readable.push (_stream_readable.js:209:10)
    at LineStream.Transform.push (_stream_transform.js:152:32)
    at LineStream._pushBuffer (C:\Users\onemon\Documents\workspace\gamecamp-server\node_modules\@prisma\cli\build\index.js:2:2979140)
    at LineStream._transform (C:\Users\onemon\Documents\workspace\gamecamp-server\node_modules\@prisma\cli\build\index.js:2:2978959) {
  code: -32000,
  data: null
}

So do i

@sdnts
Copy link
Contributor

sdnts commented May 11, 2020

Hey everyone, I've tried to reproduce this unsuccessfully, so I'm guessing something about my setup is different from yours. It also looks like this is happening on all platforms so can't be a macOS specific thing.

I'd really appreciate it if you could do some investigation for me:

  1. Do you have @prisma/cli installed locally in your project's package.json or globally? I tried both ways, but haven't been able to see this.
  2. Is this happening in one specific project? What happens if you move to a brand new directory and then do npm init && npm i @prisma/cli @prisma/client && npx @prisma/cli@alpha init && npx @prisma/cli@alpha studio --experimental? I just want to make sure this isn't a case of busted node_modules since we did make a change on that front recently. You might need to tweak the command a little, but the point is to init a new project.
  3. Have you tried this on the latest alpha yet? (2.0.0-alpha.1200). I know @Cretezy did, but in their case, it looks like Studio failed to shut down correctly the first time around, so if you could kill all processes listening on port 5555 and try again, you should get the same error (or not!)

If there's anything else about your setup that you think might be relevant, please let me know too. Thanks so much!

@sdnts sdnts transferred this issue from prisma/prisma May 11, 2020
@sdnts sdnts added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. labels May 11, 2020
@sdnts sdnts self-assigned this May 11, 2020
@sdnts sdnts added this to the Beta milestone May 11, 2020
@e2goon
Copy link

e2goon commented May 11, 2020

I solved this problem. @GuilhermedeAndrade @madebysid

  1. Move Folder node_modules/.prisma/client
  2. Selected Files > Copy
    image
  3. Move Folder > Paste C:\Users\{user-id}\AppData\Roaming\Prisma\Studio\-Users-{user-id}-Documents-{folder}-{folder}
    image
  4. Open index.js file.
  5. Change module path
    image

@sdnts
Copy link
Contributor

sdnts commented May 11, 2020

@e2goon Yep, that should fix the problem, but this is not a long-term solution. Studio generates its own Prisma Client (regardless of whether or not your project uses it), and what you're doing is manually copying over your project's generated Client to Studio's generated Client.

While this will work right now, this isn't a long term solution, because things will start breaking if you change your schema, or regenerate Client, or update @prisma/cli

Were you able to try out the things I mentioned in my previous comment? It'll help me debug this so I can figure out why this isn't happening automatically!

@e2goon
Copy link

e2goon commented May 11, 2020

@madebysid

I tried it the way you told me, but it failed. All fail... 😢

$ yarn prisma studio --experimental
yarn run v1.22.4
$ C:\Users\onemon\Documents\workspace\test-prisma\node_modules\.bin\prisma studio --experimental
Environment variables loaded from ./prisma/.env
Generating Prisma Client ... Failed to generate Prisma Client: GeneratorError: Error: ENOENT: no such file or directory, copyfile 'C:\Users\onemon\Documents\workspace\test-prisma\node_modules\@prisma\cli\index.js' -> 'C:\Users\onemon\AppData\Roaming\Prisma\Studio\-Users-onemon-Documents-workspace-test-prisma\index.js'
    at GeneratorProcess.handleResponse (C:\Users\onemon\Documents\workspace\test-prisma\node_modules\@prisma\cli\build\index.js:2:2807165)
    at LineStream.<anonymous> (C:\Users\onemon\Documents\workspace\test-prisma\node_modules\@prisma\cli\build\index.js:2:2806803)
    at LineStream.emit (events.js:311:20)
    at LineStream.EventEmitter.emit (domain.js:482:12)
    at addChunk (_stream_readable.js:294:12)
    at readableAddChunk (_stream_readable.js:275:11)
    at LineStream.Readable.push (_stream_readable.js:209:10)
    at LineStream.Transform.push (_stream_transform.js:152:32)
    at LineStream._pushBuffer (C:\Users\onemon\Documents\workspace\test-prisma\node_modules\@prisma\cli\build\index.js:2:2979140)
    at LineStream._transform (C:\Users\onemon\Documents\workspace\test-prisma\node_modules\@prisma\cli\build\index.js:2:2978959) {
  code: -32000,
  data: null
}

@cihadturhan
Copy link

Same here on macOS – prisma-cli 2.0.0-beta.4

Is there any previous version that would work without issues?
I'll try reverting that.

@cihadturhan
Copy link

@madebysid
Ok, I did some debugging so the problematic part is this and this

After changing them to

  if (!fs.existsSync(proxyIndexJsPath)) {
+    await copyFile(path.join(__dirname, '../../index.js'), proxyIndexJsPath)
-    await copyFile(path.join(__dirname, '../index.js'), proxyIndexJsPath)
  }

  if (!fs.existsSync(proxyIndexDTSPath)) {
-    await copyFile(path.join(__dirname, '../../index.d.ts'), proxyIndexDTSPath)
+    await copyFile(path.join(__dirname, '../index.d.ts'), proxyIndexDTSPath)
  }

At least I managed to start the UI.

After that I saw this error:
Unable to start Prisma Client: { Error: Cannot find module '.prisma/client'
which means this line fails

I changed that line too

function getDotPrismaDir(outputDir: string): string {
  if (
    process.env.INIT_CWD &&
    process.env.npm_lifecycle_event === 'postinstall' &&
    !process.env.PWD?.includes('.pnpm')
  ) {
    return path.join(process.env.INIT_CWD, 'node_modules/.prisma/client')
  }

-  return path.join(outputDir, '../../.prisma/client')
+  return path.join(outputDir, '../.prisma/client')
}

But I still see errors which couldn't find runtime script. I think a commit mixed up paths so it doesn't work on our end.
Hope this helps.

@sdnts
Copy link
Contributor

sdnts commented May 12, 2020

@cihadturhan Thanks to your investigation (❤️ for that!), I realized I what was actually happening. So I deleted Studio's cache at ~/.cache/prisma/studio and tried to start up Studio and was able to see what everyone here is seeing.
The error makes sense. You're right that the path there is definitely wrong. I think a bunch of other paths might be wrong too.

That being said, I'm unable to reproduce this with beta.5 (released today), so perhaps give that a shot too? Regardless, I'm going to investigate and talk to the Prisma Client team to understand how beta.5 "fixed" it. Then I can make sure it stays that way!

@ubmit
Copy link

ubmit commented May 12, 2020

Thanks a lot for helping guys @cihadturhan @madebysid 🙌

@Cretezy
Copy link
Author

Cretezy commented May 13, 2020

Studio working perfectly on beta 5 🎉

@ubmit
Copy link

ubmit commented May 13, 2020

Just tested and it is indeed working fine on 2.0.0-beta.5

@sdnts
Copy link
Contributor

sdnts commented May 13, 2020

Ooh awesome, I'm going to keep this open till the next next-plugin-prisma is released too so people in here who use Nexus can check too :D

@sdnts
Copy link
Contributor

sdnts commented Jun 15, 2020

Nexus's Prisma Plugin has now updated to 2.0.0, which means this should now be fixed for everyone, closing!

@rabit1977
Copy link

The package @prisma/cli has been renamed to prisma. │
npm ERR! │ │
npm ERR! │ Please uninstall @prisma/cli first. │
npm ERR! │ Then install prisma to continue using Prisma CLI: │
npm ERR! │ │
npm ERR! │ # Uninstall old CLI │
npm ERR! │ npm uninstall @prisma/cli │
npm ERR! │ │
npm ERR! │ # Install new CLI │
npm ERR! │ npm install prisma --save-dev │
npm ERR! │ │
npm ERR! │ # Invoke via npx │
npm ERR! │ npx prisma --help │
npm ERR! │ │
npm ERR! │ Learn more here: https://github.com/prisma/prisma/releases/tag/2.16.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. topic: basic functionality
Projects
None yet
Development

No branches or pull requests

7 participants