Troubleshoot Import and Apply Errors Beta
- free
- growth
- enterprise
4 minute read
This guide covers common validation and error scenarios when you import workspace resources into a CLI project or run apply afterward.
Project has changes to be synced
The import workspace command fails with the following error:
Error: import not allowed as project has changes to be syncedWhat it means: Before it imports anything, Rudder CLI compares your local project with the resources in the workspace that are already CLI-managed. The import runs only when the two match, that is, when apply would have nothing to do. Any difference blocks it:
- Resources in your project that don’t exist in the workspace yet
- Resources whose settings in your project differ from the workspace
- CLI-managed resources in the workspace that your project doesn’t contain
Differences in secret values alone don’t block the import.
Common causes
The workspace already has resources managed by another CLI project. This is the usual cause when you run the import from a new or empty directory. Your project contains none of those resources, so they count as pending deletions. The import never re-imports resources that a project already manages, so there’s no way to import them into a second project.
Your project has changes you haven’t applied yet, or someone changed CLI-managed resources outside Rudder CLI.
Your specs use
{{ .VAR }}references and you didn’t pass--var-file. Without the var file,import workspacecan’t resolve those references when it reads the project, so the affected fields read as changes. Rudder CLI v0.26.0 and later accept--var-fileonimport workspace. Pass the same var file you use withapply:bashrudder-cli import workspace -l <project-directory> --var-file ./secrets.vars.yamlOn v0.25.1 and earlier,
import workspacehas no--var-fileflag. Upgrade Rudder CLI.
Don’t runapplyjust to clear this error. If you run it from an empty or partial project,applydeletes every CLI-managed resource in the workspace that the project doesn’t contain.
Fix:
See what differs. A dry run shows the plan without changing anything:
bashrudder-cli apply -l <project-directory> --dry-runResources under Removed resources are CLI-managed in the workspace but missing from your project.
applywould delete them.If Removed resources lists resources that this project didn’t create, another CLI project owns them. Find the Git repository that holds that project and run
import workspacefrom there, so a single project manages the whole workspace. See One project per workspace. If you can’t find that project, contact RudderStack support before you runapply.If the plan shows only changes you intend to make, such as specs you added or edited in this project, apply them and then run
import workspaceagain.
Imported directory already exists
If an imported directory already exists in your project, the import workspace command will fail with the following error:
Error: directory for import: my-project/imported already existsFix: Move anything you need out of imported/, delete the imported directory, and run import workspace again.
Import fails with “file exists” for transformation code
The import workspace command fails with an error like:
Error: writing files for formattable entities: writing my-project/imported/transformations/javascript/<name>.js: opening file ... file existsCause: A transformation and a transformation library in the workspace use the same language and have the same name. Names that differ only in case, spaces, or punctuation, such as My Utils and my-utils, count as the same. Import tries to write both code files to the same path. This is a known issue in Rudder CLI v0.25.1 and earlier.
Fix: Upgrade to a Rudder CLI release that includes the import file-name dedupe fix, where import renames the second file automatically. On v0.25.1 and earlier:
- In the RudderStack dashboard, rename the transformation or the library so the names differ. If you rename the library, make sure its import name, which transformation code uses to import it, doesn’t change.
- Delete the partially written
importeddirectory. - Run
import workspaceagain.
Import fails for a specific resource
When import workspace or a resource-specific import fails:
- Confirm the workspace still contains the
remote_idyou’re importing - Confirm your token includes the required permissions for that resource type
- Make sure the
local_iddoesn’t conflict with an existing CLI-managed resource
Apply fails after import
When apply fails right after an import:
- Check that every generated YAML file is present and valid
- For SQL models you imported with
--sql-location, keep the YAML and the referenced.sqlfile on the paths Rudder CLI expects - Confirm you’re logged in and the token can reach the workspace
- Confirm that no manual changes were made to the resource in the RudderStack dashboard after import — if changes were made outside Rudder CLI, you will be prompted to reconcile them
Resource deleted from dashboard before apply
If you delete a resource from the RudderStack dashboard after running import workspace but before running apply, the apply command will fail with:
Resource with ID not foundFix: Remove the matching YAML from the project (or rewrite it so Rudder CLI creates a new resource), then run apply again.