Back

Function build error : Docker Error: tar: short read

  • 0
  • Functions
armanhadi
5 Nov, 2023, 09:31

I self hosted appwrite and created a function and deployed it on github

I get this error on function build

TL;DR
User is experiencing a Docker error when building a function. They receive an error message stating that the code file cannot be found. Another user suggests that the issue may be related to the folder name including spaces and recommends renaming the folder. The function code provided by the user seems to be correct, and it is generated with the Appwrite CLI. No specific solution is mentioned in the thread.
armanhadi
5 Nov, 2023, 09:32

And this is my repo

D5
5 Nov, 2023, 09:33

Did you have created the repository from scratch manually?

D5
5 Nov, 2023, 09:33

Or used a template?

armanhadi
5 Nov, 2023, 09:33

From scratch

armanhadi
5 Nov, 2023, 09:33

I creatd function locally then push it to my repo

D5
5 Nov, 2023, 09:34

And what's the function code?

armanhadi
5 Nov, 2023, 09:35

i didn't edit the code its generated with the cli

armanhadi
5 Nov, 2023, 09:35

`import { Client } from 'node-appwrite';

// This is your Appwrite function // It's executed each time we get a request export default async ({ req, res, log, error }) => { // Why not try the Appwrite SDK? // // const client = new Client() // .setEndpoint('https://cloud.appwrite.io/v1') // .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) // .setKey(process.env.APPWRITE_API_KEY);

// You can log messages to the console

// If something goes wrong, log an error error('Hello, Errors!');

// The req object contains the request data if (req.method === 'GET') { // Send a response with the res object helpers // res.send() dispatches a string back to the client return res.send('Hello, World!'); }

// res.json() is a handy helper for sending JSON return res.json({ motto: 'Build like a team of hundreds_', learn: 'https://appwrite.io/docs', connect: 'https://appwrite.io/discord', getInspired: 'https://builtwith.appwrite.io', }); };`

armanhadi
5 Nov, 2023, 09:39

and this is my config is it correct ?

D5
5 Nov, 2023, 10:06

The code doesn't seem to return anything

D5
5 Nov, 2023, 10:06

You should execute the return.res.json

armanhadi
5 Nov, 2023, 10:07

Like i said this is just the appwrite generated code , is this excerpted behavior ?

armanhadi
5 Nov, 2023, 10:10

From the code isn't this part a return return res.send('Hello, World!');

Meldiron
5 Nov, 2023, 11:52

Hey there πŸ‘‹ The error seems to be regaring tarring or untarring. This usually means issues with rootDirectory. Can you try to rename folder to not include spaces? Let's see if that is the issue we are facing.

armanhadi
5 Nov, 2023, 12:10

Hi thanks for your reply now it deployed but when excecute that code i get this error

`Could not load code file. Error: Cannot find module '/usr/local/server/src/function/main.js' Require stack:

  • /usr/local/server/src/server.js at Module._resolveFilename (node:internal/modules/cjs/loader:939:15) at Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:81:25) at require (node:internal/modules/cjs/helpers:102:18) at execute (/usr/local/server/src/server.js:123:28) at /usr/local/server/src/server.js:158:33 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)`
Drake
13 Nov, 2023, 21:09

Would you be able to create a github issue for the spaces problem?

Drake
13 Nov, 2023, 21:10

What's your folder structure and what did you set for hte root directory and entrypoint?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more