Skip to content

fix(sdk): avoid unlinking QE library when running "prisma generate"#10507

Merged
aqrln merged 5 commits intomainfrom
integration/fix-9184
Dec 2, 2021
Merged

fix(sdk): avoid unlinking QE library when running "prisma generate"#10507
aqrln merged 5 commits intomainfrom
integration/fix-9184

Conversation

@aqrln
Copy link
Member

@aqrln aqrln commented Nov 30, 2021

  • Don't install prisma when it is already present.
  • Don't install both prisma and @prisma/client if Yarn on Windows is detected, and ask the user to install them manually.
  • Add TODO comments for potential bugs out of scope of this PR.

Fixes #9184

@aqrln
Copy link
Member Author

aqrln commented Nov 30, 2021

Marking as draft for now because some testing is necessary

Copy link
Contributor

@janpio janpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fundamentally good to me.

@aqrln aqrln marked this pull request as ready for review November 30, 2021 15:11
@aqrln
Copy link
Member Author

aqrln commented Nov 30, 2021

Manual testing ✅

How should we test this automatically? e2e tests?

@janpio
Copy link
Contributor

janpio commented Nov 30, 2021

e2e-tests repo would be the fallback, yes, if we can not do that in the tests here. As it does not need to talk to the database, but really just is about running a few commands in a specific order it does not really fit there either but we should be ok with that.

Copy link
Contributor

@Jolg42 Jolg42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will make some people quite happy :)

@janpio
Copy link
Contributor

janpio commented Dec 1, 2021

Oh, this is an intergration branch so I can actually test it on Windows 👍 Let me do that...

3.6.0-integration-fix-9184.5

@janpio
Copy link
Contributor

janpio commented Dec 1, 2021

I can confirm this fix works for me:

Original reproduction of problem:

C:\Users\Jan\Documents\throwaway                                                                                                                         
λ git clone https://github.com/janpio/prisma-issue-9184 9184_3                                                                                           
Cloning into '9184_3'...                                                                                                                                 
remote: Enumerating objects: 9, done.                                                                                                                    
remote: Counting objects: 100% (9/9), done.                                                                                                              
remote: Compressing objects: 100% (7/7), done.                                                                                                           
remote: Total 9 (delta 0), reused 9 (delta 0), pack-reused 0                                                                                             
Receiving objects: 100% (9/9), done.                                                                                                                     
                                                                                                                                                         
C:\Users\Jan\Documents\throwaway                                                                                                                         
λ cd 9184_3                                                                                                                                              
                                                                                                                                                         
C:\Users\Jan\Documents\throwaway\9184_3 (main -> origin) (9184_2@1.0.0)                                                                                  
λ ls                                                                                                                                                     
package.json  package-lock.json  prisma/                                                                                                                 
                                                                                                                                                         
C:\Users\Jan\Documents\throwaway\9184_3 (main -> origin) (9184_2@1.0.0)                                                                                  
λ npm install                                                                                                                                            
                                                                                                                                                         
> prisma@3.1.1 preinstall C:\Users\Jan\Documents\throwaway\9184_3\node_modules\prisma                                                                    
> node scripts/preinstall-entry.js                                                                                                                       
                                                                                                                                                         
                                                                                                                                                         
> prisma@3.1.1 install C:\Users\Jan\Documents\throwaway\9184_3\node_modules\prisma                                                                       
> node scripts/install-entry.js                                                                                                                          
                                                                                                                                                         
                                                                                                                                                         
> @prisma/engines@3.1.0-24.c22652b7e418506fab23052d569b85d3aec4883f postinstall C:\Users\Jan\Documents\throwaway\9184_3\node_modules\@prisma\engines     
> node download/index.js                                                                                                                                 
                                                                                                                                                         
npm WARN 9184_2@1.0.0 No description                                                                                                                     
npm WARN 9184_2@1.0.0 No repository field.                                                                                                               
                                                                                                                                                         
added 2 packages from 1 contributor and audited 2 packages in 6.427s                                                                                     
found 0 vulnerabilities                                                                                                                                  
                                                                                                                                                         
                                                                                                                                                         
C:\Users\Jan\Documents\throwaway\9184_3 (main -> origin) (9184_2@1.0.0)                                                                                  
λ npx prisma generate                                                                                                                                    
Prisma schema loaded from prisma\schema.prisma                                                                                                           
npm WARN 9184_2@1.0.0 No description                                                                                                                     
npm WARN 9184_2@1.0.0 No repository field.                                                                                                               
                                                                                                                                                         
