Skip to content

Commit a98e6f5

Browse files
authored
Merge pull request #145 from banchan86/environments-2.9
Update "Environments" article for Bonsai 2.9
2 parents ae40a46 + fe89e5b commit a98e6f5

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

articles/environments.md

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ If you have many projects, you might notice that older projects require specific
1111
`Bonsai` addresses these problems by supporting the creation of reproducible package environments. An environment is a self-contained, portable, installation of `Bonsai` that records a *snapshot* of all the packages required to run the workflows in your project. This makes it much easier to share a project with other people, or keep track of multiple separate projects in your local machine, and be assured you always have everything you need in the right place.
1212

1313
## Environment Basics
14+
1415
The key to creating and updating environments is the `Bonsai.config` file, which keeps a record of all currently installed dependencies for a specific Bonsai setup. You can find this file in the same location of the Bonsai executable (`Bonsai.exe`). Anytime you install or update a package, Bonsai will automatically modify the config file.
1516

1617
The contents of the `Bonsai.config` file are compared with the current state of the `Packages` folder when Bonsai starts. If there are any missing packages the Bonsai bootstrapper will download them automatically to recover the expected state of the installation folder.
1718

1819
There is a second configuration file located next to the `Bonsai.config` file called `NuGet.config`. This file stores a list of all the remote, and local, NuGet package sources where the [`Package Manager`](xref:packages) should look for new packages. While this file needs to be included in the environment, most users do not need to modify it.
1920

2021
## Portable Method
22+
2123
> [!TIP]
2224
> We recommend this approach for the casual user.
2325
@@ -26,50 +28,47 @@ The easiest way to create a self-contained Bonsai environment is to download the
2628
1. Start by downloading the [latest Bonsai portable release](https://github.com/bonsai-rx/bonsai/releases/latest/download/Bonsai.zip).
2729
2. After extracting all the files from the `Bonsai.zip` file, your folder will look like this:
2830

29-
![Portable Bonsai release](~/images/environments-portablerelease.png)
31+
![Portable Bonsai release](~/images/environments-portablerelease.png){width=150}
3032

3133
3. Run `Bonsai.exe`. During this first run, Bonsai will bootstrap the core dependencies and create an initial `Bonsai.config` file.
3234
4. Install the **Bonsai - Vision** package using the [`Package Manager`](xref:packages). The `Bonsai.config` file will be modified to specify this package as a new dependency. Any additional dependencies which might be needed for the package to run will also be added.
3335
5. Close Bonsai.
3436

3537
You now have a local Bonsai environment folder that you can keep separate for experiments or share with anyone else who needs it. Alternatively, once you have a modified `Bonsai.config` file, you can also simply copy the `Bonsai.config` file into a new portable installation, and the Bonsai bootstrapper will download and resolve the missing or inconsistent packages.
3638

37-
## Template Method
39+
## Command-Line Method
40+
3841
> [!TIP]
3942
> We recommend this approach for users who need to deploy and maintain multiple environments. This approach assumes familiarity with the command-line.
4043
41-
We have also provided a command-line tool for "one-click" deployment which installs packages automatically and streamlines the process for creating new environments.
44+
> [!NOTE]
45+
> This method supersedes the older template method as its functionality is now integrated into the Bonsai bootstrapper.
4246
43-
1. Install [`.NET SDK`](https://dotnet.microsoft.com/en-us/download).
44-
2. Install `Bonsai.Templates` with the following command.
45-
```cmd
46-
dotnet new install Bonsai.Templates
47-
```
48-
3. Navigate to the folder where you want to create a new Bonsai environment and run this command.
49-
```cmd
50-
dotnet new bonsaienv
51-
```
52-
This creates by default a `.bonsai` folder with a minimal bonsai environment in your current directory. It will also prompt to run a powershell script to install any packages based on `Bonsai.config`. Before running the powershell script, you can replace the `Bonsai.config` file with a modified version or run the powershell script after by navigating to the `.bonsai` folder and running:
47+
We have also provided a command-line tool for "one-click" deployment which installs packages automatically and streamlines the process for creating and restoring environments.
48+
49+
1. Download the [Bonsai installer](https://bonsai-rx.org/docs/articles/installation.html).
50+
2. When running the installer, ensure that **Add to PATH (requires shell restart)** is selected within **Options**.
51+
3. Navigate to the folder where you want to create a new Bonsai environment and run this command.
5352

5453
```cmd
55-
./Setup.cmd
56-
```
57-
4. You can supply additional options to change the default settings. The following command for instance will create a new folder `project1` containing a bonsai environment folder named `env`.
58-
```cmd
59-
dotnet new bonsaienv -o project1 -n .env
54+
bonsai --init
6055
```
61-
To install new packages in this environment, simply open the local `Bonsai.exe` and install the packages you need.
6256

63-
To share this environment with others, all you need are these 4 files.
57+
This command creates a `.bonsai` local environment folder in your current directory and will also install any core dependencies. To install new packages in this environment, open the `Bonsai.exe` located in this folder and install the packages you need.
58+
59+
To share this environment with others, all you need are these two files.
6460

65-
- `Setup.ps1`
66-
- `Setup.cmd`.
6761
- `NuGet.config`
6862
- `Bonsai.config`
6963

70-
Other users will be able to easily install your current Bonsai dependencies by running the `Setup.cmd` file.
64+
To restore the environment, navigate to the folder containing these files and run this command.
65+
66+
```cmd
67+
bonsai --no-editor
68+
```
7169

7270
## Adding Local Dependencies
71+
7372
> [!TIP]
7473
> For [new package](xref:create-package) developers, you may need to install local NuGet packages as dependencies during testing.
7574
@@ -81,9 +80,6 @@ For example, to add a new package source named `LocalPackages` pointing to the D
8180
<?xml version="1.0" encoding="utf-8"?>
8281
<configuration>
8382
<packageSources>
84-
<add key="Gallery" value="Gallery" />
85-
<add key="Bonsai Packages" value="https://www.myget.org/F/bonsai/api/v3/index.json" />
86-
<add key="Community Packages" value="https://www.myget.org/F/bonsai-community/api/v3/index.json" />
8783
<add key="LocalPackages" value="C:\Users\BonsaiUser\Desktop"/>
8884
</packageSources>
8985
</configuration>
@@ -101,10 +97,9 @@ You can also use relative paths if you want to keep package sources relative to
10197
Similar to `Bonsai.config` the `NuGet.config` file will be used as part of the bootstrapper process when `Bonsai.exe` starts.
10298

10399
## Version Control
104-
To keep track of environments, all that is needed are these four files from the [template method](#template-method)
105100

106-
- `Setup.ps1`
107-
- `Setup.cmd`.
101+
To keep track of environments, all that is needed are these two files.
102+
108103
- `NuGet.config`
109104
- `Bonsai.config`
110105

@@ -116,4 +111,4 @@ To prevent installed packages and other binary files from being tracked, you can
116111
Packages
117112
*.exe
118113
*.exe.settings
119-
```
114+
```
5.17 KB
Loading

0 commit comments

Comments
 (0)