question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected binaryTargets environment variables usage

See original GitHub issue

Bug description

In version 2.22 and below, I was able to use an environment variable to set binaryTargets. This was the generator part in my schema:

generator client {
  provider          = "prisma-client-js"
  binaryTargets = [env("PRISMA_BINARY_TARGET")]
}

I could run something like this to set this environment variable:

$ PRISMA_BINARY_TARGET='native' yarn prisma generate

However, it does not work like this anymore in v2.26. If I upgrade Prisma to 2.26 and try running the same command, I’d get an error like this ( with DEBUG="prisma*" turned on):

Screen Shot 2021-07-06 at 8 55 43 pm

How to reproduce

  1. Create a new schema
  2. Use an environment variable for binaryTargets
  3. Set the environment variable when running relevant commands like prisma generate

Expected behavior

I was expecting v2.26 to work the same way as v2.22 and before:

$ PRISMA_BINARY_TARGET='native' yarn prisma generate

Would be nice to also have this documented somewhere as well ( Maybe it’s out there but I missed it 😃 ? )

Alternative

Given the following setting:

generator client {
  provider          = "prisma-client-js"
  binaryTargets = env("PRISMA_BINARY_TARGET") // Notice env is now the `binaryTargets` array 
}

Maybe the targets can be passed in with a , separator? For example:

$ PRISMA_BINARY_TARGET='native,darwin' yarn prisma generate

Current workaround

After digging around a bit in this file, I found that it was expecting an array in JSON string instead of a string. That means I could do something like this:

$ PRISMA_BINARY_TARGET='["native"]' yarn prisma generate

Prisma information

N/A

Environment & setup

  • OS: MacOS
  • Database: MySQL
  • Node.js version: 12.13.1

Prisma Version

prisma               : 2.26.0
@prisma/client       : 2.26.0
Current platform     : darwin
Query Engine         : query-engine 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine     : migration-engine-cli 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary        : prisma-fmt 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 9b816b3aa13cc270074f172f30d6eda8a8ce867d
Studio               : 0.408.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
janpiocommented, Jan 7, 2022

Internal Note: We need to confirm the described behavior in 2.22.0, reproduce the failure in recent versions and then understand how and why this changed - and then decide if this is something we can or want to undo, and how to properly document this.

0reactions
gimtoniccommented, Jun 28, 2022

Sorry. The problem is not relevant. I fixed this by copying the .env file to inside docker container.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ENV03-C. Sanitize the environment when invoking external ...
Because environment variables are inherited from the parent process when a program is executed, an attacker can easily sabotage variables, causing a program...
Read more >
Problems with Environment Variables
Environment variable is not set · Open a DOS box (or a Command prompt box in Windows NT/2000/XP) · Type the word "Set"...
Read more >
SyntaxError: Unexpected token ':' in environment variable
I am passing a environment variable through docker but my nestjs application wont accept the variable value. docker run command:.
Read more >
Diff - 8389745919cae02139ddc085a63c00d024269cf2^! - platform ...
+ 'Default is env var BUILDTYPE or Debug') + ... shutting down') + except: # pylint: disable=bare-except + logging.exception('Unexpected exception in main.
Read more >
https://mirror.umd.edu/opensuse/tumbleweed/iso/Cha...
libgnutls: Fixed issue with unexpected non-fatal errors resetting the handshake's ... Changes in behavior: * The GREP_OPTIONS environment variable is now ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found