Clasp: `clasp push` fails with custom root directory

Created on 8 Jun 2018  路  9Comments  路  Source: google/clasp

Expected Behavior

clasp push works when I've specified a custom rootDir in .clasp.json.

Actual Behavior

clasp push doesn't work when I've specified a custom rootDir in .clasp.json.

PS C:\src\gas\XP Logbook> Get-Content .\.clasp.json
{
    "scriptId": "<SCRIPT_ID>",
    "rootDir": "../../git/xp-logbook/src"
}
PS C:\src\gas\XP Logbook> Get-ChildItem ..\..\git\xp-logbook\src\


    Directory: C:\src\git\xp-logbook\src


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2018-06-03     22:29                node_modules
-a----       2018-06-07     21:00             75 .claspignore
-a----       2018-06-07     19:45            442 appsscript.json
-a----       2018-06-07     19:45            825 database.js
-a----       2018-06-07     19:45            252 macros.js
-a----       2018-06-03     22:29            382 package-lock.json
-a----       2018-06-07     19:45            516 players.js
-a----       2018-06-07     19:45           5543 sessions.js
-a----       2018-06-07     19:45           1152 sheets.js
-a----       2018-06-07     18:43             50 _imports.js


PS C:\src\gas\XP Logbook> clasp push
Push failed. Errors:
Project contents must include a manifest file named appsscript.
Files to push were:
PS C:\src\gas\XP Logbook>

Steps to Reproduce the Problem

  1. Create a .clasp.json file with a valid scriptId and a custom rootDir
  2. clasp pull
  3. clasp push

It looks like files.getProjectFiles() strips rootDir, but commands.push() doesn't add it back before attempting script.projects.updateContent().

https://github.com/google/clasp/blob/98026240317c4a5107dadc6b99daffb2ccb089e9/src/files.ts#L101-L110

Specifications

  • Node version 10.3.0
  • Clasp version 1.3.1
  • Windows 10 x64 v 1803

Most helpful comment

Hi @ShowMeBillyJo, @agektmr, @misterludden,
Can you try installing the latest version, 1.5.3? I think I've solved this issue.

Tests:

clasp status
Not ignored files:
鈹斺攢 ../dist/src/appsscript.json
鈹斺攢 ../dist/src/hi.js

Ignored files:
clasp push
鈹斺攢 ../dist/src/appsscript.json
鈹斺攢 ../dist/src/hi.js
Pushed 2 files.
cat .clasp.json
{
  "scriptId":"11AIejfE3_Qbmh0BO1Yb0g75c0giLjWlghFcALj9BI6OTLHI7JyDU-Pph",
  "rootDir": "../dist/src"
}

Sorry for the troubles and delayed fix.

All 9 comments

Updated with ls of custom root directory.

I just encountered the exact same issue and fixed by explicitly white listed the directory in .claspignore file. Example:

**/**
node_modules/**.*
!dist/apps_script/**.*

Hey @bhaelochon can you try using the full path as rootDir rather than the relative path?

1.5 ignore appsscript.json in custom directory.
1.4 work fine in my environment.

For example, https://github.com/azu/gmail-old-notification-remover
yarn run deploy does work with [email protected]

$ clasp status
The following files will be pushed by clasp push:
鈹斺攢 build/appsscript.json
鈹斺攢 build/bundle.js
Untracked files:

But, yarn run deploy does not work with [email protected]

$ clasp status
Not ignored files:
鈹斺攢 build/bundle.js

Ignored files:
鈹斺攢 build/appsscript.json

Same for me - rolling back to @1.4.0 resolved it for some reason.

I must have broken custom directories with typescript support. I'll fix this issue next week.

In the meanwhile, use 1.4 for now.

Ah. there's a bug with using .. with rootDir:

filePaths = filePaths.filter((name) => !name.startsWith('.'));

I'm working on a fix.

Hi @ShowMeBillyJo, @agektmr, @misterludden,
Can you try installing the latest version, 1.5.3? I think I've solved this issue.

Tests:

clasp status
Not ignored files:
鈹斺攢 ../dist/src/appsscript.json
鈹斺攢 ../dist/src/hi.js

Ignored files:
clasp push
鈹斺攢 ../dist/src/appsscript.json
鈹斺攢 ../dist/src/hi.js
Pushed 2 files.
cat .clasp.json
{
  "scriptId":"11AIejfE3_Qbmh0BO1Yb0g75c0giLjWlghFcALj9BI6OTLHI7JyDU-Pph",
  "rootDir": "../dist/src"
}

Sorry for the troubles and delayed fix.

Closing.
Comment here if you still see the issue and I'll reopen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smandava picture smandava  路  8Comments

imthenachoman picture imthenachoman  路  3Comments

labnol picture labnol  路  4Comments

Haris-Jamil picture Haris-Jamil  路  6Comments

hariharasuthan-balaji picture hariharasuthan-balaji  路  8Comments