Skip to content

Commit

Permalink
fix(*): use process.env value or default for RUST_LOG RUST_BACKTRACE (#…
Browse files Browse the repository at this point in the history
…14074)

* fix(*): use process.env value or default for RUST_LOG RUST_BACKTRACE

closes #13931

* remove SERVER_ROOT
  • Loading branch information
Jolg42 committed Jul 18, 2022
1 parent 2b7c796 commit f8b8d38
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/engine-core/src/binary/BinaryEngine.ts
Expand Up @@ -489,12 +489,9 @@ ${chalk.dim("In case we're mistaken, please report this to us 🙏.")}`)
private getEngineEnvVars() {
const env: any = {
PRISMA_DML_PATH: this.datamodelPath,
RUST_BACKTRACE: '1',
RUST_LOG: 'info',
}

if (this.logQueries || this.logLevel === 'info') {
env.RUST_LOG = 'info'
if (this.logQueries) {
env.LOG_QUERIES = 'true'
}
Expand All @@ -512,6 +509,9 @@ ${chalk.dim("In case we're mistaken, please report this to us 🙏.")}`)
...this.env, // user-provided env vars
...process.env,
...env,
// use value from process.env or use default
RUST_BACKTRACE: process.env.RUST_BACKTRACE ?? '1',
RUST_LOG: process.env.RUST_LOG ?? 'info',
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/internals/src/engine-commands/formatSchema.ts
Expand Up @@ -24,7 +24,7 @@ export async function formatSchema({ schemaPath, schema }: { schemaPath?: string

const options = {
env: {
RUST_BACKTRACE: '1',
RUST_BACKTRACE: process.env.RUST_BACKTRACE ?? '1',
...(showColors ? { CLICOLOR_FORCE: '1' } : {}),
},
maxBuffer: MAX_BUFFER,
Expand Down
2 changes: 1 addition & 1 deletion packages/internals/src/engine-commands/getDmmf.ts
Expand Up @@ -278,7 +278,7 @@ async function getDmmfBinary(options: GetDMMFOptions): Promise<DMMF.Document> {
* to serialize big datamodels.
*/
PRISMA_DML_PATH: tempDatamodelPath,
RUST_BACKTRACE: '1',
RUST_BACKTRACE: process.env.RUST_BACKTRACE ?? '1',
...(process.env.NO_COLOR ? {} : { CLICOLOR_FORCE: '1' }),
},
maxBuffer: MAX_BUFFER,
Expand Down
4 changes: 2 additions & 2 deletions packages/internals/src/migrateEngineCommands.ts
Expand Up @@ -190,8 +190,8 @@ export async function execaCommand({
return await execa(migrationEnginePath, ['cli', '--datasource', connectionString, engineCommandName], {
cwd,
env: {
RUST_BACKTRACE: '1',
RUST_LOG: 'info',
RUST_BACKTRACE: process.env.RUST_BACKTRACE ?? '1',
RUST_LOG: process.env.RUST_LOG ?? 'info',
},
})
} catch (_e) {
Expand Down
7 changes: 4 additions & 3 deletions packages/migrate/src/MigrateEngine.ts
Expand Up @@ -172,7 +172,7 @@ export class MigrateEngine {
return new Promise(async (resolve, reject) => {
try {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { PWD, ...rest } = process.env
const { PWD, ...processEnv } = process.env
const binaryPath = await resolveBinary(BinaryType.migrationEngine)
debugRpc('starting migration engine with binary: ' + binaryPath)
const args: string[] = []
Expand All @@ -192,10 +192,11 @@ export class MigrateEngine {
cwd: this.projectDir,
stdio: ['pipe', 'pipe', this.debug ? process.stderr : 'pipe'],
env: {
...rest,
SERVER_ROOT: this.projectDir,
// The following environment variables can be overridden by the user.
RUST_LOG: 'info',
RUST_BACKTRACE: '1',
// Take env values from process.env (willl override values set before)
...processEnv,
},
})

Expand Down

0 comments on commit f8b8d38

Please sign in to comment.