electric-sql / legacy-cli

ElectricSQL command line interface (CLI) tool.
https://electric-sql.com/docs
Apache License 2.0
10 stars 0 forks source link

Error trying to init existing Expo app #34

Closed gigq closed 1 year ago

gigq commented 1 year ago

I have an Expo app I'm working on, trying to init electric on it. Whenever I run the following I get this error. Tried is on an M1 macbook pro and a separate Ubuntu system and get the same error, both in version 0.4.0 and 0.3.0. Any ideas?

> electric init App --no-verify                                                                 
warning: Caught exception in Elixir.ElectricCli.Main.main/1: :error => :function_clause
  (electric_cli 0.3.0) lib/electric_cli/main.ex:153: ElectricCli.Main.map_result({:app, {:error, {:invalid, :format}}})
  (electric_cli 0.3.0) lib/electric_cli/main.ex:62: ElectricCli.Main.main/1
  (electric_cli 0.3.0) lib/bakeware/script.ex:34: ElectricCli.Main._main/0
  (elixir 1.14.3) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
  (stdlib 4.3) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
thruflo commented 1 year ago

Hey @gigq are you literally running electric init App --no-verify? If so, it's just a silly thing that the value of the app identifier needs to be lower case. Normally they're slugs like tarragon-envy-1234 but values like app or ignore-app will work. It's just the capital A in App that's causing the format error.

gigq commented 1 year ago

Thanks I get this warning, but it does create the proper electric.json and .electric and migrations folders:

> electric init app --no-verify                                                            
warning: Caught exception in Elixir.ElectricCli.Main.main/1: :error => {:with_clause, {:error, "`manifest.json` is missing in `migrations`"}}
  (electric_cli 0.3.0) lib/electric_cli/migrations.ex:39: ElectricCli.Migrations.init_migrations/2
  (electric_cli 0.3.0) lib/electric_cli/commands/init.ex:135: ElectricCli.Commands.Init.init/1
  (electric_cli 0.3.0) lib/electric_cli/main.ex:121: ElectricCli.Main.run/1
  (electric_cli 0.3.0) lib/electric_cli/main.ex:62: ElectricCli.Main.main/1
  (electric_cli 0.3.0) lib/bakeware/script.ex:34: ElectricCli.Main._main/0
  (elixir 1.14.3) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
  (stdlib 4.3) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

Then the next step fails trying to create the migration:

> electric migrations new "create docs"
Creating new migration failed.
ERROR: There was an error:
`manifest.json` is missing in `migrations`

The reason I'm trying to use --no-verify is I like the library but wanted to use it just as a local client not the sync side. I might try the normal sync path though and see if I have better luck.

thruflo commented 1 year ago

I wonder if the previous error got stuff confused. Maybe rm -rf electric.json and the .electric and migrations folders and then re-init from a clean basis? You should definitely be able to just init a new app that targets the local stack. As per https://electric-sql.com/docs/overview/examples#option-3--run-the-backend-locally (but those instructions create a new local env and configure it).

gigq commented 1 year ago

Ah yes I see what happened, I had removed .electric and electric.json but not the empty migrations folder as it wasn't in git stat. Having that empty folder was enough to throw it off. Works now thanks for the help.

thruflo commented 1 year ago

Thanks for flagging up -- appreciate the visibility into the issues. This config stuff is fiddly atm.