npm ERR! code EPERM                                                                                                                                      
npm ERR! syscall unlink                                                                                                                                  
npm ERR! path C:\Users\Jan\Documents\throwaway\9184_3\node_modules\prisma\query_engine-windows.dll.node                                                  
npm ERR! errno -4048                                                                                                                                     
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\Jan\Documents\throwaway\9184_3\node_modules\prisma\query_engine-windows.dll.node'       
npm ERR!  [OperationalError: EPERM: operation not permitted, unlink 'C:\Users\Jan\Documents\throwaway\9184_3\node_modules\prisma\query_engine-windows.dll
ode'] {                                                                                                                                                  
npm ERR!   cause: [Error: EPERM: operation not permitted, unlink 'C:\Users\Jan\Documents\throwaway\9184_3\node_modules\prisma\query_engine-windows.dll.no
'] {                                                                                                                                                     
npm ERR!     errno: -4048,                                                                                                                               
npm ERR!     code: 'EPERM',                                                                                                                              
npm ERR!     syscall: 'unlink',                                                                                                                          
npm ERR!     path: 'C:\\Users\\Jan\\Documents\\throwaway\\9184_3\\node_modules\\prisma\\query_engine-windows.dll.node'                                   
npm ERR!   },                                                                                                                                            
npm ERR!   errno: -4048,                                                                                                                                 
npm ERR!   code: 'EPERM',                                                                                                                                
npm ERR!   syscall: 'unlink',                                                                                                                            
npm ERR!   path: 'C:\\Users\\Jan\\Documents\\throwaway\\9184_3\\node_modules\\prisma\\query_engine-windows.dll.node',                                    
npm ERR!   parent: '9184_3'                                                                                                                              
npm ERR! }                                                                                                                                               
npm ERR!                                                                                                                                                 
npm ERR! The operation was rejected by your operating system.                                                                                            
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),                                                                 
npm ERR! or that you lack permissions to access it.                                                                                                      
npm ERR!                                                                                                                                                 
npm ERR! If you believe this might be a permissions issue, please double-check the                                                                       
npm ERR! permissions of the file and its containing directories, or try running                                                                          
npm ERR! the command again as root/Administrator.                                                                                                        
                                                                                                                                                         
npm ERR! A complete log of this run can be found in:                                                                                                     
npm ERR!     C:\Users\Jan\AppData\Roaming\npm-cache\_logs\2021-12-01T18_10_25_176Z-debug.log                                                             
Error: Command failed with exit code 4294963248: npm install -D prisma@3.1.1                                                                             
The batch file cannot be found.                                                                                                                          

And then working with this new integration branch:

C:\Users\Jan\Documents\throwaway                                                                                                                         
λ git clone https://github.com/janpio/prisma-issue-9184 9184_4                                                                                           
Cloning into '9184_4'...                                                                                                                                 
remote: Enumerating objects: 9, done.                                                                                                                    
remote: Counting objects: 100% (9/9), done.                                                                                                              
remote: Compressing objects: 100% (7/7), done.                                                                                                           
remote: Total 9 (delta 0), reused 9 (delta 0), pack-reused 0                                                                                             
Receiving objects: 100% (9/9), done.                                                                                                                     
                                                                                                                                                         
C:\Users\Jan\Documents\throwaway                                                                                                                         
λ cd 9184_4                                                                                                                                              
                                                                                                                                                         
C:\Users\Jan\Documents\throwaway\9184_4 (main -> origin) (9184_2@1.0.0)                                                                                  
λ npm install prisma@3.6.0-integration-fix-9184.5                                                                                                        
                                                                                                                                                         
> prisma@3.6.0-integration-fix-9184.5 preinstall C:\Users\Jan\Documents\throwaway\9184_4\node_modules\prisma                                             
> node scripts/preinstall-entry.js                                                                                                                       
                                                                                                                                                         
                                                                                                                                                         
> prisma@3.6.0-integration-fix-9184.5 install C:\Users\Jan\Documents\throwaway\9184_4\node_modules\prisma                                                
> node scripts/install-entry.js                                                                                                                          
                                                                                                                                                         
                                                                                                                                                         
> @prisma/engines@3.6.0-19.9372e13dbcc967fb9bd1f954bed16d7b7b96d4f9 postinstall C:\Users\Jan\Documents\throwaway\9184_4\node_modules\@prisma\engines     
> node download/index.js                                                                                                                                 
                                                                                                                                                         
npm WARN 9184_2@1.0.0 No description                                                                                                                     
npm WARN 9184_2@1.0.0 No repository field.                                                                                                               
                                                                                                                                                         
+ prisma@3.6.0-integration-fix-9184.5                                                                                                                    
added 2 packages from 1 contributor and audited 2 packages in 11.83s                                                                                     
found 0 vulnerabilities                                                                                                                                  
                                                                                                                                                         
                                                                                                                                                         
C:\Users\Jan\Documents\throwaway\9184_4 (main -> origin) (9184_2@1.0.0)                                                                                  
λ npm install                                                                                                                                            
npm WARN 9184_2@1.0.0 No description                                                                                                                     
npm WARN 9184_2@1.0.0 No repository field.                                                                                                               
                                                                                                                                                         
