Change in .clasp.json location & behavior with --rootDir
See original GitHub issueSteps to reproduce the problem
- Install clasp locally
- Create a project using --rootDir
- Attempt to push files
Expected Behavior
(as in 2.4.😇 4. Success
% mkdir -p project-2.4.0/{src,tools}
% cd project-2.4.0/tools
% npm install @google/clasp@2.4.0
...
% ./node_modules/.bin/clasp create --type webapp --title test-2.4.0 --rootDir ../src
Created new webapp script: https://script.google.com/d/.../edit
Warning: files in subfolder are not accounted for unless you set a '.claspignore' file.
Cloned 1 file.
└─ ../src/appsscript.json
% ./node_modules/.bin/clasp push
└─ ../src/appsscript.json
Pushed 1 file.
Actual Behavior
(in 2.4.1:) 4. .clasp.json file (now in rootDir rather than same directory) not found; must run with clasp -P rootdir
% mkdir -p project-2.4.1/{tools,src}
% cd project-2.4.1/tools
% npm install @google/clasp@2.4.1
...
% ./node_modules/.bin/clasp create --type webapp --title test-2.4.1 --rootDir ../src
Created new webapp script: https://script.google.com/d/.../edit
Warning: files in subfolder are not accounted for unless you set a '../src/.claspignore' file.
Cloned 1 file.
└─ ../src/appsscript.json
% ./node_modules/.bin/clasp push
No valid /Users/chjones/Downloads/project-2.4.1/tools/.clasp.json project file. You may need to `create` or `clone` a project first.
% ./node_modules/.bin/clasp -P ../src push
└─ ../src/appsscript.json
Pushed 1 file.
Specifications
- Node version (
node -v
): 16.5.0 - Version (
clasp -v
): 2.4.1 - OS (Mac/Linux/Windows):Mac
Presumably this is associated with #865 ; the new behavior may be the “correct” one, but failure to create .clasp.json in the working directory is a breaking change when that is expected (at least, for some of my scripts. 😃 ) Is this worth specifying in documentation or release notes?
Thanks as always, CDJ
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
@google/clasp - npm
rootDir : Local directory in which clasp will store your project files. If not specified, clasp will default to the current directory.
Read more >Error working with google apps script locally in VSCode using ...
... the changes with the push command I get the following error: PS D:\evcPRD> clasp push. No valid D:\evcPRD.clasp.json project file.
Read more >appsscript.json invalid. `create` or `clone` a project first.
As I understand I need to change rootDir in .clasp.json. But is it the best decision? Emily Seville's profile photo ...
Read more >How to automate Google Apps Script deployments with ...
clasp.json) that contains important information about the created document. As we will use two documents as possible destinations for our code, ...
Read more >If You Use Clasp With Google Apps Script, You Need This ...
clasp.json file so that the code is pushed to the intended project environment. It takes two arguments, <path_to_folder> and <apps_script_project_id> ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Additional issue: as the relative directory rootDir is also written to .clasp.json as given to the --rootDir option., clasp -P must also be called from a directory at a certain hierarchy.
From the above, if we are in the
tools
directory and useclasp create ... --rootDir ../src
to place the project in the givensrc
directory,../src
is written to.clasp.json
, hence moving up a directory level and callingclasp -P src/ ...
results in:If we can agree on desired behavior for
--rootDir
and-P
I’m happy to work on a PR. Thanks again!I figured out that:
clasp push
need a.clasp.json
to know what to do.clasp create ... --rootDir ./dist
create.clasp.json
automatically and store it at./dist/.clasp.json
./dist
DIRECTORY DOES NOT EXIST CLASP WON’T CREATE THE FILE.IF YOU ARE CREATING A NEW PROJECT
( Google Sheets as Container in this example )
It’s better you initialize the project with :
This let clasp create the
.clasp.json
in the current working directory.Then, assumed your code bundler (ie. webpack ) put your code inside
./dist
, you need to manually update the.clasp.json
:IF YOU’VE ALREADY CREATED A PROJECT
In this case you should not have the
.clasp.json
file.So create
.clasp.json
and put in project root directory , or the directory from where you callclasp pull | push
: