I'm setting up an `ApolloApi` configuring `server....
# sst
j
I'm setting up an
ApolloApi
configuring
server.bundle.commandHooks.beforeInstall()
to copy some files over but I'm getting an error:
Copy code
There was a problem running "beforeInstall" command.

Error: Command failed: pwd && cp apps/data-graph/src/prisma/schema.prisma ${outputDir}/
cp: cannot create regular file '/schema.prisma': Permission denied
Any idea?
f
Hey @Josias Duarte Busiquia, can I see how you are creating the
ApolloApi
?
j
Copy code
const dataGraphApi = new ApolloApi(this, "Api", {
  server: {
    handler: "apps/data-graph/src/lambda.handler",
    bundle: {
      nodeModules: [
        // node_modules/nexus-plugin-prisma/src/index.ts
        "graphql",
        "nexus",
        "@prisma/client",
        "prisma",
      ],
      commandHooks: {
        beforeBundling: () => [],
        beforeInstall: (inputDir, outputDir) => {
          console.log("beforeInstall: ", { inputDir, outputDir })
          return ["pwd", "cp -R apps/data-graph/src/prisma ${outputDir}/"]
        },
        afterBundling: (inputDir, outputDir) => {
          console.log("afterBundling: ", { inputDir, outputDir })
          return [
            "pwd",
            "ls -al",
            `cd ${outputDir}`,
            `yarn prisma generate`,
            `rm -rf node_modules/@prisma/engines`,
          ]
        },
      },
    },
  },
})
Copy code
➜ ll -a .build/
total 768K
drwxrwxr-x  5 iqb iqb 4.0K Jul 28 17:35 .
drwxrwxr-x 15 iqb iqb 4.0K Jul 28 17:35 ..
drwxr-xr-x  2 iqb iqb 4.0K Jul 28 17:35 apps-data-graph-src-lambda-handler-1627508115036
drwxrwxr-x  2 iqb iqb 4.0K Jul 28 17:35 cdk.out
-rw-r--r--  1 iqb iqb 730K Jul 28 17:35 .esbuild.apps-data-graph-src-lambda-handler.json
-rw-rw-r--  1 iqb iqb 2.0K Jul 28 17:35 eslint.js
drwxr-xr-x  2 iqb iqb 4.0K Jul 28 17:35 lib
-rw-rw-r--  1 iqb iqb 2.8K Jul 28 17:35 run.js
-rw-r--r--  1 iqb iqb 2.2K Jul 28 17:35 sst-debug.log
-rw-rw-r--  1 iqb iqb  107 Jul 28 17:35 sst-merged.json
iqb
is my linux username.
f
Yeah… I just read the Stackoverlow thread on this error - https://askubuntu.com/questions/462187/cp-cannot-create-regular-file-permission-denied
What did this print out
console.log("beforeInstall: ", { inputDir, outputDir })
?
instead of this
Copy code
return ["pwd", "cp -R apps/data-graph/src/prisma ${outputDir}/"]
can you try this
Copy code
return ["pwd", `cp -R apps/data-graph/src/prisma ${outputDir}/`]
replacing the ” with `
j
What did this print out 
console.log("beforeInstall: ", { inputDir, outputDir })
?
Copy code
beforeInstall:  {                                                                                       
  inputDir: '.',                                                                                        
  outputDir: '.build/apps-data-graph-src-lambda-handler-1627508115036'                                  
}
replacing the ” with `
I'll try
replacing the ” with `
It did work! It was right on face! The pains of copy-pasting 😆. Greatly appreciated @Frank!
f
Awesome!