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

Environment variables loaded from uses wrong directory separator (slashes) on Windows #2699

Closed
janpio opened this issue Jun 9, 2020 · 3 comments
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. topic: windows
Milestone

Comments

@janpio
Copy link
Member

janpio commented Jun 9, 2020

C:\Users\Jan\Documents\throwaway\1313>prisma introspect
Environment variables loaded from ./prisma/.env

Introspecting based on datasource defined in prisma\schema.prisma …
Error: P1001
@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. topic: windows labels Jun 9, 2020
@jonahsnider
Copy link

jonahsnider commented Jun 9, 2020

Here's a line that's assuming the path separator is /:

dotenvResult = dotenv.config({ path: 'prisma/.env' })

When working with paths in Node you should always use path.join to avoid quirks like this:

import { join as joinPaths } from 'path';

dotenv.config({ path: joinPaths('prisma', '.env') });

@janpio janpio added process/candidate tech/typescript Issue for tech TypeScript. labels Jun 9, 2020
@janpio janpio added this to the 2.1.0 milestone Jun 10, 2020
@timsuchanek
Copy link
Contributor

Thanks @pizzafox but that line is not the problem.
The Dotenv library under the hood uses the path library and therefore can deal with the /.
The problem is just the hardcoded / path separator.

Using a simple path.relative solves this problem.

@timsuchanek
Copy link
Contributor

Thanks a lot for reporting 🙏
This issue is fixed in the latest dev version of @prisma/cli.
You can try it out with npm i -g @prisma/cli@dev.

In case it’s not fixed for you - please let us know and we’ll reopen this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. topic: windows
Projects
None yet
Development

No branches or pull requests

3 participants