audited 2 packages in 0.6s                                                                                                                               
found 0 vulnerabilities                                                                                                                                  
                                                                                                                                                         
                                                                                                                                                         
C:\Users\Jan\Documents\throwaway\9184_4 (main -> origin) (9184_2@1.0.0)                                                                                  
λ npx prisma -v                                                                                                                                          
prisma                  : 3.6.0-integration-fix-9184.5                                                                                                   
@prisma/client          : Not found                                                                                                                      
Current platform        : windows                                                                                                                        
Query Engine (Node-API) : libquery-engine 9372e13dbcc967fb9bd1f954bed16d7b7b96d4f9 (at node_modules\@prisma\engines\query_engine-windows.dll.node)       
Migration Engine        : migration-engine-cli 9372e13dbcc967fb9bd1f954bed16d7b7b96d4f9 (at node_modules\@prisma\engines\migration-engine-windows.exe)   
Introspection Engine    : introspection-core 9372e13dbcc967fb9bd1f954bed16d7b7b96d4f9 (at node_modules\@prisma\engines\introspection-engine-windows.exe) 
Format Binary           : prisma-fmt 9372e13dbcc967fb9bd1f954bed16d7b7b96d4f9 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)                   
Default Engines Hash    : 9372e13dbcc967fb9bd1f954bed16d7b7b96d4f9                                                                                       
Studio                  : 0.440.0                                                                                                                        
                                                                                                                                                         
C:\Users\Jan\Documents\throwaway\9184_4 (main -> origin) (9184_2@1.0.0)                                                                                  
λ cat package.json                                                                                                                                       
{                                                                                                                                                        
  "name": "9184_2",                                                                                                                                      
  "version": "1.0.0",                                                                                                                                    
  "description": "",                                                                                                                                     
  "main": "index.js",                                                                                                                                    
  "scripts": {                                                                                                                                           
    "test": "echo \"Error: no test specified\" && exit 1"                                                                                                
  },                                                                                                                                                     
  "keywords": [],                                                                                                                                        
  "author": "",                                                                                                                                          
  "license": "ISC",                                                                                                                                      
  "dependencies": {                                                                                                                                      
    "prisma": "^3.6.0-integration-fix-9184.5"                                                                                                            
  }                                                                                                                                                      
}                                                                                                                                                        
                                                                                                                                                         
C:\Users\Jan\Documents\throwaway\9184_4 (main -> origin) (9184_2@1.0.0)                                                                                  
λ npx prisma generate                                                                                                                                    
Prisma schema loaded from prisma\schema.prisma                                                                                                           
                                                                                                                                                         
> @prisma/client@3.6.0-integration-fix-9184.5 postinstall C:\Users\Jan\Documents\throwaway\9184_4\node_modules\@prisma\client                            
> node scripts/postinstall.js                                                                                                                            
                                                                                                                                                         
npm WARN 9184_2@1.0.0 No description                                                                                                                     
npm WARN 9184_2@1.0.0 No repository field.                                                                                                               
                                                                                                                                                         
+ @prisma/client@3.6.0-integration-fix-9184.5                                                                                                            
added 2 packages from 1 contributor and audited 4 packages in 10.257s                                                                                    
found 0 vulnerabilities                                                                                                                                  
                                                                                                                                                         
                                                                                                                                                         
✔ Installed the @prisma/client and prisma packages in your project                                                                                       
                                                                                                                                                         
✔ Generated Prisma Client (3.6.0-integration-fix-9184.5 | library) to .\node_modules\@prisma\client in 69ms                                              
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client                                                                  
```                                                                                                                                                      
import { PrismaClient } from '@prisma/client'                                                                                                            
const prisma = new PrismaClient()                                                                                                                        
```                                                                                                                                                      
┌─────────────────────────────────────────────────────────┐                                                                                              
│  Update available 3.6.0-integration-fix-9184.5 -> 3.6.0 │                                                                                              
│  Run the following to update                            │                                                                                              
│    npm i --save-dev prisma@latest                       │                                                                                              
│    npm i @prisma/client@latest                          │                                                                                              
└─────────────────────────────────────────────────────────┘                                                                                              

C:\Users\Jan\Documents\throwaway\9184_4 (main -> origin) (9184_2@1.0.0)
λ cat package.json                                                     
{                                                                      
  "name": "9184_2",                                                    
  "version": "1.0.0",                                                  
  "description": "",                                                   
  "main": "index.js",                                                  
  "scripts": {                                                         
    "test": "echo \"Error: no test specified\" && exit 1"              
  },                                                                   
  "keywords": [],                                                      
  "author": "",                                                        
  "license": "ISC",                                                    
  "dependencies": {                                                    
    "@prisma/client": "^3.6.0-integration-fix-9184.5",                 
    "prisma": "^3.6.0-integration-fix-9184.5"                          
  }                                                                    
}                                                                      

@aqrln aqrln merged commit 0ad49f4 into main Dec 2, 2021
@aqrln aqrln deleted the integration/fix-9184 branch December 2, 2021 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EPERM: operation not permitted, unlink '...node_modules\prisma\query_engine-windows.dll.node'

4 participants