Create new branch for Development with forest New agent

Hello :wave:

After the forest init I get my forest secrets for the Development environment, but when I try to create a new branch for the Development environment, I get the following errors in Observed behavior part

Feature(s) impacted

forest-cli, forest environments and forest branch

Observed behavior

forest environments return error:

forest branch return error:

Expected behavior

that I can create a branch for the Development environment via the forest commands

Context

  • Project name: Nostrum Care v3
  • Team name: Op
  • Environment name: development
  • Agent (forest package) name & version:
    @forestadmin/agent”: “^1.0.0”,
    @forestadmin/datasource-sequelize”: “^1.5.21”,
    @forestadmin/datasource-sql”: “^1.0.0”,
    “dotenv”: “^16.0.1”,
    “pg”: “^8.8.0”,
    “sequelize”: “^6.33.0”
  • Database type: Postgresql

Thanks in advance

Hello Jacques,
I see that there is no environment named “Development” on your project, but there is an environment with the name “Development | nostrumtech.”

Can you try to create a branch from this environment ?

Hello @Enki
Yes sorry, I tried to create the “Development | nostrumtech.” environment brache but I get the errors I mentioned above.

What is the command you are using ?
It should be like :

forest branch <your-branch-name> --origin “Development | nostrumtech.”

Yes I use this, but donen’t work

quotes are important. There is spaces in the name of your environment, so the CLI take each word as a command.
You wrote “orgin” instead of origin.

Yes my bad, but I have this

What does it tell you when you do “forest branch” ? It should list the available branches and environments.

The CLI takes the values in your .env to determine on which environment you are. Can you check that you provided the right FOREST_ENV_SECRET in your .env ?

For forest branch:


Yes I have a good FOREST_ENV_SECRET

To which environment this FOREST_ENV_SECRET corresponds ?
Do you execute the command forest branch development-local from the same directory of the .env file ?

This error means that the CLI does not find any environment from the .env in the same folder that the command is executed. Are you sure the FOREST_ENV_SECRET has the same value of the one provided in the environment settings page ?

Hello @Enki

Sorry for the late reply.
I’m currently working on another project, but I’ll let you know as soon as I get back to the forest project.

Best regards

Hello @jacques_liao,
Thank you for keeping us updated ! :pray:
I’m marking the topic as solved temporarily. If you find that the solution suggested by @Enki doesn’t fix your problem, feel free to update the status.

Regards
@Nicolas.M

Hello @Nicolas @Enki
it’s fine, I’m available to take up this subject which is still unresolved on my side.

As you can see, the .env file is in our Nostrum-forest folder, and when I run the command, it’s also in the same directory. However, I still get the not found error

Hello @jacques_liao ,

I see that you have none of the required environment variables to make forest work.
During the onboarding, you should have seen a screen similar to this:

These environment variables need to be added to your .env
You can find the FOREST_ENV_SECRET in the details of an environment in the environment settings.
FOREST_AUTH_SECRET is used for user authentication and can be any value at the same format.
Can you add these to your .env and tell me if it solved your issue ?

Regards,
@Enki

Hello, I have FOREST_ENV_SECRET and FOREST_AUTH_SECRET in our .env file. :confused:
I can npm start

Could you please ensure that you have the latest version of the forest-cli (by checking with forest -v, and upgrade if necessary).
Then try running forest environments again and see if you can find your environment among the listed projects. This command shouldnt require .env variables, only for you to be logged in to the correct user account.

Hello @Nicolas.M
I have forest-cli/4.3.1 darwin-arm64 node-v20.7.0

And for forest environments:

forest environments
Error: Not Found
    at Request.callback (/opt/homebrew/lib/node_modules/forest-cli/node_modules/superagent/lib/node/index.js:857:15)
    at /opt/homebrew/lib/node_modules/forest-cli/node_modules/superagent/lib/node/index.js:1100:20
    at IncomingMessage.<anonymous> (/opt/homebrew/lib/node_modules/forest-cli/node_modules/superagent/lib/node/parsers/json.js:22:7)
    at IncomingMessage.emit (node:events:526:35)
    at endReadableNT (node:internal/streams/readable:1376:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
From previous event:
    at PromiseRequest.then (/opt/homebrew/lib/node_modules/forest-cli/node_modules/superagent-promise/index.js:43:12)
    at ProjectManager.getByEnvSecret (/opt/homebrew/lib/node_modules/forest-cli/dist/services/project-manager.js:41:14)
    at withCurrentProject (/opt/homebrew/lib/node_modules/forest-cli/dist/services/with-current-project.js:13:53)
    at async EnvironmentCommand.runAuthenticated (/opt/homebrew/lib/node_modules/forest-cli/dist/commands/environments.js:15:24)
    at async EnvironmentCommand.run (/opt/homebrew/lib/node_modules/forest-cli/dist/abstract-authenticated-command.js:17:13)
    at async EnvironmentCommand._run (/opt/homebrew/lib/node_modules/forest-cli/node_modules/@oclif/command/lib/command.js:29:20)
    at async Config.runCommand (/opt/homebrew/lib/node_modules/forest-cli/node_modules/@oclif/config/lib/config.js:151:9)
    at async Main.run (/opt/homebrew/lib/node_modules/forest-cli/node_modules/@oclif/command/lib/main.js:21:9)
    at async Main._run (/opt/homebrew/lib/node_modules/forest-cli/node_modules/@oclif/command/lib/command.js:29:20

Hello,
The error that you are getting is highlighting the fact that you still have an incorrect FOREST_ENV_SECRET in your environment.
it is most probably due to the key FOREST_ENV_SECRET in the .env file in the directory where you are running the forest environments command.
Could you please provide with the first 4 and last 4 digits of this FOREST_ENV_SECRET so that I can check against our database that it exists and you have rights to access it ?
You can send it in private message if you prefer.

Regards,

@Nicolas.M

Hello,

Here it is:
5f80 and 0525